-
Notifications
You must be signed in to change notification settings - Fork 15
/
test.py
executable file
·47 lines (35 loc) · 1.34 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python3
import glob
import subprocess
import os
import shutil
def sh(cmd: str):
subprocess.run(cmd, check=True, shell=True)
if os.path.exists("temp-persisted-data"):
shutil.rmtree("temp-persisted-data")
sh("docker compose build")
if not os.environ.get("SKIP_TEST_SETUP"):
sh("docker compose run --rm test setup")
print("Ensure resources were created...", flush=True)
sh("docker compose run --rm test verify")
sh("docker compose stop")
print("Ensure changes were persisted and can be loaded...", flush=True)
sh("docker compose run --rm test verify")
sh("docker compose stop")
shutil.rmtree("temp-persisted-data")
shutil.copytree(
"test-persisted-data/" + os.environ.get("TEST_PERSISTED_DATA_DIR", "v2"),
"temp-persisted-data",
)
if os.name != "nt":
# Windows doesn't support colons in filenames, so they're checked-in to git with a replacement character (\uf03a).
# So when running tests on unix-like systems, we need to change that character back to a colon.
for dir in glob.glob("temp-persisted-data/**/*\uf03a*", recursive=True):
shutil.move(dir, dir.replace("\uf03a", ":"))
print(
"Ensure changes from previous runs can be loaded (backward-compatibility)...",
flush=True,
)
sh("docker compose run --rm test verify")
sh("docker compose down")
print("Tests passed!")