-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3328 from Ruadhri17/smartest-templates-custom-ope…
…ration-test test: missing test for custom operation execution using smartrest templates
- Loading branch information
Showing
6 changed files
with
85 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ dateparser~=1.2.0 | |
paho-mqtt~=1.6.1 | ||
python-dotenv~=1.0.0 | ||
robotframework~=7.0.0 | ||
robotframework-c8y @ git+https://github.com/thin-edge/robotframework-c8y.git@0.37.4 | ||
robotframework-c8y @ git+https://github.com/thin-edge/robotframework-c8y.git@0.39.1 | ||
robotframework-aws @ git+https://github.com/thin-edge/[email protected] | ||
robotframework-debuglibrary~=2.5.0 | ||
robotframework-jsonlibrary~=0.5 | ||
|
4 changes: 4 additions & 0 deletions
4
...tFramework/tests/cumulocity/custom_operation/custom_operation_smartrest_template/set_wifi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[exec] | ||
command = "/etc/tedge/operations/set_wifi.sh" | ||
topic = "c8y/s/dc/custom_devmgmt" | ||
on_message = "dm101" |
18 changes: 18 additions & 0 deletions
18
...ework/tests/cumulocity/custom_operation/custom_operation_smartrest_template/set_wifi.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"com_cumulocity_model_smartrest_csv_CsvSmartRestTemplate": { | ||
"requestTemplates": [], | ||
"responseTemplates": [ | ||
{ | ||
"msgId": "dm101", | ||
"condition": "set_wifi", | ||
"base": "set_wifi", | ||
"name": "set_wifi", | ||
"pattern": [ | ||
"name", | ||
"ssid", | ||
"type" | ||
] | ||
} | ||
] | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...amework/tests/cumulocity/custom_operation/custom_operation_smartrest_template/set_wifi.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
# Constants | ||
OK=0 | ||
|
||
# Input arguments | ||
MESSAGE="$1" | ||
NAME=$(echo "$MESSAGE" | cut -d, -f 3) | ||
SSID=$(echo "$MESSAGE" | cut -d, -f 4) | ||
TYPE=$(echo "$MESSAGE" | cut -d, -f 5) | ||
|
||
echo "Processing message: $MESSAGE" | ||
echo "NAME: $NAME" | ||
echo "SSID: $SSID" | ||
echo "TYPE: $TYPE" | ||
exit "$OK" |
42 changes: 42 additions & 0 deletions
42
.../cumulocity/custom_operation/custom_operation_smartrest_template/smartrest_template.robot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
*** Settings *** | ||
Resource ../../../../resources/common.resource | ||
Library Cumulocity | ||
Library ThinEdgeIO | ||
|
||
Test Setup Custom Setup | ||
Test Teardown Get Logs | ||
|
||
Test Tags theme:c8y theme:operation theme:custom theme:smartrest theme:template | ||
|
||
|
||
*** Test Cases *** | ||
smartrest template custom operation successful | ||
Create SmartREST2 Template ${CURDIR}/set_wifi.json ${DEVICE_SN} | ||
Should Have SmartREST2 Template ${DEVICE_SN} | ||
|
||
${operation}= Cumulocity.Create Operation | ||
... description=do something | ||
... fragments={"set_wifi":{"name":"Factory Wifi","ssid":"factory-onboarding-wifi","type":"WPA3-Personal"}} | ||
Operation Should Be SUCCESSFUL ${operation} | ||
|
||
${c8y_messages}= Should Have MQTT Messages | ||
... c8y/s/dc/${DEVICE_SN} | ||
... minimum=1 | ||
... maximum=1 | ||
... message_contains=dm101,${DEVICE_SN},Factory Wifi,factory-onboarding-wifi,WPA3-Personal | ||
|
||
|
||
*** Keywords *** | ||
Custom Setup | ||
${DEVICE_SN}= Setup | ||
Set Suite Variable $DEVICE_SN | ||
Device Should Exist ${DEVICE_SN} | ||
|
||
ThinEdgeIO.Transfer To Device ${CURDIR}/set_wifi /etc/tedge/operations/c8y/set_wifi | ||
Execute Command sed -i -e 's/custom_devmgmt/${DEVICE_SN}/g' /etc/tedge/operations/c8y/set_wifi | ||
|
||
ThinEdgeIO.Transfer To Device ${CURDIR}/set_wifi.sh /etc/tedge/operations/set_wifi.sh | ||
Execute Command chmod a+x /etc/tedge/operations/set_wifi.sh | ||
|
||
Execute Command tedge config set c8y.smartrest.templates ${DEVICE_SN} | ||
Execute Command tedge reconnect c8y |