-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathupgrade_test.go
87 lines (67 loc) · 2.56 KB
/
upgrade_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package tests
import (
"log"
"testing"
"time"
"github.com/canonical/matter-snap-testing/env"
"github.com/canonical/matter-snap-testing/utils"
"github.com/stretchr/testify/assert"
)
func TestUpgrade(t *testing.T) {
start := time.Now()
t.Cleanup(func() {
utils.SnapDumpLogs(t, start, allClustersSnap)
utils.SnapDumpLogs(t, start, chipToolSnap)
// Remove snaps, ignoring errors during removal
utils.SnapRemove(nil, allClustersSnap)
utils.SnapRemove(nil, chipToolSnap)
})
// Start clean
utils.SnapRemove(t, allClustersSnap)
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, allClustersSnap, "latest/beta")
// Setup all clusters app
utils.SnapSet(t, allClustersSnap, "args", "--wifi")
utils.SnapConnect(t, allClustersSnap+":avahi-control", "")
utils.SnapConnect(t, allClustersSnap+":bluez", "")
// Start all clusters app
utils.SnapStart(t, allClustersSnap)
utils.WaitForLogMessage(t,
allClustersSnap, "CHIP minimal mDNS started advertising", start)
t.Run("Commission", func(t *testing.T) {
stdout, _, _ := utils.Exec(t, "chip-tool pairing onnetwork 110 20202021 2>&1")
assert.NoError(t, utils.WriteLogFile(t, chipToolSnap, stdout))
})
t.Run("Control before upgrade", 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)
start := time.Now()
stdout, _, _ := utils.Exec(t, "chip-tool onoff on 110 1 2>&1")
assert.NoError(t, utils.WriteLogFile(t, chipToolSnap, stdout))
waitForOnOffHandlingByAllClustersApp(t, start)
})
t.Run("Upgrade snap", func(t *testing.T) {
if env.SnapPath() != "" {
utils.SnapInstallFromFile(t, env.SnapPath())
} else {
utils.SnapRefresh(t, chipToolSnap, "latest/edge")
}
})
t.Run("Control after upgrade", 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)
start := time.Now()
stdout, _, _ := utils.Exec(t, "chip-tool onoff off 110 1 2>&1")
assert.NoError(t, utils.WriteLogFile(t, chipToolSnap, stdout))
waitForOnOffHandlingByAllClustersApp(t, start)
})
}