Skip to content

Commit

Permalink
Fixes for startup test
Browse files Browse the repository at this point in the history
  • Loading branch information
natefoo committed Aug 23, 2022
1 parent f47527f commit a17b268
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions tests/test_operations.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import os
import re
import time
from pathlib import Path
Expand All @@ -9,7 +10,8 @@

from gravity.cli import galaxyctl

STARTUP_TIMEOUT = 20
STARTUP_TIMEOUT = 30
CELERY_BEAT_TIMEOUT = 10


def test_cmd_register(state_dir, galaxy_yml):
Expand Down Expand Up @@ -50,6 +52,17 @@ def wait_for_gxit_proxy(state_dir):
return startup_logs


def wait_for_path(path, timeout):
for _ in range(timeout * 4):
try:
assert path.exists()
return True
except AssertionError:
time.sleep(0.25)
return False



def start_instance(state_dir, free_port):
runner = CliRunner()
result = runner.invoke(galaxyctl, ['--state-dir', state_dir, 'start'])
Expand All @@ -68,9 +81,9 @@ def test_cmd_start(state_dir, galaxy_yml, startup_config, free_port):
assert result.exit_code == 0, result.output
start_instance(state_dir, free_port)
result = runner.invoke(galaxyctl, ['--state-dir', state_dir, 'status'])
for process in result.stdout.splitlines():
assert "RUNNING" in process or "STARTING" in process, process
assert (state_dir / "celery-beat-schedule").exists()
celery_beat_db_exists = wait_for_path(state_dir / "celery-beat-schedule", CELERY_BEAT_TIMEOUT)
assert celery_beat_db_exists is True, "celery-beat failed to write db. State dir contents:\n" \
f"{os.listdir(state_dir)}"
result = runner.invoke(galaxyctl, ['--state-dir', state_dir, 'stop'])
assert result.exit_code == 0, result.output
assert "All processes stopped, supervisord will exit" in result.output
Expand Down

0 comments on commit a17b268

Please sign in to comment.