run.py
 1  """Build and run the integration tests."""
 2  
 3  # ruff: noqa: S605, S607, T201
 4  
 5  import os
 6  import sys
 7  
 8  if __name__ == "__main__":
 9      print("Building and running integration tests...")
10      print("Building Spoolman...")
11      if os.system("docker build -t donkie/spoolman:test .") > 0:
12          print("Failed to build Spoolman!")
13          sys.exit(1)
14      print("Building Spoolman tester...")
15      if os.system("docker build -t donkie/spoolman-tester:latest tests_integration") > 0:
16          print("Failed to build Spoolman tester!")
17          sys.exit(1)
18  
19      # Support input arguments for running only specific tests
20      if len(sys.argv) > 1:
21          targets = sys.argv[1:]
22          # Check that all targets are valid
23          for target in targets:
24              if target not in ["postgres", "sqlite", "mariadb", "cockroachdb"]:
25                  print(f"Unknown target: {target}")
26                  sys.exit(1)
27      else:
28          print("No targets specified, running all tests...")
29          targets = [
30              "postgres",
31              "sqlite",
32              "mariadb",
33              "cockroachdb",
34          ]
35  
36      for target in targets:
37          print(f"Running integration tests against {target}...")
38          os.system(f"docker compose -f tests_integration/docker-compose-{target}.yml down -v")
39          if (
40              os.system(f"docker compose -f tests_integration/docker-compose-{target}.yml up --abort-on-container-exit")
41              > 0
42          ):
43              print(f"Integration tests against {target} failed!")
44              sys.exit(1)
45  
46      print("Integration tests passed!")