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

Add system test for the SmartREST templates #3202

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -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
didier-wenzek marked this conversation as resolved.
Show resolved Hide resolved
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*$
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tedge config will never returns none or null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thoughts behind this were instead of assuming the output will be [], to ensure the keyword can handle different potential outputs for no templates, making the test more robust, not for now but also in the future. I can change it to the state that I had before Should Contain ${output} []

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c8y.smartrest.templates is a list of templates, hence none and null values are to be rejected as errors.


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
Loading