-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Set tmpdir to snap home dir using command chain. Remove outdated path rewrites and unnecessary mounts. * Add post refresh hook Copy system-wide common files to root user specific common directory. * Simplify local part build command * Add a test for upgrading from stable to local/edge Make sure we can still control a paired device after upgrading * Update readme to not use sudo where it's not required Add a section explaining the change to no requiring sudo Add commands to move to a new user and fix a know error
- Loading branch information
1 parent
a3550bd
commit 1661240
Showing
7 changed files
with
140 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
# This script runs as root, so $SNAP_USER_COMMON is /root/snap/chip-tool/common | ||
# See https://forum.snapcraft.io/t/snapcraft-hook-support/19069/12 | ||
|
||
if [ -d $SNAP_COMMON/mnt ] && [ -n "$(ls -A $SNAP_COMMON/mnt)" ]; then | ||
cp $SNAP_COMMON/mnt/* $SNAP_USER_COMMON/; | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
export TMPDIR=$SNAP_USER_COMMON | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package tests | ||
|
||
import ( | ||
"github.com/canonical/matter-snap-testing/utils" | ||
"github.com/stretchr/testify/assert" | ||
"log" | ||
"os" | ||
"testing" | ||
"time" | ||
) | ||
|
||
func TestUpgrade(t *testing.T) { | ||
start := time.Now() | ||
|
||
// Remove snaps and logs at end of test, even if it failed | ||
t.Cleanup(func() { | ||
utils.SnapRemove(nil, allClusterSnap) | ||
utils.SnapDumpLogs(nil, start, allClusterSnap) | ||
utils.SnapRemove(nil, chipToolSnap) | ||
utils.SnapDumpLogs(nil, start, chipToolSnap) | ||
}) | ||
|
||
// Start clean | ||
utils.SnapRemove(t, allClusterSnap) | ||
utils.SnapRemove(t, chipToolSnap) | ||
|
||
// Install stable chip tool from store | ||
utils.SnapInstallFromStore(t, chipToolSnap, "latest/stable") | ||
|
||
// Setup chip-tool | ||
utils.SnapConnect(t, chipToolSnap+":avahi-observe", "") | ||
utils.SnapConnect(t, chipToolSnap+":bluez", "") | ||
utils.SnapConnect(t, chipToolSnap+":process-control", "") | ||
|
||
// Install all clusters app | ||
utils.SnapInstallFromStore(t, allClusterSnap, utils.ServiceChannel) | ||
|
||
// Setup all clusters app | ||
utils.SnapSet(t, allClusterSnap, "args", "--wifi") | ||
utils.SnapConnect(t, allClusterSnap+":avahi-control", "") | ||
utils.SnapConnect(t, allClusterSnap+":bluez", "") | ||
|
||
// Start all clusters app | ||
utils.SnapStart(t, allClusterSnap) | ||
utils.WaitForLogMessage(t, | ||
allClusterSnap, "CHIP minimal mDNS started advertising", start) | ||
|
||
// Pair device | ||
t.Run("Commission", func(t *testing.T) { | ||
stdout, _, _ := utils.Exec(t, "sudo chip-tool pairing onnetwork 110 20202021 2>&1") | ||
assert.NoError(t, | ||
os.WriteFile("chip-tool-pairing.log", []byte(stdout), 0644), | ||
) | ||
}) | ||
|
||
// Control device | ||
t.Run("Control with stable snap", func(t *testing.T) { | ||
snapVersion := utils.SnapVersion(t, chipToolSnap) | ||
snapRevision := utils.SnapRevision(t, chipToolSnap) | ||
log.Printf("%s installed version %s build %s\n", chipToolSnap, snapVersion, snapRevision) | ||
|
||
stdout, _, _ := utils.Exec(t, "sudo chip-tool onoff toggle 110 1 2>&1") | ||
assert.NoError(t, | ||
os.WriteFile("chip-tool-onoff.log", []byte(stdout), 0644), | ||
) | ||
|
||
utils.WaitForLogMessage(t, | ||
allClusterSnap, "CHIP:ZCL: Toggle ep1 on/off", start) | ||
}) | ||
|
||
// Upgrade chip-tool to local snap or edge | ||
if utils.LocalServiceSnap() { | ||
utils.SnapInstallFromFile(t, utils.LocalServiceSnapPath) | ||
} else { | ||
utils.SnapRefresh(t, chipToolSnap, "latest/edge") | ||
} | ||
|
||
// Control device again | ||
t.Run("Control upgraded snap", func(t *testing.T) { | ||
snapVersion := utils.SnapVersion(t, chipToolSnap) | ||
snapRevision := utils.SnapRevision(t, chipToolSnap) | ||
log.Printf("%s installed version %s build %s\n", chipToolSnap, snapVersion, snapRevision) | ||
|
||
stdout, _, _ := utils.Exec(t, "sudo chip-tool onoff toggle 110 1 2>&1") | ||
assert.NoError(t, | ||
os.WriteFile("chip-tool-onoff.log", []byte(stdout), 0644), | ||
) | ||
|
||
utils.WaitForLogMessage(t, | ||
allClusterSnap, "CHIP:ZCL: Toggle ep1 on/off", start) | ||
}) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters