Skip to content

Commit

Permalink
smoketest: use compose file for restart
Browse files Browse the repository at this point in the history
  • Loading branch information
Shubham8287 committed Jan 20, 2025
1 parent 7c39d87 commit 4250ef2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions smoketests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
# and a dotnet installation is detected
HAVE_DOTNET = False

# default value can be overriden by `--compose-file` flag
COMPOSE_FILE = "./docker-compose.yml"

# we need to late-bind the output stream to allow unittests to capture stdout/stderr.
class CapturableHandler(logging.StreamHandler):

Expand Down
3 changes: 2 additions & 1 deletion smoketests/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def check_docker():
docker_ps = smoketests.run_cmd("docker", "ps", "--format=json")
docker_ps = (json.loads(line) for line in docker_ps.splitlines())
for docker_container in docker_ps:
if "node" in docker_container["Image"]:
if "node" in docker_container["Image"] or "spacetime" in docker_container["Image"]:
return docker_container["Names"]
else:
print("Docker container not found, is SpacetimeDB running?")
Expand Down Expand Up @@ -79,6 +79,7 @@ def main():
# have docker logs print concurrently with the test output
if args.compose_file:
subprocess.Popen(["docker", "compose", "-f", args.compose_file, "logs", "-f"])
smoketests.COMPOSE_FILE = args.compose_file
else:
docker_container = check_docker()
subprocess.Popen(["docker", "logs", "-f", docker_container])
Expand Down
7 changes: 4 additions & 3 deletions smoketests/tests/zz_docker.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import time
from .. import Smoketest, run_cmd, requires_docker
from .. import Smoketest, run_cmd, requires_docker, COMPOSE_FILE
from urllib.request import urlopen
from .add_remove_index import AddRemoveIndex


def restart_docker():

# Behold!
#
# You thought stop/start restarts? How wrong. Restart restarts.
run_cmd("docker", "compose", "restart")
run_cmd("docker", "compose", "-f", COMPOSE_FILE, "restart")
# The suspense!
#
# Wait until compose believes the health probe succeeds.
#
# The container may decide to recompile, or grab a coffee at crates.io, or
# whatever. In any case, restart doesn't mean the server is up yet.
run_cmd("docker", "compose", "up", "--no-recreate", "--detach", "--wait-timeout", "60")
run_cmd("docker", "compose","-f", COMPOSE_FILE, "up", "--no-recreate", "--detach", "--wait-timeout", "60")
# Belts and suspenders!
#
# The health probe runs inside the container, but that doesn't mean we can
Expand Down

0 comments on commit 4250ef2

Please sign in to comment.