This repository has been archived by the owner on Oct 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
main_test.go
94 lines (75 loc) · 2.21 KB
/
main_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
88
89
90
91
92
93
94
package test
import (
"edgex-snap-testing/test/utils"
"log"
"os"
"testing"
"time"
)
const (
ascSnap = "edgex-app-service-configurable"
ascApp = "app-service-configurable"
ascService = ascSnap + "." + ascApp
defaultTestProfile = "rules-engine"
defaultTestProfileServicePort = "59701"
)
func TestMain(m *testing.M) {
start := time.Now()
log.Println("[SETUP]")
// start clean
utils.SnapRemove(nil,
ascSnap,
"edgexfoundry",
)
// install the app-service-configurable snap before edgexfoundry
// to catch build error sooner and stop
if utils.LocalSnap != "" {
utils.SnapInstallFromFile(nil, utils.LocalSnap)
// for local build, the interface isn't auto-connected.
// connect manually
utils.SnapConnect(nil,
"edgexfoundry:edgex-secretstore-token",
ascSnap+":edgex-secretstore-token",
)
} else {
utils.SnapInstallFromStore(nil, ascSnap, utils.ServiceChannel)
}
utils.SnapInstallFromStore(nil, "edgexfoundry", utils.PlatformChannel)
// make sure all services are online before starting the tests
utils.WaitPlatformOnline(nil)
// set profile to rules engine
utils.SnapSet(nil, ascSnap, "profile", defaultTestProfile)
exitCode := m.Run()
log.Println("[TEARDOWN]")
utils.SnapDumpLogs(nil, start, ascSnap)
utils.SnapRemove(nil,
ascSnap,
"edgexfoundry",
)
os.Exit(exitCode)
}
func TestCommon(t *testing.T) {
utils.TestContentInterfaces(t, utils.ContentInterfaces{
TestSecretstoreToken: true,
Snap: ascSnap,
App: "app-" + defaultTestProfile,
})
utils.TestConfig(t, ascSnap, utils.Config{
TestChangePort: utils.ConfigChangePort{
App: ascApp,
DefaultPort: defaultTestProfileServicePort,
TestLegacyEnvConfig: utils.FullConfigTest,
TestAppConfig: true,
TestGlobalConfig: true,
TestMixedGlobalAppConfig: utils.FullConfigTest,
},
})
utils.TestNet(t, ascSnap, utils.Net{
StartSnap: true,
TestOpenPorts: []string{defaultTestProfileServicePort},
TestBindLoopback: []string{defaultTestProfileServicePort},
})
utils.TestPackaging(t, ascSnap, utils.Packaging{
TestSemanticSnapVersion: true,
})
}