diff --git a/images/tedge/docker-compose.yaml b/images/tedge/docker-compose.yaml index 9fdf03d..4ed94b5 100644 --- a/images/tedge/docker-compose.yaml +++ b/images/tedge/docker-compose.yaml @@ -11,6 +11,9 @@ x-device-defaults: &defaults - /tmp depends_on: - mqtt-broker + # Only required if you want to install apk packages at runtime via sm-plugin + # If this is not required then you can disable this + user: root services: bootstrap: diff --git a/tests/tedge/children/operations.robot b/tests/tedge/children/operations.robot deleted file mode 100644 index 077b91e..0000000 --- a/tests/tedge/children/operations.robot +++ /dev/null @@ -1,54 +0,0 @@ -*** Settings *** -Resource ../../resources/common.robot -Library Cumulocity -Library DeviceLibrary - -Suite Setup Set Child Device1 - -*** Test Cases *** - -It Should Show Supported Log File Types - Cumulocity.Should Have Services name=tedge-agent status=up - Cumulocity.Should Support Log File Types software-management shell - -Get Log File - ${operation}= Cumulocity.Get Log File type=software-management - Operation Should Be SUCCESSFUL ${operation} - -Set Configuration - [Teardown] Revert Configuration - ${binary_url}= Cumulocity.Create Inventory Binary tedge-configuration-plugin-2.toml tedge-configuration-plugin file=${CURDIR}/tedge-configuration-plugin-2.toml - ${operation}= Cumulocity.Set Configuration typename=tedge-configuration-plugin url=${binary_url} - Operation Should Be SUCCESSFUL ${operation} - Cumulocity.Should Support Configurations tedge-configuration-plugin tedge.toml system.toml tedge-log-plugin.toml - -Get Configuration - ${operation}= Cumulocity.Get Configuration typename=tedge-configuration-plugin - Operation Should Be SUCCESSFUL ${operation} - -Restart Device - ${operation}= Cumulocity.Restart Device - Operation Should Be SUCCESSFUL ${operation} - -It Should List the Installed Software - Device Should Have Installed Software ca-certificates tedge-apk-plugin - # Device Should Have Installed Software tedge tedge-agent - -Install software (apk package) - Skip msg=TODO - ${operation}= Install Software jq,latest::apk - Operation Should Be SUCCESSFUL ${operation} - Device Should Have Installed Software jq - -Uninstall software (apk package) - Skip msg=TODO - ${operation}= Uninstall Software jq,latest::apk - Operation Should Be SUCCESSFUL ${operation} - Device Should Not Have Installed Software jq - -*** Keywords *** - -Revert Configuration - ${binary_url}= Cumulocity.Create Inventory Binary tedge-configuration-plugin-1.toml tedge-configuration-plugin file=${CURDIR}/tedge-configuration-plugin-1.toml - ${operation}= Cumulocity.Set Configuration typename=tedge-configuration-plugin url=${binary_url} - Operation Should Be SUCCESSFUL ${operation} diff --git a/tests/tedge/children/tedge-configuration-plugin-1.toml b/tests/tedge/data/tedge-configuration-plugin-1.toml similarity index 100% rename from tests/tedge/children/tedge-configuration-plugin-1.toml rename to tests/tedge/data/tedge-configuration-plugin-1.toml diff --git a/tests/tedge/children/tedge-configuration-plugin-2.toml b/tests/tedge/data/tedge-configuration-plugin-2.toml similarity index 100% rename from tests/tedge/children/tedge-configuration-plugin-2.toml rename to tests/tedge/data/tedge-configuration-plugin-2.toml diff --git a/tests/tedge/main/operations.robot b/tests/tedge/main/operations.robot deleted file mode 100644 index cc5e7ac..0000000 --- a/tests/tedge/main/operations.robot +++ /dev/null @@ -1,32 +0,0 @@ -*** Settings *** -Resource ../../resources/common.robot -Library Cumulocity -Library DeviceLibrary - -Suite Setup Set Main Device - -*** Test Cases *** - -Restart device - ${date_from}= Get Test Start Time - Sleep 1s - ${operation}= Cumulocity.Restart Device - # Cumulocity.Device Should Have Event/s expected_text=.*Warning: device is about to reboot.* minimum=1 maximum=1 type=device_reboot after=${date_from} - Operation Should Be SUCCESSFUL ${operation} timeout=120 - -Execute shell command - ${operation}= Cumulocity.Execute Shell Command ls -l /etc/tedge - ${operation}= Operation Should Be SUCCESSFUL ${operation} - Should Not Be Empty ${operation["c8y_Command"]["result"]} - -# Get Logfile Request -# [Template] Get Logfile Request -# software-management - -*** Keywords *** - -Get Logfile Request - [Arguments] ${name} - ${operation}= Cumulocity.Create Operation description=Get Log File fragments={"c8y_LogfileRequest": {"dateFrom": "2023-05-08T20:46:56+0200","dateTo": "2023-05-09T20:46:56+0200","logFile": "${name}","maximumLines": 1000,"searchText": ""}} - ${operation}= Operation Should Be SUCCESSFUL ${operation} - Should Not Be Empty ${operation["c8y_LogfileRequest"]["file"]} diff --git a/tests/tedge/operations.robot b/tests/tedge/operations.robot new file mode 100644 index 0000000..a4eb87a --- /dev/null +++ b/tests/tedge/operations.robot @@ -0,0 +1,129 @@ +*** Settings *** +Resource ../resources/common.robot +Library Cumulocity +Library DeviceLibrary + + +*** Test Cases *** + +It Should Show Supported Log File Types + [Template] Check Supported Log File Types + ${DEVICE_ID} + ${CHILD_DEVICE_1} + +Get Log File + [Template] Get Log File + ${DEVICE_ID} + ${CHILD_DEVICE_1} + +Set Configuration + [Template] Set Configuration + ${DEVICE_ID} + ${CHILD_DEVICE_1} + +Get Configuration + [Template] Get Configuration + ${DEVICE_ID} + ${CHILD_DEVICE_1} + +Restart Device + [Template] Restart Device + ${DEVICE_ID} + ${CHILD_DEVICE_1} + +It Should List the Installed Software + [Template] Check Software List + ${DEVICE_ID} + ${CHILD_DEVICE_1} + +Install software (apk package) + [Template] Install software + ${DEVICE_ID} + ${CHILD_DEVICE_1} + +Uninstall software (apk package) + [Template] Uninstall software + ${DEVICE_ID} + ${CHILD_DEVICE_1} + +Execute shell command + [Template] Execute shell command + ${DEVICE_ID} + +Get Logfile Request + [Template] Get Logfile Request + ${DEVICE_ID} software-management + ${CHILD_DEVICE_1} software-management + +*** Keywords *** + +Check Supported Log File Types + [Arguments] ${device} + Cumulocity.Set Device ${device} + Cumulocity.Should Have Services name=tedge-agent status=up + Cumulocity.Should Support Log File Types software-management shell + +Get Log File + [Arguments] ${device} + Cumulocity.Set Device ${device} + ${operation}= Cumulocity.Get Log File type=software-management + Operation Should Be SUCCESSFUL ${operation} + +Set Configuration + [Arguments] ${device} + Cumulocity.Set Device ${device} + [Teardown] Revert Configuration + ${binary_url}= Cumulocity.Create Inventory Binary tedge-configuration-plugin-2.toml tedge-configuration-plugin file=${CURDIR}/data/tedge-configuration-plugin-2.toml + ${operation}= Cumulocity.Set Configuration typename=tedge-configuration-plugin url=${binary_url} + Operation Should Be SUCCESSFUL ${operation} + Cumulocity.Should Support Configurations tedge-configuration-plugin tedge.toml system.toml tedge-log-plugin.toml + +Get Configuration + [Arguments] ${device} + Cumulocity.Set Device ${device} + ${operation}= Cumulocity.Get Configuration typename=tedge-configuration-plugin + Operation Should Be SUCCESSFUL ${operation} + +Restart Device + [Arguments] ${device} + Cumulocity.Set Device ${device} + ${operation}= Cumulocity.Restart Device + Operation Should Be SUCCESSFUL ${operation} + +Check Software List + [Arguments] ${device} + Cumulocity.Set Device ${device} + Device Should Have Installed Software ca-certificates tedge-apk-plugin + +Install software + [Arguments] ${device} + Cumulocity.Set Device ${device} + ${operation}= Cumulocity.Install Software jq,latest::apk + Operation Should Be SUCCESSFUL ${operation} + Device Should Have Installed Software jq + +Uninstall software + [Arguments] ${device} + Cumulocity.Set Device ${device} + ${operation}= Cumulocity.Uninstall Software jq,latest::apk + Operation Should Be SUCCESSFUL ${operation} + Device Should Not Have Installed Software jq + +Execute shell command + [Arguments] ${device} + Cumulocity.Set Device ${device} + ${operation}= Cumulocity.Execute Shell Command ls -l /etc/tedge + ${operation}= Operation Should Be SUCCESSFUL ${operation} + Should Not Be Empty ${operation["c8y_Command"]["result"]} + +Get Logfile Request + [Arguments] ${device} ${name} + Cumulocity.Set Device ${device} + ${operation}= Cumulocity.Create Operation description=Get Log File fragments={"c8y_LogfileRequest": {"dateFrom": "2023-05-08T20:46:56+0200","dateTo": "2023-05-09T20:46:56+0200","logFile": "${name}","maximumLines": 1000,"searchText": ""}} + ${operation}= Operation Should Be SUCCESSFUL ${operation} + Should Not Be Empty ${operation["c8y_LogfileRequest"]["file"]} + +Revert Configuration + ${binary_url}= Cumulocity.Create Inventory Binary tedge-configuration-plugin-1.toml tedge-configuration-plugin file=${CURDIR}/data/tedge-configuration-plugin-1.toml + ${operation}= Cumulocity.Set Configuration typename=tedge-configuration-plugin url=${binary_url} + Operation Should Be SUCCESSFUL ${operation} diff --git a/tests/tedge/children/telemetry.robot b/tests/tedge/telemetry-child.robot similarity index 91% rename from tests/tedge/children/telemetry.robot rename to tests/tedge/telemetry-child.robot index 5e7e7e7..95da1fd 100644 --- a/tests/tedge/children/telemetry.robot +++ b/tests/tedge/telemetry-child.robot @@ -1,5 +1,5 @@ *** Settings *** -Resource ../../resources/common.robot +Resource ../resources/common.robot Library Cumulocity Library DeviceLibrary diff --git a/tests/tedge/main/telemetry.robot b/tests/tedge/telemetry-main.robot similarity index 68% rename from tests/tedge/main/telemetry.robot rename to tests/tedge/telemetry-main.robot index 03b8a9f..e3055df 100644 --- a/tests/tedge/main/telemetry.robot +++ b/tests/tedge/telemetry-main.robot @@ -1,5 +1,5 @@ *** Settings *** -Resource ../../resources/common.robot +Resource ../resources/common.robot Library Cumulocity Library DeviceLibrary @@ -8,9 +8,7 @@ Suite Setup Set Main Device *** Test Cases *** Child devices should be attached to the main device - Skip Demo does not contain child devices Cumulocity.Should Be A Child Device Of Device ${CHILD_DEVICE_1} - Cumulocity.Should Be A Child Device Of Device ${CHILD_DEVICE_2} Service status Cumulocity.Should Have Services name=tedge-mapper-c8y service_type=service status=up timeout=90 @@ -18,6 +16,6 @@ Service status Cumulocity.Should Have Services name=mosquitto-c8y-bridge service_type=service status=up Sends measurements - Skip No automatic publishing publishing ${date_from}= Get Test Start Time - Cumulocity.Device Should Have Measurements minimum=1 after=${date_from} timeout=120 + Cumulocity.Execute Shell Command tedge mqtt pub te/device/main///m/environment '{"temp":1.234}' + Cumulocity.Device Should Have Measurements minimum=1 maximum=1 type=environment after=${date_from}