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

Add tests for snap config options #53

Merged
merged 25 commits into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
66a0e93
Add apps/config options tests for environment variable injection (#48)
MonicaisHer Apr 21, 2022
f978f6c
Move config testing into util functions, add `FULL_CONFIG_TEST` optio…
MonicaisHer Apr 22, 2022
99de32c
Remove extra `unset config`, add cleanup for `config-enabled` (#51)
MonicaisHer Apr 22, 2022
b4451bc
Update device-gpio's config_test (#50)
MonicaisHer Apr 25, 2022
3ac67ea
Change value of FULL_CONFIG_TEST to boolean
farshidtz Apr 25, 2022
82601a9
Update app-service-configurable's config test (#52)
MonicaisHer Apr 25, 2022
e83271c
Merge branch 'main' into config
farshidtz Apr 25, 2022
b77c7f4
Add dev channels for rest, mqtt, asc, gpio
farshidtz Apr 25, 2022
d8ba008
Replace config keys to use hyphen as separator
farshidtz Apr 25, 2022
5d1ce60
Add config tests for app-rfid-llrp-inventory (#54)
farshidtz Apr 25, 2022
a481b76
Add config testing for device-modbus (#55)
farshidtz Apr 25, 2022
018ca2b
Add config tests for device-rfid-llrp (#57)
farshidtz Apr 25, 2022
6edd8bb
Add dev channel for device-rfid-llrp
farshidtz Apr 25, 2022
3d4e6d1
Add config testing for device-snmp (#58)
farshidtz Apr 26, 2022
84f9a67
Update edgex-go's config test (#56)
MonicaisHer Apr 26, 2022
7b692a1
remove unused configure.go
MonicaisHer Apr 27, 2022
4cbb9e6
rename each app
MonicaisHer Apr 27, 2022
cfc1e65
construct `service` using `snap` and `app`
MonicaisHer Apr 27, 2022
90531fe
remove not needed `else` after `t.SKip()`
MonicaisHer Apr 27, 2022
ee4a90f
rename vars
MonicaisHer Apr 27, 2022
7a1f36a
move `FullConfigTest` out of each function, and do cleanup
MonicaisHer Apr 27, 2022
5c8b6ec
install with `ServiceChannel` when test edgexfoundry
MonicaisHer Apr 27, 2022
08c27ff
update description for `platform_channel`
MonicaisHer Apr 27, 2022
e7e0c79
remove temporary pr channels
MonicaisHer Apr 27, 2022
2d1d34a
Minor cleanup
farshidtz Apr 27, 2022
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
1 change: 1 addition & 0 deletions .github/workflows/snap-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@ jobs:
with:
name: ${{matrix.name}}
channel: ${{matrix.channel}}
platform_channel: ${{matrix.platform_channel}}
print_logs: ${{matrix.print_logs}}
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ To test all:
go test -p 1 ./test/suites/...
```

Test one with variables, e.g.:
```bash
FULL_CONFIG_TEST=true go test -p 1 ./test/suites/device-mqtt
```
```bash
LOCAL_SNAP="edgex-device-mqtt_2.0.1-dev.15_amd64.snap" go test -p 1 ./test/suites/device-mqtt
```

Test the testing utils:
```bash
go test ./test/utils -count=10
Expand Down
7 changes: 7 additions & 0 deletions test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ inputs:
Channel for downloading the snap from store.
This is useful only when 'snap' input is not set.
required: false
platform_channel:
description: |
Channel for downloading the edgexfoundry snap from store.
This is used when testing services against the edgexfoundry snap.
This is useful only when 'snap' input is not set.
required: false
print_logs:
description: |
Print snap logs.
Expand Down Expand Up @@ -48,6 +54,7 @@ runs:
working-directory: ${{github.action_path}}
env:
LOCAL_SNAP: ${{steps.path.outputs.local_snap}}
PLATFORM_CHANNEL: ${{inputs.platform_channel}}
SERVICE_CHANNEL: ${{inputs.channel}}
run: |
go test -p 1 -timeout 30m -v ./suites/${{inputs.name}}
Expand Down
26 changes: 9 additions & 17 deletions test/suites/app-rfid-llrp-inventory/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,17 @@ import (

// Deprecated
func TestEnvConfig(t *testing.T) {
utils.SetEnvConfig(t, appRfidLlrpSnap, appRfidLlrpApp, defaultServicePort)
}

t.Run("change service port", func(t *testing.T) {
t.Cleanup(func() {
utils.SnapStop(t, appRfidLlrpService)
utils.SnapUnset(t, appRfidLlrpSnap, "env.service.port")
})

const newPort = "56789"

// make sure the port is available before using it
utils.RequirePortAvailable(t, newPort)
func TestAppConfig(t *testing.T) {
utils.SetAppConfig(t, appRfidLlrpSnap, appRfidLlrpApp, defaultServicePort)
}

utils.SnapStop(t, appRfidLlrpSnap)
utils.SnapSet(t, appRfidLlrpSnap, "env.service.port", newPort)
utils.SnapStart(t, appRfidLlrpSnap)
utils.WaitServiceOnline(t, 60, newPort)
})
func TestGlobalConfig(t *testing.T) {
utils.SetGlobalConfig(t, appRfidLlrpSnap, appRfidLlrpApp, defaultServicePort)
}

func TestAppConfig(t *testing.T) {
t.Skip("TODO")
func TestMixedConfig(t *testing.T) {
utils.SetMixedConfig(t, appRfidLlrpSnap, appRfidLlrpApp, defaultServicePort)
}
7 changes: 5 additions & 2 deletions test/suites/app-rfid-llrp-inventory/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ import (
"time"
)

const appRfidLlrpSnap = "edgex-app-rfid-llrp-inventory"
const appRfidLlrpService = "edgex-app-rfid-llrp-inventory.app-rfid-llrp-inventory"
const (
appRfidLlrpSnap = "edgex-app-rfid-llrp-inventory"
appRfidLlrpApp = "app-rfid-llrp-inventory"
appRfidLlrpService = appRfidLlrpSnap + "." + appRfidLlrpApp
)

var start = time.Now()

Expand Down
30 changes: 10 additions & 20 deletions test/suites/app-service-configurable/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,23 @@ import (
)

const profile = "http-export"
const appRulesEngineServicePort = "59720"

// Deprecated
func TestEnvConfig(t *testing.T) {
// start clean
utils.SnapStop(t, ascService)

t.Run("change service port", func(t *testing.T) {
t.Cleanup(func() {
utils.SnapStop(t, ascService)
utils.SnapUnset(t, ascSnap, "env.service.port")
utils.SnapSet(t, ascSnap, "env.service.port", appRulesEngineServicePort)
})

const newPort = "56789"
utils.SetEnvConfig(t, ascSnap, ascApp, appServiceRulesServicePort)
}

// make sure the port is available before using it
utils.RequirePortAvailable(t, newPort)
func TestAppConfig(t *testing.T) {
utils.SetAppConfig(t, ascSnap, ascApp, appServiceRulesServicePort)
}

utils.SnapSet(t, ascSnap, "env.service.port", newPort)
utils.SnapStart(t, ascSnap)
utils.WaitServiceOnline(t, 60, newPort)
})
func TestGlobalConfig(t *testing.T) {
// start clean
utils.SetGlobalConfig(t, ascSnap, ascApp, appServiceRulesServicePort)
}

func TestAppConfig(t *testing.T) {
t.Skip("TODO")
func TestMixedConfig(t *testing.T) {
utils.SetMixedConfig(t, ascSnap, ascApp, appServiceRulesServicePort)
}

func TestProfileConfig(t *testing.T) {
Expand Down
16 changes: 13 additions & 3 deletions test/suites/app-service-configurable/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ import (
"time"
)

const ascSnap = "edgex-app-service-configurable"
const ascService = "edgex-app-service-configurable.app-service-configurable"
const defaultProfile = "rules-engine"
const (
ascSnap = "edgex-app-service-configurable"
ascApp = "app-service-configurable"
ascService = ascSnap + "." + ascApp
defaultProfile = "rules-engine"
appServiceRulesServicePort = "59701"
)

var start = time.Now()

Expand Down Expand Up @@ -46,6 +50,12 @@ func TestMain(m *testing.M) {
// set profile to rules engine
utils.SnapSet(nil, ascSnap, "profile", defaultProfile)

// Start the service so that the default config gets uploaded to consul.
// Otherwise, settings that get passed using environment variables on first start get uploaded
// and become the default.
utils.SnapStart(nil, ascService)
utils.WaitServiceOnline(nil, 60, appServiceRulesServicePort)

exitCode := m.Run()

log.Println("[TEARDOWN]")
Expand Down
10 changes: 5 additions & 5 deletions test/suites/app-service-configurable/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ func TestNetworkInterface(t *testing.T) {

utils.SnapStart(t, ascService)

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

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

t.Run("listen localhost", func(t *testing.T) {
utils.RequireListenLoopback(t, appRulesEngineServicePort)
utils.RequirePortOpen(t, appRulesEngineServicePort)
utils.RequireListenLoopback(t, appServiceRulesServicePort)
utils.RequirePortOpen(t, appServiceRulesServicePort)
})
}
28 changes: 10 additions & 18 deletions test/suites/device-gpio/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,18 @@ import (

// Deprecated
func TestEnvConfig(t *testing.T) {
// start clean
utils.SnapStop(t, deviceGpioService)

t.Run("change service port", func(t *testing.T) {
t.Cleanup(func() {
utils.SnapStop(t, deviceGpioService)
utils.SnapUnset(t, deviceGpioSnap, "env.service.port")
})

const newPort = "56789"
utils.SetEnvConfig(t, deviceGpioSnap, deviceGpioApp, defaultServicePort)
}

// make sure the port is available before using it
utils.RequirePortAvailable(t, newPort)
func TestAppConfig(t *testing.T) {
utils.SetAppConfig(t, deviceGpioSnap, deviceGpioApp, defaultServicePort)
}

utils.SnapSet(t, deviceGpioSnap, "env.service.port", newPort)
utils.SnapStart(t, deviceGpioSnap)
utils.WaitServiceOnline(t, 60, newPort)
})
func TestGlobalConfig(t *testing.T) {
// start clean
utils.SetGlobalConfig(t, deviceGpioSnap, deviceGpioApp, defaultServicePort)
}

func TestAppConfig(t *testing.T) {
t.Skip("TODO")
func TestMixedConfig(t *testing.T) {
utils.SetMixedConfig(t, deviceGpioSnap, deviceGpioApp, defaultServicePort)
}
7 changes: 5 additions & 2 deletions test/suites/device-gpio/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ import (
"time"
)

const deviceGpioSnap = "edgex-device-gpio"
const deviceGpioService = "edgex-device-gpio.device-gpio"
const (
deviceGpioSnap = "edgex-device-gpio"
deviceGpioApp = "device-gpio"
deviceGpioService = deviceGpioSnap + "." + deviceGpioApp
)

var start = time.Now()

Expand Down
14 changes: 10 additions & 4 deletions test/suites/device-modbus/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@ import (

// Deprecated
func TestEnvConfig(t *testing.T) {
t.Run("change service port", func(t *testing.T) {
utils.TestEnvChangeServicePort(t, deviceModbusSnap, defaultServicePort)
})
utils.SetEnvConfig(t, deviceModbusSnap, deviceModbusApp, defaultServicePort)
}

func TestAppConfig(t *testing.T) {
t.Skip("TODO")
utils.SetAppConfig(t, deviceModbusSnap, deviceModbusApp, defaultServicePort)
}

func TestGlobalConfig(t *testing.T) {
utils.SetGlobalConfig(t, deviceModbusSnap, deviceModbusApp, defaultServicePort)
}

func TestMixedConfig(t *testing.T) {
utils.SetMixedConfig(t, deviceModbusSnap, deviceModbusApp, defaultServicePort)
}
7 changes: 5 additions & 2 deletions test/suites/device-modbus/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ import (
"time"
)

const deviceModbusSnap = "edgex-device-modbus"
const deviceModbusService = "edgex-device-modbus.device-modbus"
const (
deviceModbusSnap = "edgex-device-modbus"
deviceModbusApp = "device-modbus"
deviceModbusService = deviceModbusSnap + "." + deviceModbusApp
)

var start = time.Now()

Expand Down
29 changes: 11 additions & 18 deletions test/suites/device-mqtt/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,21 @@ import (
"testing"
)

var FullConfigTest = true

// Deprecated
func TestEnvConfig(t *testing.T) {
// start clean
utils.SnapStop(t, deviceMqttService)

t.Run("change service port", func(t *testing.T) {
t.Cleanup(func() {
utils.SnapStop(t, deviceMqttService)
utils.SnapUnset(t, deviceMqttSnap, "env.service.port")
})

const newPort = "56789"
utils.SetEnvConfig(t, deviceMqttSnap, deviceMqttApp, defaultServicePort)
}

// make sure the port is available before using it
utils.RequirePortAvailable(t, newPort)
func TestAppConfig(t *testing.T) {
utils.SetAppConfig(t, deviceMqttSnap, deviceMqttApp, defaultServicePort)
}

utils.SnapSet(t, deviceMqttSnap, "env.service.port", newPort)
utils.SnapStart(t, deviceMqttSnap)
utils.WaitServiceOnline(t, 60, newPort)
})
func TestGlobalConfig(t *testing.T) {
utils.SetGlobalConfig(t, deviceMqttSnap, deviceMqttApp, defaultServicePort)
}

func TestAppConfig(t *testing.T) {
t.Skip("TODO")
func TestMixedConfig(t *testing.T) {
utils.SetMixedConfig(t, deviceMqttSnap, deviceMqttApp, defaultServicePort)
}
7 changes: 5 additions & 2 deletions test/suites/device-mqtt/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ import (
"time"
)

const deviceMqttSnap = "edgex-device-mqtt"
const deviceMqttService = "edgex-device-mqtt.device-mqtt"
const (
deviceMqttSnap = "edgex-device-mqtt"
deviceMqttApp = "device-mqtt"
deviceMqttService = deviceMqttSnap + "." + deviceMqttApp
)

var start = time.Now()

Expand Down
26 changes: 9 additions & 17 deletions test/suites/device-rest/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,17 @@ import (

// Deprecated
func TestEnvConfig(t *testing.T) {
utils.SetEnvConfig(t, deviceRestSnap, deviceRestApp, defaultServicePort)
}

t.Run("change service port", func(t *testing.T) {
t.Cleanup(func() {
utils.SnapStop(t, deviceRestService)
utils.SnapUnset(t, deviceRestSnap, "env.service.port")
})

const newPort = "56789"

// make sure the port is available before using it
utils.RequirePortAvailable(t, newPort)
func TestAppConfig(t *testing.T) {
utils.SetAppConfig(t, deviceRestSnap, deviceRestApp, defaultServicePort)
}

utils.SnapStop(t, deviceRestSnap)
utils.SnapSet(t, deviceRestSnap, "env.service.port", newPort)
utils.SnapStart(t, deviceRestSnap)
utils.WaitServiceOnline(t, 60, newPort)
})
func TestGlobalConfig(t *testing.T) {
utils.SetGlobalConfig(t, deviceRestSnap, deviceRestApp, defaultServicePort)
}

func TestAppConfig(t *testing.T) {
t.Skip("TODO")
func TestMixedConfig(t *testing.T) {
utils.SetMixedConfig(t, deviceRestSnap, deviceRestApp, defaultServicePort)
}
7 changes: 5 additions & 2 deletions test/suites/device-rest/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ import (
"time"
)

const deviceRestSnap = "edgex-device-rest"
const deviceRestService = "edgex-device-rest.device-rest"
const (
deviceRestSnap = "edgex-device-rest"
deviceRestApp = "device-rest"
deviceRestService = deviceRestSnap + "." + deviceRestApp
)

var start = time.Now()

Expand Down
Loading