From 7ee147a00bdc332dfea5ca778a87273faf190418 Mon Sep 17 00:00:00 2001 From: Mengyi Wang Date: Thu, 2 Jun 2022 17:35:24 +0200 Subject: [PATCH] Update device-virtual part in edgexfoundry and ekuiper test suites (#62) * replace device-virtual with core-metadata for config, network tests * replace edgexfoundry.device-virtual with edgex-device-virtual * add cleanup for edgex-device-virtual * Temporarily hardcode channel, remove unused `snap disconnect` --- test/suites/edgexfoundry/config_test.go | 32 +++++++++++------------ test/suites/edgexfoundry/main_test.go | 14 +++++----- test/suites/edgexfoundry/network_test.go | 16 ++++++------ test/suites/ekuiper/main_test.go | 22 +++++++++++----- test/suites/ekuiper/streams_rules_test.go | 4 +-- 5 files changed, 48 insertions(+), 40 deletions(-) diff --git a/test/suites/edgexfoundry/config_test.go b/test/suites/edgexfoundry/config_test.go index 0c7e216..6f7bb9e 100644 --- a/test/suites/edgexfoundry/config_test.go +++ b/test/suites/edgexfoundry/config_test.go @@ -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) } diff --git a/test/suites/edgexfoundry/main_test.go b/test/suites/edgexfoundry/main_test.go index c2d406e..496d1d9 100644 --- a/test/suites/edgexfoundry/main_test.go +++ b/test/suites/edgexfoundry/main_test.go @@ -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() @@ -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() diff --git a/test/suites/edgexfoundry/network_test.go b/test/suites/edgexfoundry/network_test.go index a6ef360..401a75b 100644 --- a/test/suites/edgexfoundry/network_test.go +++ b/test/suites/edgexfoundry/network_test.go @@ -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: diff --git a/test/suites/ekuiper/main_test.go b/test/suites/ekuiper/main_test.go index e19d369..fb8b3ef 100644 --- a/test/suites/ekuiper/main_test.go +++ b/test/suites/ekuiper/main_test.go @@ -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() @@ -23,6 +24,7 @@ func TestMain(m *testing.M) { utils.SnapRemove(nil, ekuiperSnap, "edgexfoundry", + deviceVirtualSnap, ) // install the ekuiper snap before edgexfoundry @@ -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) @@ -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() @@ -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() @@ -73,6 +80,7 @@ TEARDOWN: utils.SnapRemove(nil, ekuiperSnap, "edgexfoundry", + deviceVirtualSnap, ) os.Exit(exitCode) diff --git a/test/suites/ekuiper/streams_rules_test.go b/test/suites/ekuiper/streams_rules_test.go index 2b5e5fc..dc538ee 100644 --- a/test/suites/ekuiper/streams_rules_test.go +++ b/test/suites/ekuiper/streams_rules_test.go @@ -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")'`)