Skip to content

Commit

Permalink
fixup! test: add coverage for off-device mqtt broker
Browse files Browse the repository at this point in the history
Signed-off-by: Reuben Miller <reuben.d.miller@gmail.com>
  • Loading branch information
reubenmiller committed Mar 31, 2023
1 parent ebb250e commit 2f35c97
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
files = [
{ path = '/etc/tedge/tedge.toml', user = 'tedge', group = 'tedge', mode = 0o444 },
{ path = '/etc/tedge/system.toml', type = 'system.toml', user = 'tedge', group = 'tedge', mode = 0o444 },
{ path = '/etc/config1.json', type = 'CONFIG1', user = 'tedge', group = 'tedge', mode = 0o444 },
{ path = '/etc/config2.json', type = 'Config@2.0.0', user = 'tedge', group = 'tedge', mode = 0o444 },
]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
files = [
{ path = '/etc/tedge/tedge.toml', user = 'tedge', group = 'tedge', mode = 0o444 },
{ path = '/etc/tedge/system.toml', type = 'system.toml', user = 'tedge', group = 'tedge', mode = 0o444 },
{ path = '/etc/config1.json', type = 'CONFIG1', user = 'tedge', group = 'tedge', mode = 0o444 },
{ path = '/etc/config1.json', type = 'CONFIG1', user = 'tedge', group = 'tedge', mode = 0o640 },
]
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,30 @@ Suite Setup Custom Setup
Test Teardown Get Logs
Test Setup Test Setup

*** Variables ***
${DEFAULT_CONFIG} c8y-configuration-plugin

*** Test Cases ***

Set configuration
Set configuration when file exists
${config_url}= Cumulocity.Create Inventory Binary config1 CONFIG1 file=${CURDIR}/config1-version2.json
${operation}= Cumulocity.Set Configuration CONFIG1 url=${config_url}
${operation}= Operation Should Be SUCCESSFUL ${operation}
${target_contents}= Execute Command cat /etc/config1.json
Should Be Equal ${target_contents} {"name":"configuration1","version":2}
${FILE_MODE_OWNERSHIP}= Execute Command stat -c '%a %U:%G' /etc/config1.json strip=${True}
# Note: File permission will not change if the file already exists
Should Be Equal ${FILE_MODE_OWNERSHIP} 644 root:root

Set configuration when file does not exist
Execute Command rm -f /etc/config1.json
${config_url}= Cumulocity.Create Inventory Binary config1 CONFIG1 file=${CURDIR}/config1-version2.json
${operation}= Cumulocity.Set Configuration CONFIG1 url=${config_url}
${operation}= Operation Should Be SUCCESSFUL ${operation}
${target_contents}= Execute Command cat /etc/config1.json
Should Be Equal ${target_contents} {"name":"configuration1","version":2}
${FILE_MODE_OWNERSHIP}= Execute Command stat -c '%a %U:%G' /etc/config1.json strip=${True}
Should Be Equal ${FILE_MODE_OWNERSHIP} 640 tedge:tedge

Set configuration with broken url
${operation}= Cumulocity.Set Configuration CONFIG1 url=invalid://hellö.zip
Expand All @@ -42,17 +58,40 @@ Get non existent configuration type
${operation}= Cumulocity.Get Configuration unknown_config
Operation Should Be FAILED ${operation} failure_reason=.*requested config_type unknown_config is not defined in the plugin configuration file.*

Update configuration plugin config via cloud
Cumulocity.Should Support Configurations ${DEFAULT_CONFIG} /etc/tedge/tedge.toml system.toml CONFIG1
${config_url}= Cumulocity.Create Inventory Binary c8y-configuration-plugin ${DEFAULT_CONFIG} file=${CURDIR}/c8y-configuration-plugin-updated.toml
${operation}= Cumulocity.Set Configuration ${DEFAULT_CONFIG} url=${config_url}
${operation}= Operation Should Be SUCCESSFUL ${operation}
Cumulocity.Should Support Configurations ${DEFAULT_CONFIG} /etc/tedge/tedge.toml system.toml CONFIG1 Config@2.0.0

Modify configuration plugin config via local filesystem action
[Documentation] Editing the c8y-configuration-plugin.toml locally requires the
... c8y-configuration-plugin service to be restarted
Cumulocity.Should Support Configurations ${DEFAULT_CONFIG} /etc/tedge/tedge.toml system.toml CONFIG1
Execute Command sed -i 's/CONFIG1/CONFIG3/g' /etc/tedge/c8y/c8y-configuration-plugin.toml
ThinEdgeIO.Restart Service c8y-configuration-plugin
Cumulocity.Should Support Configurations ${DEFAULT_CONFIG} /etc/tedge/tedge.toml system.toml CONFIG3

Update configuration plugin config via local filesystem action
[Documentation] Repalacing the c8y-configuration-plugin.toml locally requires the
... c8y-configuration-plugin service to be restarted
Cumulocity.Should Support Configurations ${DEFAULT_CONFIG} /etc/tedge/tedge.toml system.toml CONFIG1
Transfer To Device ${CURDIR}/c8y-configuration-plugin-updated.toml /etc/tedge/c8y/
Execute Command mv /etc/tedge/c8y/c8y-configuration-plugin-updated.toml /etc/tedge/c8y/c8y-configuration-plugin.toml
ThinEdgeIO.Restart Service c8y-configuration-plugin
Cumulocity.Should Support Configurations ${DEFAULT_CONFIG} /etc/tedge/tedge.toml system.toml CONFIG1 Config@2.0.0

*** Keywords ***

Test Setup
ThinEdgeIO.Transfer To Device ${CURDIR}/c8y-configuration-plugin.toml /etc/tedge/c8y/
ThinEdgeIO.Transfer To Device ${CURDIR}/config1.json /etc/
Execute Command chown root:root /etc/tedge/c8y/c8y-configuration-plugin.toml /etc/config1.json
ThinEdgeIO.Restart Service c8y-configuration-plugin
ThinEdgeIO.Service Health Status Should Be Up c8y-configuration-plugin

Custom Setup
${DEVICE_SN}= Setup
Set Suite Variable $DEVICE_SN
Device Should Exist ${DEVICE_SN}
ThinEdgeIO.Transfer To Device ${CURDIR}/c8y-configuration-plugin.toml /etc/tedge/c8y/
ThinEdgeIO.Transfer To Device ${CURDIR}/config1.json /etc/
ThinEdgeIO.Restart Service c8y-configuration-plugin
ThinEdgeIO.Service Health Status Should Be Up c8y-configuration-plugin

0 comments on commit 2f35c97

Please sign in to comment.