Skip to content

Commit

Permalink
Merge pull request #559 from doorstop-dev/wait_for_server
Browse files Browse the repository at this point in the history
Wait for server
  • Loading branch information
neerdoc committed Mar 8, 2022
2 parents 6ede2ee + d717791 commit 4f5471b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/execute-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,17 @@ jobs:
- name: Install project dependencies
run: make install

- name: Run tests
# Some tests fails intermittently, likely due to the public runners being
# very slow. Especially any client/server tests seems to be problematic.
# This is a simple attempt to re-run the tests up to three times if they
# fail. Does not add any execution time if successful.
- name: Run tests attempt 1
run: make test
- name: Run tests attempt 2
if: ${{ failure() }}
run: make test
- name: Run tests attempt 3
if: ${{ failure() }}
run: make test

- name: Upload coverage
Expand Down
14 changes: 12 additions & 2 deletions doorstop/server/tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from multiprocessing import Process
from unittest.mock import patch

import requests

from doorstop import server
from doorstop.server import main
from doorstop.server.tests import ENV, REASON
Expand All @@ -24,8 +26,16 @@ def setUpClass(cls):
if os.getenv(ENV):
cls.process = Process(target=main.main, kwargs={"args": []})
cls.process.start()
logging.info("delaying for the server to initialize...")
time.sleep(3)
logging.info("waiting for the server to initialize...")
# Check for response!
url = "http://localhost:7867/documents"
for _ in range(0, 29):
try:
_ = requests.head(url)
break
except requests.exceptions.RequestException:
time.sleep(1)
logging.info("server is answering!")
assert cls.process.is_alive()

@classmethod
Expand Down

0 comments on commit 4f5471b

Please sign in to comment.