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

Make service alive checking more universal #1607

Merged
merged 1 commit into from
Jun 12, 2024

Conversation

phoebusm
Copy link
Collaborator

Reference Issues/PRs

It is part of https://github.com/man-group/arcticdb-enterprise/issues/95.
The old design is limited to testing services spinned by subprocess. I made it more universal for testing any url without the same requirement.

What does this implement or fix?

Any other comments?

Checklist

Checklist for code changes...
  • Have you updated the relevant docstrings, documentation and copyright notice?
  • Is this contribution tested against all ArcticDB's features?
  • Do all exceptions introduced raise appropriate error messages?
  • Are API changes highlighted in the PR description?
  • Is the PR labelled as enhancement or bug so it appears in autogenerated release notes?

@phoebusm phoebusm self-assigned this Jun 10, 2024
@phoebusm phoebusm added the enhancement New feature or request label Jun 10, 2024
@phoebusm phoebusm force-pushed the feature/make_service_alive_checking_more_universal branch from f1b274f to b8af42c Compare June 10, 2024 16:36
while True:
assert time.time() < deadline, f"Timed out waiting for {service} process to start"
assert alive(), service + " process died shortly after start up"
if "alive" in locals():
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do not check locals() instead do something like this,

alive = lamba: True

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@phoebusm phoebusm force-pushed the feature/make_service_alive_checking_more_universal branch from b8af42c to 4afb180 Compare June 11, 2024 12:23
@@ -92,7 +92,10 @@ def terminate(p: Union[multiprocessing.Process, subprocess.Popen]):

def wait_for_server_to_come_up(url: str, service: str, process: ProcessUnion, *, timeout=20, sleep=0.2, req_timeout=1):
deadline = time.time() + timeout
alive = (lambda: process.poll() is None) if isinstance(process, subprocess.Popen) else process.is_alive
if process is not None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

(Nit) invert the if to avoid the double negative

@phoebusm phoebusm force-pushed the feature/make_service_alive_checking_more_universal branch from 4afb180 to 66900fc Compare June 11, 2024 14:41
@phoebusm phoebusm merged commit 0a347e8 into master Jun 12, 2024
114 checks passed
@phoebusm phoebusm deleted the feature/make_service_alive_checking_more_universal branch June 12, 2024 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants