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

Commit

Permalink
Add LOCAL_PLATFORM_SNAP and LOCAL_SERVICE_SNAP environment variables (#…
Browse files Browse the repository at this point in the history
…219)

* Add LOCAL_PLATFORM_SNAP and LOCAL_SERVICE_SNAP environment variables

* Update GitHub action file

* Update instructions in README
  • Loading branch information
MonicaisHer committed Jun 15, 2023
1 parent 0fb52a2 commit 29eba3e
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 33 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,21 @@ Full config test:
FULL_CONFIG_TEST=true go test -v -failfast -count 1 ./test/suites/device-mqtt
```

Testing with a local snap:
Testing with a local platform snap:
```bash
LOCAL_SNAP="edgex-device-mqtt_2.0.1-dev.15_amd64.snap" go test -v -failfast -count 1 ./test/suites/device-mqtt
LOCAL_PLATFORM_SNAP="edgexfoundry_3.1.0-dev.3_amd64.snap" \
go test -v -failfast -count 1 ./test/suites/edgexfoundry
```
Testing with a local service snap:
```bash
LOCAL_SERVICE_SNAP="edgex-device-mqtt_2.0.1-dev.15_amd64.snap" \
go test -v -failfast -count 1 ./test/suites/device-mqtt
```
Testing with local platform and service snaps:
```bash
LOCAL_PLATFORM_SNAP="edgexfoundry_3.1.0-dev.3_amd64.snap" \
LOCAL_SERVICE_SNAP="edgex-device-mqtt_2.0.1-dev.15_amd64.snap" \
go test -v -failfast -count 1 ./test/suites/device-mqtt
```

Test with skipping the removal of snaps during teardown:
Expand Down
5 changes: 3 additions & 2 deletions test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ inputs:
description: Name of the testing suite
required: true
snap:
description: Relative path to local snap
description: Relative path to local platform or service snap
required: false
channel:
description: |
Expand Down Expand Up @@ -60,7 +60,8 @@ runs:
- shell: bash
working-directory: ${{github.action_path}}
env:
LOCAL_SNAP: ${{steps.path.outputs.local_snap}}
LOCAL_PLATFORM_SNAP: ${{ inputs.name == 'edgexfoundry' && steps.path.outputs.local_snap || '' }}
LOCAL_SERVICE_SNAP: ${{ inputs.name != 'edgexfoundry' && steps.path.outputs.local_snap || '' }}
PLATFORM_CHANNEL: ${{inputs.platform_channel}}
SERVICE_CHANNEL: ${{inputs.channel}}
FULL_CONFIG_TEST: ${{inputs.full_config_test}}
Expand Down
11 changes: 8 additions & 3 deletions test/suites/edgex-config-provider/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ func setup() (teardown func(), err error) {
}

// install the provider
if utils.LocalSnap() {
if err = utils.SnapInstallFromFile(nil, utils.LocalSnapPath); err != nil {
if utils.LocalServiceSnap() {
if err = utils.SnapInstallFromFile(nil, utils.LocalServiceSnapPath); err != nil {
teardown()
return
}
Expand All @@ -85,7 +85,12 @@ func setup() (teardown func(), err error) {
}
}

if err = utils.SnapInstallFromStore(nil, platformSnap, utils.PlatformChannel); err != nil {
if utils.LocalPlatformSnap() {
err = utils.SnapInstallFromFile(nil, utils.LocalPlatformSnapPath)
} else {
err = utils.SnapInstallFromStore(nil, platformSnap, utils.PlatformChannel)
}
if err != nil {
teardown()
return
}
Expand Down
4 changes: 2 additions & 2 deletions test/suites/edgex-no-sec/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ func setup() (teardown func(), err error) {
}
}

if utils.LocalSnap() {
err = utils.SnapInstallFromFile(nil, utils.LocalSnapPath)
if utils.LocalPlatformSnap() {
err = utils.SnapInstallFromFile(nil, utils.LocalPlatformSnapPath)
} else {
err = utils.SnapInstallFromStore(nil, platformSnap, utils.PlatformChannel)
}
Expand Down
4 changes: 2 additions & 2 deletions test/suites/edgexfoundry/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ func setup() (teardown func(), err error) {
}
}

if utils.LocalSnap() {
err = utils.SnapInstallFromFile(nil, utils.LocalSnapPath)
if utils.LocalPlatformSnap() {
err = utils.SnapInstallFromFile(nil, utils.LocalPlatformSnapPath)
} else {
err = utils.SnapInstallFromStore(nil, platformSnap, utils.PlatformChannel)
}
Expand Down
13 changes: 9 additions & 4 deletions test/suites/ekuiper/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ func setup() (teardown func(), err error) {

// install the ekuiper snap before edgexfoundry
// to catch build error sooner and stop
if utils.LocalSnap() {
err = utils.SnapInstallFromFile(nil, utils.LocalSnapPath)
if utils.LocalServiceSnap() {
err = utils.SnapInstallFromFile(nil, utils.LocalServiceSnapPath)
} else {
err = utils.SnapInstallFromStore(nil, ekuiperSnap, utils.ServiceChannel)
}
Expand All @@ -103,7 +103,12 @@ func setup() (teardown func(), err error) {
return
}

if err = utils.SnapInstallFromStore(nil, platformSnap, utils.PlatformChannel); err != nil {
if utils.LocalPlatformSnap() {
err = utils.SnapInstallFromFile(nil, utils.LocalPlatformSnapPath)
} else {
err = utils.SnapInstallFromStore(nil, platformSnap, utils.PlatformChannel)
}
if err != nil {
teardown()
return
}
Expand All @@ -115,7 +120,7 @@ func setup() (teardown func(), err error) {

// for local build, the interface isn't auto-connected.
// connect manually
if utils.LocalSnap() {
if utils.LocalServiceSnap() {
if err = utils.SnapConnectSecretstoreToken(nil, ekuiperSnap); err != nil {
teardown()
return
Expand Down
4 changes: 2 additions & 2 deletions test/suites/ui/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ func setup() (teardown func(), err error) {
}
}

if utils.LocalSnap() {
err = utils.SnapInstallFromFile(nil, utils.LocalSnapPath)
if utils.LocalServiceSnap() {
err = utils.SnapInstallFromFile(nil, utils.LocalServiceSnapPath)
} else {
err = utils.SnapInstallFromStore(nil, uiSnap, utils.ServiceChannel)
}
Expand Down
27 changes: 17 additions & 10 deletions test/utils/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,23 @@ import (
const (
// environment variables
// used to override defaults
platformChannelEnv = "PLATFORM_CHANNEL" // channel/revision of the edgexfoundry snap (has default)
serviceChannelEnv = "SERVICE_CHANNEL" // channel/revision of the service snap (has default)
localSnapEnv = "LOCAL_SNAP" // path to local snap to be tested instead of downloading from a channel
platformChannelEnv = "PLATFORM_CHANNEL" // channel/revision of the edgexfoundry snap (has default)
serviceChannelEnv = "SERVICE_CHANNEL" // channel/revision of the service snap (has default)
localPlatformSnapEnv = "LOCAL_PLATFORM_SNAP" // path to local platform snap to be tested instead of downloading from a channel
localServiceSnapEnv = "LOCAL_SERVICE_SNAP" // path to local service snap to be tested instead of downloading from a channel

fullConfigTestEnv = "FULL_CONFIG_TEST" // toggle full config tests (has default)
skipTeardownRemovalEnv = "SKIP_TEARDOWN_REMOVAL" // skip the removal of snaps during teardown
)

var (
// global defaults
PlatformChannel = "latest/edge"
ServiceChannel = "latest/edge"
LocalSnapPath = ""
FullConfigTest = false
SkipTeardownRemoval = false
PlatformChannel = "latest/edge"
ServiceChannel = "latest/edge"
LocalPlatformSnapPath = ""
LocalServiceSnapPath = ""
FullConfigTest = false
SkipTeardownRemoval = false
)

func init() {
Expand All @@ -33,8 +36,12 @@ func init() {
ServiceChannel = v
}

if v := os.Getenv(localSnapEnv); v != "" {
LocalSnapPath = v
if v := os.Getenv(localPlatformSnapEnv); v != "" {
LocalPlatformSnapPath = v
}

if v := os.Getenv(localServiceSnapEnv); v != "" {
LocalServiceSnapPath = v
}

if v := os.Getenv(fullConfigTestEnv); v != "" {
Expand Down
2 changes: 1 addition & 1 deletion test/utils/refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
// TestRefresh tests an EdgeX upgrade using snap refresh
func TestRefresh(t *testing.T, snapName string) {
t.Run("refresh", func(t *testing.T) {
if LocalSnap() {
if LocalPlatformSnap() {
t.Skip("Skip refresh for local snap build")
}

Expand Down
17 changes: 14 additions & 3 deletions test/utils/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ func SetupServiceTests(snapName string) (teardown func(), err error) {

// install the device/app service snap before edgexfoundry
// to catch build error sooner and stop
if LocalSnap() {
err = SnapInstallFromFile(nil, LocalSnapPath)
if LocalServiceSnap() {
err = SnapInstallFromFile(nil, LocalServiceSnapPath)
} else {
err = SnapInstallFromStore(nil, snapName, ServiceChannel)
}
Expand All @@ -50,9 +50,20 @@ func SetupServiceTests(snapName string) (teardown func(), err error) {
return
}

// install the edgexfoundry platform snap
if LocalPlatformSnap() {
err = SnapInstallFromFile(nil, LocalPlatformSnapPath)
} else {
err = SnapInstallFromStore(nil, snapName, PlatformChannel)
}
if err != nil {
teardown()
return
}

// for local build, the interface isn't auto-connected.
// connect manually
if LocalSnap() {
if LocalServiceSnap() || LocalPlatformSnap() {
if err = SnapConnectSecretstoreToken(nil, snapName); err != nil {
teardown()
return
Expand Down
8 changes: 6 additions & 2 deletions test/utils/snap.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ func SnapServicesActive(t *testing.T, name string) bool {
return strings.TrimSpace(out) == "active"
}

func LocalSnap() bool {
return LocalSnapPath != ""
func LocalPlatformSnap() bool {
return LocalPlatformSnapPath != ""
}

func LocalServiceSnap() bool {
return LocalServiceSnapPath != ""
}

0 comments on commit 29eba3e

Please sign in to comment.