From 552fa9662134778de62360dcf58a465d8a1e2e79 Mon Sep 17 00:00:00 2001 From: gligorisaev Date: Thu, 24 Oct 2024 13:08:55 +0200 Subject: [PATCH 1/2] Add system test for the SmartREST templates Signed-off-by: gligorisaev --- .../smartrest/smartrest_templates.robot | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 tests/RobotFramework/tests/cumulocity/smartrest/smartrest_templates.robot diff --git a/tests/RobotFramework/tests/cumulocity/smartrest/smartrest_templates.robot b/tests/RobotFramework/tests/cumulocity/smartrest/smartrest_templates.robot new file mode 100644 index 00000000000..0914132f234 --- /dev/null +++ b/tests/RobotFramework/tests/cumulocity/smartrest/smartrest_templates.robot @@ -0,0 +1,69 @@ +*** Settings *** +Resource ../../../resources/common.resource +Library Cumulocity +Library ThinEdgeIO + +Suite Setup Custom Setup +Suite Teardown Get Logs + + +*** Test Cases *** + +Add New SmartREST Template + [Documentation] Test to add a new SmartREST template + + # Check if SmartREST template setting exists + Verify Non-Existing SmartREST Templates + + # Add Template and check if it was added + Execute Command sudo tedge config set c8y.smartrest.templates template-1 + Reconnect to Cumulocity + Check SmartREST Templates present template-1 + + # Add Template and check if existing template + added template co-exist + Execute Command sudo tedge config add c8y.smartrest.templates template-2 + Reconnect to Cumulocity + Check SmartREST Templates present template-1 template-2 + + # Add Template using set command and check if setting was overwritten + Execute Command sudo tedge config set c8y.smartrest.templates template-2,template-3 + Reconnect to Cumulocity + Check SmartREST Templates present template-2 template-3 + Check SmartREST Templates not present template-1 + +Remove SmartREST Template + [Documentation] Test to remove a SmartREST template + Execute Command sudo tedge config remove c8y.smartrest.templates template-2 + Reconnect to Cumulocity + Check SmartREST Templates present template-3 + Check SmartREST Templates not present template-2 + + # Remove all SmartREST templates using unset + Execute Command sudo tedge config unset c8y.smartrest.templates + Reconnect to Cumulocity + Verify Non-Existing SmartREST Templates + + +*** Keywords *** + +Custom Setup + ${DEVICE_SN}= Setup + Set Suite Variable $DEVICE_SN + +Verify Non-Existing SmartREST Templates + ${output}= Execute Command tedge config get c8y.smartrest.templates + Should Match Regexp ${output} ^\s*(\\[\\]|\bnone\b|null)\s*$ + +Reconnect to Cumulocity + Execute Command sudo tedge reconnect c8y + +Check SmartREST Templates + [Arguments] ${state} @{templates} + ${output}= Execute Command tedge config get c8y.smartrest.templates + FOR ${template} IN @{templates} + IF '${state}' == 'present' + Should Contain ${output} ${template} + ELSE IF '${state}' == 'not present' + Should Not Contain ${output} ${template} + END + END From c19d92659cad1a34dbb240d80143912d914277f9 Mon Sep 17 00:00:00 2001 From: gligorisaev Date: Fri, 25 Oct 2024 07:24:28 +0200 Subject: [PATCH 2/2] fixup! Removed Reconnect to c8y, line 20 Signed-off-by: gligorisaev --- .../tests/cumulocity/smartrest/smartrest_templates.robot | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/RobotFramework/tests/cumulocity/smartrest/smartrest_templates.robot b/tests/RobotFramework/tests/cumulocity/smartrest/smartrest_templates.robot index 0914132f234..53c4b780615 100644 --- a/tests/RobotFramework/tests/cumulocity/smartrest/smartrest_templates.robot +++ b/tests/RobotFramework/tests/cumulocity/smartrest/smartrest_templates.robot @@ -17,7 +17,6 @@ Add New SmartREST Template # Add Template and check if it was added Execute Command sudo tedge config set c8y.smartrest.templates template-1 - Reconnect to Cumulocity Check SmartREST Templates present template-1 # Add Template and check if existing template + added template co-exist