-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Reuben Miller <reuben.d.miller@gmail.com>
- Loading branch information
1 parent
f883310
commit 9f634db
Showing
4 changed files
with
106 additions
and
88 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
70 changes: 0 additions & 70 deletions
70
tests/RobotFramework/tests/cumulocity/smartrest_one/register-device.sh
This file was deleted.
Oops, something went wrong.
85 changes: 69 additions & 16 deletions
85
tests/RobotFramework/tests/cumulocity/smartrest_one/smartrest_one.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 |
---|---|---|
@@ -1,25 +1,78 @@ | ||
*** Settings *** | ||
Resource ../../../../resources/common.resource | ||
Library Cumulocity | ||
Library ThinEdgeIO | ||
Resource ../../../../resources/common.resource | ||
Library Cumulocity | ||
Library ThinEdgeIO | ||
|
||
Test Teardown Custom Teardown | ||
|
||
Test Tags theme:c8y theme:operation | ||
|
||
|
||
*** Variables *** | ||
${SMART_REST_ONE_TEMPLATES}= | ||
... SEPARATOR=\n | ||
... 10,339,GET,/identity/externalIds/c8y_Serial/%%,,application/vnd.com.nsn.cumulocity.externalId+json,%%,STRING, | ||
... 10,311,GET,/alarm/alarms?source\=%%&status\=%%&pageSize\=100,,,%%,UNSIGNED STRING, | ||
... 11,800,$.managedObject,,$.id | ||
... 11,808,$.alarms,,$.id,$.type | ||
|
||
Test Tags theme:c8y theme:operation | ||
Test Setup Custom Setup | ||
Test Teardown Get Logs | ||
|
||
*** Test Cases *** | ||
Supports SmartREST 1.0 Templates | ||
[Template] Register and Use SmartREST 1.0. Templates | ||
use_builtin_bridge=true | ||
use_builtin_bridge=false | ||
|
||
Register SmartREST 1 templates | ||
${TEMPLATE_XID}= Set Variable templateXIDexample01 | ||
# Execute Command cmd=curl -XPOST -H "X-Id: templateXIDexample01" -d "10,107,GET,/inventory/managedObjects/%%/childDevices?pageSize=100,,,%%,," http://127.0.0.1:8001/c8y/s | ||
Execute Command cmd=tedge mqtt pub c8y/s/ul "15,${TEMPLATE_XID}\n10,107,GET,/inventory/managedObjects/%%/childDevices?pageSize=100,,,%%,,\n" | ||
Log debug | ||
# 10,107,GET,/inventory/managedObjects/%%/childDevices?pageSize=100,,,%%,,\n | ||
# Should Have MQTT Messages c8y/s/us message_pattern=114,c8y_DownloadConfigFile,c8y_LogfileRequest,c8y_RemoteAccessConnect,c8y_Restart,c8y_SoftwareUpdate,c8y_UploadConfigFile minimum=1 maximum=1 | ||
|
||
|
||
*** Keywords *** | ||
Register and Use SmartREST 1.0. Templates | ||
[Arguments] ${use_builtin_bridge} | ||
Custom Setup use_builtin_bridge=${use_builtin_bridge} | ||
|
||
${TEMPLATE_XID}= Get Random Name prefix=TST_Template | ||
Set Test Variable $TEMPLATE_XID | ||
Execute Command tedge config set c8y.smartrest1.templates "${TEMPLATE_XID}" | ||
Execute Command tedge connect c8y timeout=10 | ||
${mo}= Device Should Exist ${DEVICE_SN} | ||
|
||
# register templates | ||
Execute Command | ||
... curl --max-time 15 -sf -XPOST http://127.0.0.1:8001/c8y/s -H "Content-Type: plain/text" -H "X-Id: ${TEMPLATE_XID}" --data "${SMART_REST_ONE_TEMPLATES}" | ||
|
||
# Use templates | ||
# Get managed object id | ||
Execute Command cmd=tedge mqtt pub c8y/s/ul/${TEMPLATE_XID} '339,${DEVICE_SN}' | ||
Should Have MQTT Messages c8y/s/dl/${TEMPLATE_XID} message_pattern=^800,\\d+,${mo["id"]} timeout=10 | ||
|
||
Execute Command cmd=tedge mqtt pub te/device/main///a/test '{"text":"test alarm","severity":"major"}' -r | ||
Device Should Have Alarm/s type=test expected_text=test alarm | ||
|
||
# Get alarms | ||
Execute Command cmd=tedge mqtt pub c8y/s/ul/${TEMPLATE_XID} '311,${mo["id"]},ACTIVE' | ||
Should Have MQTT Messages c8y/s/dl/${TEMPLATE_XID} message_pattern=^808,\\d+,\\d+,test timeout=10 | ||
|
||
# Operations | ||
${OPERATION}= Get Configuration tedge-configuration-plugin | ||
Operation Should Be SUCCESSFUL ${OPERATION} | ||
|
||
Register Device | ||
[Arguments] ${SERIAL} | ||
${CREDENTIALS}= Cumulocity.Bulk Register Device With Basic Auth external_id=${SERIAL} | ||
|
||
Execute Command | ||
... cmd=printf '[c8y]\nusername = "%s"\npassword = "%s"\n' "${CREDENTIALS.username}" "${CREDENTIALS.password}" > /etc/tedge/credentials | ||
|
||
Custom Setup | ||
${DEVICE_SN}= Setup | ||
[Arguments] ${use_builtin_bridge} | ||
${DEVICE_SN}= Setup skip_bootstrap=${True} | ||
Execute Command test -f ./bootstrap.sh && ./bootstrap.sh --no-connect || true | ||
Execute Command tedge config set mqtt.bridge.built_in ${use_builtin_bridge} | ||
Execute Command tedge config set c8y.use_basic_auth true | ||
|
||
Set Suite Variable $DEVICE_SN | ||
Device Should Exist ${DEVICE_SN} | ||
|
||
Register Device ${DEVICE_SN} | ||
|
||
Custom Teardown | ||
Get Logs | ||
IF $TEMPLATE_XID Delete SmartREST 1.0 Template ${TEMPLATE_XID} |