Skip to content

Commit 4e0f86e

Browse files
committed
add test to reproduce the await-agent-restart bug
Signed-off-by: reubenmiller <[email protected]>
1 parent 5cfe216 commit 4e0f86e

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

tests/RobotFramework/tests/tedge_agent/workflows/custom_operation.robot

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,21 @@ Placeholder workflow created for ill-defined operations
193193
${workflow_log} Execute Command cat /var/log/tedge/agent/workflow-issue-3079-test-1.log
194194
Should Contain ${workflow_log} item=TOML parse error
195195

196+
Trigger wrapped workflow without an intermediate state
197+
# [Documentation]
198+
Execute Command
199+
... 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
200+
${pid_before} Execute Command sudo systemctl show --property MainPID tedge-agent
201+
Execute Command
202+
... tedge mqtt pub --retain te/device/main///cmd/restart-tedge-agent-wrapper/robot-1 '{"status":"init"}'
203+
Should Have MQTT Messages
204+
... te/device/main///cmd/restart-tedge-agent-wrapper/robot-1
205+
... message_pattern=.*successful.*
206+
... maximum=1
207+
... timeout=120
208+
${pid_after} Execute Command sudo systemctl show --property MainPID tedge-agent
209+
Should Not Be Equal ${pid_before} ${pid_after} msg=tedge-agent should have been restarted
210+
196211

197212
*** Keywords ***
198213
Custom Test Setup
@@ -217,6 +232,8 @@ Copy Configuration Files
217232
ThinEdgeIO.Transfer To Device ${CURDIR}/restart-tedge-agent.toml /etc/tedge/operations/
218233
ThinEdgeIO.Transfer To Device ${CURDIR}/tedge-agent-pid.sh /etc/tedge/operations/
219234
ThinEdgeIO.Transfer To Device ${CURDIR}/native-reboot.toml /etc/tedge/operations/
235+
ThinEdgeIO.Transfer To Device ${CURDIR}/restart-tedge-agent-wrapper.toml /etc/tedge/operations/
236+
ThinEdgeIO.Transfer To Device ${CURDIR}/restart-tedge-agent-internal.toml /etc/tedge/operations/
220237
ThinEdgeIO.Transfer To Device ${CURDIR}/gp_command.toml /etc/tedge/operations/
221238
ThinEdgeIO.Transfer To Device ${CURDIR}/super_command.toml /etc/tedge/operations/
222239
ThinEdgeIO.Transfer To Device ${CURDIR}/sub_command.toml /etc/tedge/operations/
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
operation = "restart-tedge-agent-internal"
2+
3+
[init]
4+
action = "proceed"
5+
on_success = "restart"
6+
7+
[restart]
8+
background_script = "sudo systemctl restart tedge-agent"
9+
on_exec = "restarting"
10+
11+
[restarting]
12+
action = "await-agent-restart"
13+
# on_success = "restarted" # Result: PASS
14+
on_success = "successful" # Result: FAIL
15+
timeout_second = 30
16+
on_timeout = "failed"
17+
18+
[restarted]
19+
action = "proceed"
20+
on_success = "successful"
21+
22+
[successful]
23+
action = "cleanup"
24+
25+
[failed]
26+
action = "cleanup"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
operation = "restart-tedge-agent-wrapper"
2+
3+
[init]
4+
action = "proceed"
5+
on_success = "restart"
6+
7+
[restart]
8+
operation = "restart-tedge-agent-internal"
9+
on_exec = "restarting"
10+
11+
[restarting]
12+
action = "await-operation-completion"
13+
on_success = "successful"
14+
15+
[successful]
16+
action = "cleanup"
17+
18+
[failed]
19+
action = "cleanup"

0 commit comments

Comments
 (0)