-
Notifications
You must be signed in to change notification settings - Fork 1k
[sequential restart] making swss restart test failing as it should be #1991
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| """ | ||
| Helper script for checking status of critical processes | ||
|
|
||
| This script contains re-usable functions for checking status of critical services. | ||
| """ | ||
| import logging | ||
| import time | ||
|
|
||
| from tests.common.helpers.assertions import pytest_assert | ||
| from tests.common.utilities import wait_until | ||
|
|
||
|
|
||
| def _get_critical_processes_status(dut): | ||
| processes_status = dut.all_critical_process_status() | ||
| for k, v in processes_status.items(): | ||
| if v['status'] == False or len(v['exited_critical_process']) > 0: | ||
| return False, processes_status | ||
|
|
||
| return True, processes_status | ||
|
|
||
| def _all_critical_processes_healthy(dut): | ||
| logging.info("Check critical processes status") | ||
| status, _ = _get_critical_processes_status(dut) | ||
| return status | ||
|
|
||
| def check_critical_processes(dut, watch_secs=0): | ||
| """ | ||
| @summary: check all critical processes. They should be all running. | ||
| keep on checking every 5 seconds until watch_secs drops below 0. | ||
| @param dut: The AnsibleHost object of DUT. For interacting with DUT. | ||
| @param watch_secs: all processes should remain healthy for watch_secs seconds. | ||
| """ | ||
| logging.info("Check all critical processes are healthy for {} seconds".format(watch_secs)) | ||
| while watch_secs >= 0: | ||
| status, details = _get_critical_processes_status(dut) | ||
| pytest_assert(status, "Not all critical processes are healthy: {}".format(details)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't this be just logging error since we want this loop to continue?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The purpose of this loop is to make sure that there is no critical process failure for 60 seconds (or a spot check if watch_secs == 0). If there is a failure, then the test should fail.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What you have in mind is the other method: wait_critical_process()
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I got confused with the wait_critical_process approach. It is clear now |
||
| if watch_secs > 0: | ||
| time.sleep(min(5, watch_secs)) | ||
| watch_secs = watch_secs - 5 | ||
|
|
||
| def wait_critical_processes(dut): | ||
| """ | ||
| @summary: wait until all critical processes are healthy. | ||
| @param dut: The AnsibleHost object of DUT. For interacting with DUT. | ||
| """ | ||
| logging.info("Wait until all critical processes are healthy") | ||
| pytest_assert(wait_until(300, 20, _all_critical_processes_healthy, dut), | ||
| "Not all critical processes are healthy") | ||
|
|
||
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.
Why are we not using the existing 'all_critical_process_status' in devices.py?
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.
We are using it. See line 14 :-)
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.
ah I see. My bad