Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: refactor and consolidate single process system tests #69

Merged
merged 3 commits into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions images/tedge/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
54 changes: 0 additions & 54 deletions tests/tedge/children/operations.robot

This file was deleted.

32 changes: 0 additions & 32 deletions tests/tedge/main/operations.robot

This file was deleted.

129 changes: 129 additions & 0 deletions tests/tedge/operations.robot
Original file line number Diff line number Diff line change
@@ -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}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*** Settings ***
Resource ../../resources/common.robot
Resource ../resources/common.robot
Library Cumulocity
Library DeviceLibrary

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*** Settings ***
Resource ../../resources/common.robot
Resource ../resources/common.robot
Library Cumulocity
Library DeviceLibrary

Expand All @@ -8,16 +8,14 @@ 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
Cumulocity.Should Have Services name=tedge-agent service_type=service status=up
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}