diff --git a/tests/RobotFramework/tests/cumulocity/configuration/configuration_operation.robot b/tests/RobotFramework/tests/cumulocity/configuration/configuration_operation.robot index 6462ba670cf..3b52240ac40 100644 --- a/tests/RobotFramework/tests/cumulocity/configuration/configuration_operation.robot +++ b/tests/RobotFramework/tests/cumulocity/configuration/configuration_operation.robot @@ -111,24 +111,24 @@ Manual config_snapshot operation request Trigger config_snapshot operation from another operation Set Device Context ${PARENT_SN} Publish and Verify Local Command - ... topic=te/device/main///cmd/sub_config_snapshot/local-1111 - ... payload={"status":"init","tedgeUrl":"http://${PARENT_IP}:8000/tedge/file-transfer/${PARENT_SN}/sub_config_snapshot/local-1111","type":"tedge-configuration-plugin"} + ... topic=te/device/main///cmd/sub_config_snapshot/sub-1111 + ... payload={"status":"init","tedgeUrl":"http://${PARENT_IP}:8000/tedge/file-transfer/${PARENT_SN}/sub_config_snapshot/sub-1111","type":"tedge-configuration-plugin"} ... expected_status=successful ... c8y_fragment=c8y_UploadConfigFile - ${snapshot} Execute Command curl http://${PARENT_IP}:8000/tedge/file-transfer/${PARENT_SN}/sub_config_snapshot/local-1111 + ${snapshot} Execute Command curl http://${PARENT_IP}:8000/tedge/file-transfer/${PARENT_SN}/sub_config_snapshot/sub-1111 ${config} Get File ${CURDIR}/tedge-configuration-plugin.toml Should Be Equal ${snapshot} ${config} Trigger custom config_snapshot operation - [Teardown] Restore config_snapshot operation - Customize config_snapshot operation + [Teardown] Restore config operations Set Device Context ${PARENT_SN} + Customize config operations Publish and Verify Local Command - ... topic=te/device/main///cmd/config_snapshot/local-1111 - ... payload={"status":"init","tedgeUrl":"http://${PARENT_IP}:8000/tedge/file-transfer/${PARENT_SN}/config_snapshot/local-1111","type":"tedge-configuration-plugin"} + ... topic=te/device/main///cmd/config_snapshot/custom-1111 + ... payload={"status":"init","tedgeUrl":"http://${PARENT_IP}:8000/tedge/file-transfer/${PARENT_SN}/config_snapshot/custom-1111","type":"tedge-configuration-plugin"} ... expected_status=successful ... c8y_fragment=c8y_UploadConfigFile - ${snapshot} Execute Command curl http://${PARENT_IP}:8000/tedge/file-transfer/${PARENT_SN}/config_snapshot/local-1111 + ${snapshot} Execute Command curl http://${PARENT_IP}:8000/tedge/file-transfer/${PARENT_SN}/config_snapshot/custom-1111 ${config} Get File ${CURDIR}/tedge-configuration-plugin.toml Should Be Equal ${snapshot} ${config} @@ -158,6 +158,34 @@ Manual config_update operation request ... expected_status=failed ... c8y_fragment=c8y_DownloadConfigFile +Trigger config_update operation from another workflow + Set Device Context ${PARENT_SN} + + Execute Command curl -X PUT --data-binary 'new content for CONFIG1' "http://${PARENT_IP}:8000/tedge/file-transfer/${PARENT_SN}/sub_config_update/sub-2222" + Publish and Verify Local Command + ... topic=te/device/main///cmd/sub_config_update/sub-2222 + ... payload={"status":"init","tedgeUrl":"http://${PARENT_IP}:8000/tedge/file-transfer/${PARENT_SN}/sub_config_update/sub-2222","remoteUrl":"","type":"CONFIG1"} + ... expected_status=successful + ... c8y_fragment=c8y_DownloadConfigFile + + ${update} Execute Command cat /etc/config1.json + Should Be Equal ${update} new content for CONFIG1 + +Trigger custom config_update operation + [Teardown] Restore config operations + Set Device Context ${PARENT_SN} + Customize config operations + + Execute Command curl -X PUT --data-binary 'updated config' "http://${PARENT_IP}:8000/tedge/file-transfer/${PARENT_SN}/config_update/custom-2222" + Publish and Verify Local Command + ... topic=te/device/main///cmd/config_update/custom-2222 + ... payload={"status":"init","tedgeUrl":"http://${PARENT_IP}:8000/tedge/file-transfer/${PARENT_SN}/config_update/custom-2222","remoteUrl":"","type":"/tmp/config_update_target"} + ... expected_status=successful + ... c8y_fragment=c8y_DownloadConfigFile + + ${update} Execute Command cat /tmp/config_update_target + Should Be Equal ${update} updated config + Config update request not processed when operation is disabled for tedge-agent [Teardown] Enable config update capability of tedge-agent Set Device Context ${PARENT_SN} @@ -412,13 +440,15 @@ Update configuration plugin config via local filesystem move (same directory) ${operation}= Cumulocity.Get Configuration Config@2.0.0 Operation Should Be SUCCESSFUL ${operation} -Customize config_snapshot operation - ThinEdgeIO.Transfer To Device ${CURDIR}/custom_config_snapshot.toml /etc/tedge/operations/custom_config_snapshot.toml +Customize config operations + ThinEdgeIO.Transfer To Device ${CURDIR}/custom_config_snapshot.toml /etc/tedge/operations/ + ThinEdgeIO.Transfer To Device ${CURDIR}/custom_config_update.toml /etc/tedge/operations/ Restart Service tedge-agent ThinEdgeIO.Service Health Status Should Be Up tedge-agent -Restore config_snapshot operation +Restore config operations Execute Command rm -f /etc/tedge/operations/custom_config_snapshot.toml + Execute Command rm -f /etc/tedge/operations/custom_config_update.toml Restart Service tedge-agent ThinEdgeIO.Service Health Status Should Be Up tedge-agent @@ -490,6 +520,7 @@ Copy Configuration Files Customize Operation Workflows [Arguments] ${device} ThinEdgeIO.Transfer To Device ${CURDIR}/sub_config_snapshot.toml /etc/tedge/operations/ + ThinEdgeIO.Transfer To Device ${CURDIR}/sub_config_update.toml /etc/tedge/operations/ Restart Service tedge-agent ThinEdgeIO.Service Health Status Should Be Up tedge-agent diff --git a/tests/RobotFramework/tests/cumulocity/configuration/custom_config_update.toml b/tests/RobotFramework/tests/cumulocity/configuration/custom_config_update.toml new file mode 100644 index 00000000000..3654690e53e --- /dev/null +++ b/tests/RobotFramework/tests/cumulocity/configuration/custom_config_update.toml @@ -0,0 +1,22 @@ +# Custom config_update operation +# - use the type as the path for the target file +# - download the source url to the target +operation = "config_update" + +[init] +action = "proceed" +on_success = "scheduled" + +[scheduled] +action = "proceed" +on_success = "executing" + +[executing] +script = "curl --output ${.payload.type} ${.payload.tedgeUrl}" +on_success = "successful" + +[successful] +action = "cleanup" + +[failed] +action = "cleanup" diff --git a/tests/RobotFramework/tests/cumulocity/configuration/sub_config_update.toml b/tests/RobotFramework/tests/cumulocity/configuration/sub_config_update.toml new file mode 100644 index 00000000000..a813f10c366 --- /dev/null +++ b/tests/RobotFramework/tests/cumulocity/configuration/sub_config_update.toml @@ -0,0 +1,23 @@ +# Trigger config_update as a sub operation workflow +operation = "sub_config_update" + +[init] +action = "proceed" +on_success = "executing" + +[executing] +operation = "config_update" +input.remoteUrl = "${.payload.remoteUrl}" +input.tedgeUrl = "${.payload.tedgeUrl}" +input.type = "${.payload.type}" +on_exec = "awaiting_update" + +[awaiting_update] +action = "await-operation-completion" +on_success = "successful" + +[successful] +action = "cleanup" + +[failed] +action = "cleanup"