import signal import sys from utils import * from docker import rebuild_images_if_needed from docker_compose import Compose cluster = Compose() def abort_handler(s, _): warn(f'Received signal: {s}') warn(f'Gracefully stopping...') cluster.down() def run_tests(): force_rebuild = '--rebuild' in sys.argv preserve_containers = '--preserve' in sys.argv for s in (signal.SIGTERM, signal.SIGINT, signal.SIGHUP): signal.signal(s, abort_handler) rebuild_images_if_needed(force_rebuild) try: cluster.up() cluster.is_alive() cluster.run('cargo test --test integration') except Exception as e: err(e) sys.exit(1) finally: if not preserve_containers: cluster.down() if __name__ == '__main__': run_tests()