Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Update device-virtual part in edgexfoundry and ekuiper test suites #62

Merged
merged 6 commits into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions test/suites/edgexfoundry/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,56 +10,56 @@ var FullConfigTest = true
// Deprecated
func TestEnvConfig(t *testing.T) {
const newPort = "11111"
const envServicePort = "env." + deviceVirtualApp + ".service.port"
const envServicePort = "env." + coreMetadataApp + ".service.port"

// start clean
utils.SnapStop(t, deviceVirtualService)
utils.SnapStop(t, coreMetadataService)

t.Cleanup(func() {
utils.SnapUnset(t, platformSnap, envServicePort)
utils.SnapStop(t, deviceVirtualService)
utils.SnapStop(t, coreMetadataService)
})
t.Run("change device-virtual service port", func(t *testing.T) {
t.Run("change core-metadata service port", func(t *testing.T) {

// make sure the port is available before using it
utils.RequirePortAvailable(t, newPort)

// set env. and validate the new port comes online
utils.SnapSet(t, platformSnap, envServicePort, newPort)
utils.SnapStart(t, deviceVirtualService)
utils.SnapStart(t, coreMetadataService)
utils.WaitServiceOnline(t, 60, newPort)

// unset env. and validate the default port comes online
utils.SnapUnset(t, platformSnap, envServicePort)
utils.SnapRestart(t, deviceVirtualService)
utils.WaitServiceOnline(t, 60, deviceVirtualDefaultServicePort)
utils.SnapRestart(t, coreMetadataService)
utils.WaitServiceOnline(t, 60, coreMetadataDefaultServicePort)

})
}

func TestAppConfig(t *testing.T) {
t.Cleanup(func() {
utils.SnapStop(t, deviceVirtualService)
utils.SnapStop(t, coreMetadataService)
})

utils.SnapStart(t, deviceVirtualService)
utils.SetAppConfig(t, platformSnap, deviceVirtualApp, deviceVirtualDefaultServicePort)
utils.SnapStart(t, coreMetadataService)
utils.SetAppConfig(t, platformSnap, coreMetadataApp, coreMetadataDefaultServicePort)
}

func TestGlobalConfig(t *testing.T) {
t.Cleanup(func() {
utils.SnapStop(t, deviceVirtualService)
utils.SnapStop(t, coreMetadataService)
})

utils.SnapStart(t, deviceVirtualService)
utils.SetGlobalConfig(t, platformSnap, deviceVirtualApp, deviceVirtualDefaultServicePort)
utils.SnapStart(t, coreMetadataService)
utils.SetGlobalConfig(t, platformSnap, coreMetadataApp, coreMetadataDefaultServicePort)
}

func TestMixedConfig(t *testing.T) {
t.Cleanup(func() {
utils.SnapStop(t, deviceVirtualService)
utils.SnapStop(t, coreMetadataService)
})

utils.SnapStart(t, deviceVirtualService)
utils.SetMixedConfig(t, platformSnap, deviceVirtualApp, deviceVirtualDefaultServicePort)
utils.SnapStart(t, coreMetadataService)
utils.SetMixedConfig(t, platformSnap, coreMetadataApp, coreMetadataDefaultServicePort)
}
14 changes: 7 additions & 7 deletions test/suites/edgexfoundry/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
)

const (
platformSnap = "edgexfoundry"
deviceVirtualApp = "device-virtual"
deviceVirtualService = platformSnap + "." + deviceVirtualApp
platformSnap = "edgexfoundry"
coreMetadataApp = "core-metadata"
coreMetadataService = platformSnap + "." + coreMetadataApp

deviceVirtualDefaultServicePort = "59900"
coreMetadataDefaultServicePort = "59881"
)

var start = time.Now()
Expand All @@ -36,9 +36,9 @@ func TestMain(m *testing.M) {
// make sure all services are online before starting the tests
utils.WaitPlatformOnline(nil)

// make sure device-virtual service starts and comes online before starting the tests
utils.SnapStart(nil, deviceVirtualService)
utils.WaitServiceOnline(nil, 60, deviceVirtualDefaultServicePort)
// make sure core-metadata service starts and comes online before starting the tests
utils.SnapStart(nil, coreMetadataService)
utils.WaitServiceOnline(nil, 60, coreMetadataDefaultServicePort)

exitCode := m.Run()

Expand Down
16 changes: 8 additions & 8 deletions test/suites/edgexfoundry/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ import (

func TestNetworkInterface(t *testing.T) {
t.Cleanup(func() {
utils.SnapStop(t, deviceVirtualService)
utils.SnapStop(t, coreMetadataService)
})

// check network interface status for device-virtual service
utils.SnapStart(t, deviceVirtualService)
// check network interface status for core-metadata service
utils.SnapStart(t, coreMetadataService)

t.Run("listen default port "+deviceVirtualDefaultServicePort, func(t *testing.T) {
utils.WaitServiceOnline(t, 60, deviceVirtualDefaultServicePort)
t.Run("listen default port "+coreMetadataDefaultServicePort, func(t *testing.T) {
utils.WaitServiceOnline(t, 60, coreMetadataDefaultServicePort)
})

t.Run("not listen on all interfaces", func(t *testing.T) {
utils.RequireListenAllInterfaces(t, false, deviceVirtualDefaultServicePort)
utils.RequireListenAllInterfaces(t, false, coreMetadataDefaultServicePort)
})

t.Run("listen localhost", func(t *testing.T) {
utils.RequireListenLoopback(t, deviceVirtualDefaultServicePort)
utils.RequirePortOpen(t, deviceVirtualDefaultServicePort)
utils.RequireListenLoopback(t, coreMetadataDefaultServicePort)
utils.RequirePortOpen(t, coreMetadataDefaultServicePort)
})

// check network interface status for all platform ports except for:
Expand Down
22 changes: 15 additions & 7 deletions test/suites/ekuiper/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import (
)

const (
ekuiperSnap = "edgex-ekuiper"
ekuiperApp = "kuiper"
ekuiperService = ekuiperSnap + "." + ekuiperApp
ekuiperSnap = "edgex-ekuiper"
ekuiperApp = "kuiper"
ekuiperService = ekuiperSnap + "." + ekuiperApp
deviceVirtualSnap = "edgex-device-virtual"
)

var start = time.Now()
Expand All @@ -23,6 +24,7 @@ func TestMain(m *testing.M) {
utils.SnapRemove(nil,
ekuiperSnap,
"edgexfoundry",
deviceVirtualSnap,
)

// install the ekuiper snap before edgexfoundry
Expand All @@ -33,6 +35,7 @@ func TestMain(m *testing.M) {
utils.SnapInstallFromStore(nil, ekuiperSnap, utils.ServiceChannel)
}
utils.SnapInstallFromStore(nil, "edgexfoundry", utils.PlatformChannel)
utils.SnapInstallFromStore(nil, deviceVirtualSnap, "latest/edge")

// make sure all services are online before starting the tests
utils.WaitPlatformOnline(nil)
Expand All @@ -43,6 +46,10 @@ func TestMain(m *testing.M) {
"edgexfoundry:edgex-secretstore-token",
ekuiperSnap+":edgex-secretstore-token",
)
utils.SnapConnect(nil,
"edgexfoundry:edgex-secretstore-token",
deviceVirtualSnap+":edgex-secretstore-token",
)

// security on (default)
exitCode := m.Run()
Expand All @@ -54,13 +61,13 @@ func TestMain(m *testing.M) {
utils.SnapStop(nil, "edgex-ekuiper")
utils.SnapSet(nil, "edgexfoundry", "security-secret-store", "off")
utils.SnapSet(nil, "edgex-ekuiper", "edgex-security", "off")
utils.SnapSet(nil, "edgex-device-virtual", "app-options", "true")
utils.SnapSet(nil, "edgex-device-virtual", "config.edgex-security-secret-store", "false")
utils.Exec(nil, "sudo rm /var/snap/edgex-ekuiper/current/edgex-ekuiper/secrets-token.json")
utils.SnapDisconnect(nil,
"edgexfoundry:edgex-secretstore-token",
ekuiperSnap+":edgex-secretstore-token",
)

utils.SnapStart(nil,
ekuiperService,
deviceVirtualSnap,
)

exitCode = m.Run()
Expand All @@ -73,6 +80,7 @@ TEARDOWN:
utils.SnapRemove(nil,
ekuiperSnap,
"edgexfoundry",
deviceVirtualSnap,
)

os.Exit(exitCode)
Expand Down
4 changes: 2 additions & 2 deletions test/suites/ekuiper/streams_rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ func TestStreamsAndRules(t *testing.T) {
utils.SnapStop(t,
ekuiperService,
"edgexfoundry.app-service-configurable",
"edgexfoundry.device-virtual")
deviceVirtualSnap)
})

utils.SnapStart(t,
ekuiperService,
"edgexfoundry.app-service-configurable",
"edgexfoundry.device-virtual")
deviceVirtualSnap)

t.Run("create stream", func(t *testing.T) {
utils.Exec(t, `edgex-ekuiper.kuiper-cli create stream stream1 '()WITH(FORMAT="JSON",TYPE="edgex")'`)
Expand Down