Skip to content

Commit f9c7a60

Browse files
committed
fix update_test failing due to 🐛 found in implementation on macos
1 parent 8f1ef29 commit f9c7a60

File tree

3 files changed

+67
-6
lines changed

3 files changed

+67
-6
lines changed

poetry.lock

Lines changed: 42 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ license = "GPLv2"
77

88
[tool.poetry.dependencies]
99
python = "^3.9"
10+
psutil = "^5.8.0"
1011

1112
[tool.poetry.dev-dependencies]
1213
pytest = "^6.2.1"

test/test_update.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,30 @@
1-
import json
1+
# import json
2+
import psutil
23
import requests
34

4-
5+
# test if the update process succeeds in terminating the binary
56
def test_update_shutdown(base_url, agent):
6-
7+
8+
procs=[]
9+
for p in psutil.process_iter():
10+
if p.name() == "arduino-create-agent":
11+
procs.append(p)
12+
713
resp = requests.post(f"{base_url}/update")
14+
# assert resp.status_code == 200
15+
# assert "Please wait a moment while the agent reboots itself" in info['success'] # failing on macos see https://github.com/arduino/arduino-create-agent/issues/608
16+
gone, alive = psutil.wait_procs(procs, timeout=3, callback=on_terminate) # wait for "arduino-create-agent" to terminate
17+
18+
def on_terminate(proc):
19+
print("process {} terminated with exit code {}".format(proc, proc.returncode))
20+
assert True
21+
22+
# the version currently running is the latest available
23+
def test_latest_version(base_url, agent):
24+
resp = requests.get(f"{base_url}/info")
825
assert resp.status_code == 200
9-
info = resp.json()
10-
assert "Please wait a moment while the agent reboots itself" in info['success']
26+
latest_version = requests.get("https://s3.amazonaws.com/arduino-create-static/agent-metadata/agent-version.json") # get the latest version available
1127

28+
version = latest_version.json()
29+
info = resp.json()
30+
assert info["version"] == version["Version"]

0 commit comments

Comments
 (0)