-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Wait for OPA to load rules in tests startup #5483
Conversation
tests/python/shared/fixtures/init.py
Outdated
|
||
def wait_for_opa(): | ||
for i in range(300): | ||
logging.getLogger(__package__).debug(f"waiting for the opa to load ... ({i})") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zhiltsov-max , we have our own health check which have the logic.
tests/python/shared/fixtures/init.py
Outdated
def wait_for_server(): | ||
for _ in range(30): | ||
for i in range(300): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zhiltsov-max , need to use our own health check.
@kirill-sizov , could you please comment? |
My comment is the same as yours: probably we should reuse our I also noticed that in our docker-compose file |
Changed to use the server command, as recommended in the docs. UPD: changed to the server as it looks more generic (e.g. for k8s deployments) |
tests/python/shared/fixtures/init.py
Outdated
@@ -205,7 +223,7 @@ def kube_restore_data_volumes(): | |||
pod_name = _kube_get_server_pod_name() | |||
kube_cp( | |||
CVAT_DB_DIR / "cvat_data.tar.bz2", | |||
f"{pod_name}:/tmp/cvat_data.tar.bz2", | |||
f"{pod_name}:/tifmp/cvat_data.tar.bz2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zhiltsov-max , is it typo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, fixed. Sometimes I occasionally can paste something with my laptop's touchpad.
tests/python/shared/fixtures/init.py
Outdated
response = requests.get(get_server_url("api/server/health/", format="json")) | ||
try: | ||
statuses = response.json() | ||
if all(v == "working" for v in statuses.values()): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zhiltsov-max , I believe it is better just to check the response status. If it is 200, the server is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
tests/python/shared/fixtures/init.py
Outdated
sleep(5) | ||
def wait_for_services(): | ||
for i in range(300): | ||
logging.getLogger(__package__).debug(f"waiting for the server to load ... ({i})") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably it is better to get the logger only once.
logger = logging.getLogger(__package__)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
OPA can take some time to load rules, but our tests don't wait for OPA, and start right after the server is loaded. Sometimes it works, but in other times the tests may fail because OPA is still loading the rules. This PR allows to wait for OPA during the test suite startup.
Motivation and context
OPA can take some time to load rules, but our tests don't wait for OPA, and start right after the server is loaded.
Sometimes it works, but in other times the tests may fail because OPA is still loading the rules.
This PR allows to wait for OPA during the test suite startup.
How has this been tested?
Checklist
develop
branchcvat-core, cvat-data and cvat-ui)
License
Feel free to contact the maintainers if that's a concern.