Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue#687 #691

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- Replaced entity with getter (#652)
- Resolved TODO in Dockerfile (#680)
- Resolved TODO at src/reporter/tests/test_timescale_types.py (#667)
- Called to the QL's version endpoint #687

### Bug fixes

Expand Down
7 changes: 4 additions & 3 deletions src/wq/tests/benchmark/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import shutil
from time import sleep

from conftest import QL_BASE_URL
from tests.benchmark.driver_base import NOTIFY_TEST
from tests.benchmark.threaded_driver import ThreadedDriver
from utils.tests.docker import dir_from_file_path, DockerCompose
Expand Down Expand Up @@ -48,9 +49,9 @@ def _prep_monitoring_dir(self):

def _start_docker_and_wait_for_services(self):
self._docker.start()
sleep(10)
# TODO call QL's version endpoint rather than sleeping.
# If it's up, then Redis & DB backend are up to b/c of docker deps.
version_url = f"{QL_BASE_URL}/version"
r = requests.get(version_url)
r.raise_for_status()
Comment on lines +52 to +54
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good start, but there's still room for improvement :-)

The problem with this approach is that if QL starts after the requests.get call, the benchmark will exit. Ideally we should wait until we know QL is up or bail out after a max amount of secs. There's a function in reporter.tests.utils we can use to implement this flow. I'm sketching out how below in pseudo code.

from reporter.tests.utils import wait_until

def _can_get_ql_version() -> bool:
    status = requests.get(version_url)
    return status == okay

def wait_for_ql():
    wait_until(_can_get_ql_version)

class TestScript:
    ...
    def _start_docker_and_wait_for_services(self):
        self._docker.start()
        wait_for_ql()
        # If QL is up, then Redis & DB backend are up to b/c of docker deps.


def _start_samplers(self):
self._db_sampler = new_row_count_sampler(self._mon_dir,
Expand Down