diff --git a/tests/RobotFramework/tests/tedge_agent/workflows/custom_operation.robot b/tests/RobotFramework/tests/tedge_agent/workflows/custom_operation.robot index 8652bed4d8e..2f1d87b39bf 100644 --- a/tests/RobotFramework/tests/tedge_agent/workflows/custom_operation.robot +++ b/tests/RobotFramework/tests/tedge_agent/workflows/custom_operation.robot @@ -193,6 +193,21 @@ Placeholder workflow created for ill-defined operations ${workflow_log} Execute Command cat /var/log/tedge/agent/workflow-issue-3079-test-1.log Should Contain ${workflow_log} item=TOML parse error +Trigger wrapped workflow without an intermediate state + # [Documentation] + Execute Command + ... cmd=echo 'tedge ALL = (ALL) NOPASSWD:SETENV: /usr/bin/tedge, /usr/bin/systemctl, /etc/tedge/sm-plugins/[a-zA-Z0-9]*, /bin/sync, /sbin/init, /sbin/shutdown, /usr/sbin/reboot, /usr/bin/on_shutdown.sh' > /etc/sudoers.d/tedge + ${pid_before} Execute Command sudo systemctl show --property MainPID tedge-agent + Execute Command + ... tedge mqtt pub --retain te/device/main///cmd/restart-tedge-agent-wrapper/robot-1 '{"status":"init"}' + Should Have MQTT Messages + ... te/device/main///cmd/restart-tedge-agent-wrapper/robot-1 + ... message_pattern=.*successful.* + ... maximum=1 + ... timeout=120 + ${pid_after} Execute Command sudo systemctl show --property MainPID tedge-agent + Should Not Be Equal ${pid_before} ${pid_after} msg=tedge-agent should have been restarted + *** Keywords *** Custom Test Setup @@ -217,6 +232,8 @@ Copy Configuration Files ThinEdgeIO.Transfer To Device ${CURDIR}/restart-tedge-agent.toml /etc/tedge/operations/ ThinEdgeIO.Transfer To Device ${CURDIR}/tedge-agent-pid.sh /etc/tedge/operations/ ThinEdgeIO.Transfer To Device ${CURDIR}/native-reboot.toml /etc/tedge/operations/ + ThinEdgeIO.Transfer To Device ${CURDIR}/restart-tedge-agent-wrapper.toml /etc/tedge/operations/ + ThinEdgeIO.Transfer To Device ${CURDIR}/restart-tedge-agent-internal.toml /etc/tedge/operations/ ThinEdgeIO.Transfer To Device ${CURDIR}/gp_command.toml /etc/tedge/operations/ ThinEdgeIO.Transfer To Device ${CURDIR}/super_command.toml /etc/tedge/operations/ ThinEdgeIO.Transfer To Device ${CURDIR}/sub_command.toml /etc/tedge/operations/ diff --git a/tests/RobotFramework/tests/tedge_agent/workflows/restart-tedge-agent-internal.toml b/tests/RobotFramework/tests/tedge_agent/workflows/restart-tedge-agent-internal.toml new file mode 100644 index 00000000000..b94aa02db48 --- /dev/null +++ b/tests/RobotFramework/tests/tedge_agent/workflows/restart-tedge-agent-internal.toml @@ -0,0 +1,26 @@ +operation = "restart-tedge-agent-internal" + +[init] +action = "proceed" +on_success = "restart" + +[restart] +background_script = "sudo systemctl restart tedge-agent" +on_exec = "restarting" + +[restarting] +action = "await-agent-restart" +# on_success = "restarted" # Result: PASS +on_success = "successful" # Result: FAIL +timeout_second = 30 +on_timeout = "failed" + +[restarted] +action = "proceed" +on_success = "successful" + +[successful] +action = "cleanup" + +[failed] +action = "cleanup" diff --git a/tests/RobotFramework/tests/tedge_agent/workflows/restart-tedge-agent-wrapper.toml b/tests/RobotFramework/tests/tedge_agent/workflows/restart-tedge-agent-wrapper.toml new file mode 100644 index 00000000000..5de8ecab442 --- /dev/null +++ b/tests/RobotFramework/tests/tedge_agent/workflows/restart-tedge-agent-wrapper.toml @@ -0,0 +1,19 @@ +operation = "restart-tedge-agent-wrapper" + +[init] +action = "proceed" +on_success = "restart" + +[restart] +operation = "restart-tedge-agent-internal" +on_exec = "restarting" + +[restarting] +action = "await-operation-completion" +on_success = "successful" + +[successful] +action = "cleanup" + +[failed] +action = "cleanup"