Skip to content

Commit 66120ce

Browse files
committed
chore(test): wait for mender-connect to exit before restarting in set_limits
The set_limits() helper kills mender-connect and immediately starts a new instance without waiting for the old process to exit. This creates a race condition: the old process may still be running (and its WebSocket still registered as "connected" in deviceconnect) when the new one starts. wait_for_connect() can then pass on the stale "connected" state from the old connection, and the subsequent file transfer request hits an inconsistent state timing out with HTTP 408. Signed-off-by: pasinskim <marcin.pasinski@northern.tech>
1 parent 1f5bdbf commit 66120ce

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

tests/tests/test_filetransfer.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,17 @@ def set_limits(docker_env, mender_device, limits, auth, devid):
107107
)
108108
finally:
109109
shutil.rmtree(tmpdir)
110-
mender_device.run("kill -TERM `pidof %s`" % connect_service_name)
110+
# Stop the respawn loop in the container entrypoint so it doesn't
111+
# restart mender-connect automatically after we kill it — otherwise
112+
# we'd end up with two daemons running.
113+
mender_device.run(
114+
"touch /stop-respawn; "
115+
"kill -TERM `pidof %s` 2>/dev/null; "
116+
"timeout 10 sh -c 'while pidof %s >/dev/null 2>&1; do sleep 0.1; done' || "
117+
"kill -9 `pidof %s` 2>/dev/null; "
118+
"rm -f /stop-respawn"
119+
% (connect_service_name, connect_service_name, connect_service_name)
120+
)
111121
docker_env._docker_compose_cmd(
112122
"exec -d mender-client %s daemon" % connect_service_name
113123
)

0 commit comments

Comments
 (0)