46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
"""Smoke-check an already running isolated Mock container, via its loopback HTTP."""
|
|||
|
|
|
||
|
|
import json
|
||
|
|
import os
|
||
|
|
import time
|
||
|
|
import urllib.request
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
|
||
|
|
def main():
|
||
|
|
assert os.getuid() == 10333 and os.getgid() == 10333
|
||
|
|
assert not Path("/photos").exists()
|
||
|
|
for _ in range(30):
|
||
|
|
try:
|
||
|
|
with urllib.request.urlopen(
|
||
|
|
"http://127.0.0.1:18787/ready", timeout=2
|
||
|
|
) as response:
|
||
|
|
assert json.load(response)["status"] == "ready"
|
||
|
|
break
|
||
|
|
except OSError:
|
||
|
|
time.sleep(1)
|
||
|
|
else:
|
||
|
|
raise SystemExit("Mock readiness failed")
|
||
|
|
with urllib.request.urlopen(
|
||
|
|
"http://127.0.0.1:18787/api/v1/version", timeout=2
|
||
|
|
) as response:
|
||
|
|
version = json.load(response)
|
||
|
|
assert version["version"] == "0.1.9"
|
||
|
|
assert Path("/data/frameflow.db").is_file()
|
||
|
|
print(
|
||
|
|
json.dumps(
|
||
|
|
{
|
||
|
|
"ready": True,
|
||
|
|
"version": version["version"],
|
||
|
|
"commit": version["commit"],
|
||
|
|
"uid": os.getuid(),
|
||
|
|
"gid": os.getgid(),
|
||
|
|
"no_photos_mount": True,
|
||
|
|
}
|
||
|
|
)
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
main()
|