-
Notifications
You must be signed in to change notification settings - Fork 1k
Test Completeness enhancements - new diagnose level and helper methods #2149
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 2 commits
dedc179
e64bf79
7bbd373
9705fc6
4fde170
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 | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,10 +4,37 @@ | |||||||||||||||||||||||||||
| import warnings | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| class CompletenessLevel(enum.IntEnum): | ||||||||||||||||||||||||||||
| debug = 0 # Minimum execution | ||||||||||||||||||||||||||||
| basic = 1 | ||||||||||||||||||||||||||||
| confident = 2 | ||||||||||||||||||||||||||||
| thorough = 3 # Maximum execution | ||||||||||||||||||||||||||||
| diagnose = 0 | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
| debug = 1 # Minimum execution | ||||||||||||||||||||||||||||
| basic = 2 | ||||||||||||||||||||||||||||
| confident = 3 | ||||||||||||||||||||||||||||
| thorough = 4 # Maximum execution | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| @classmethod | ||||||||||||||||||||||||||||
| def get_normalized_level(cls, request): | ||||||||||||||||||||||||||||
| """Takes a request instance and returns normalized completeness level in string format. | ||||||||||||||||||||||||||||
| For example, if a testcase supports "CompletenessLevel.basic, CompletenessLevel.thorough", and specified level | ||||||||||||||||||||||||||||
| during test execution is "confident", this method will make use of normalization logic during | ||||||||||||||||||||||||||||
| pytest_runtest_setup and returns the normalized level as "basic" (str type of CompletenessLevel.basic) | ||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
| """Takes a request instance and returns normalized completeness level in string format. | |
| For example, if a testcase supports "CompletenessLevel.basic, CompletenessLevel.thorough", and specified level | |
| during test execution is "confident", this method will make use of normalization logic during | |
| pytest_runtest_setup and returns the normalized level as "basic" (str type of CompletenessLevel.basic) | |
| """ | |
| """Get the normalized completeness level for a given test instance. | |
| For example, if a testcase supports "CompletenessLevel.basic, CompletenessLevel.thorough", and the specified level | |
| during test execution is "confident", then this method will normalize the level to "basic". | |
| Returns: | |
| CompletenessLevel as a string | |
| """ |
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.
Incorporated the suggestion. Thanks!
Outdated
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.
Just some minor formatting changes:
| """Converts a type CompletenessLevel to type str. | |
| For example, if input is CompletenessLevel.basic, this method will return "basic" | |
| Arguments: | |
| level - An enum value of type CompletenessLevel | |
| """Converts a type CompletenessLevel to type str. | |
| For example, if input is CompletenessLevel.basic, this method will return "basic." | |
| Arguments: | |
| level - An enum value of type CompletenessLevel |
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.
Incorporated the suggestion. Thanks!
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,9 @@ | |
| ] | ||
|
|
||
| class TestLinkFlap: | ||
| def __init__(self, request): | ||
| self.completeness_level = CompletenessLevel.get_normalized_level(request) | ||
|
|
||
| def __get_dut_if_status(self, dut, ifname=None): | ||
| if not ifname: | ||
| status = dut.show_interface(command='status')['ansible_facts']['int_status'] | ||
|
|
@@ -47,7 +50,7 @@ def __toggle_one_link(self, dut, dut_port, fanout, fanout_port): | |
| self.ports_shutdown_by_test.discard((fanout, fanout_port)) | ||
|
|
||
|
|
||
| def __build_test_candidates(self, dut, fanouthosts, completeness_level): | ||
| def __build_test_candidates(self, dut, fanouthosts): | ||
| status = self.__get_dut_if_status(dut) | ||
| candidates = [] | ||
|
|
||
|
|
@@ -60,17 +63,17 @@ def __build_test_candidates(self, dut, fanouthosts, completeness_level): | |
| logging.info("Skipping port {} that is admin down".format(dut_port)) | ||
| else: | ||
| candidates.append((dut_port, fanout, fanout_port)) | ||
| if CompletenessLevel.debug in completeness_level: | ||
| if self.completeness_level == 'debug': | ||
| # Run the test for one port only - to just test if the test works fine | ||
| return candidates | ||
|
|
||
| return candidates | ||
|
|
||
|
|
||
| def run_link_flap_test(self, dut, fanouthosts, completeness_level): | ||
| def run_link_flap_test(self, dut, fanouthosts): | ||
| self.ports_shutdown_by_test = set() | ||
|
|
||
| candidates = self.__build_test_candidates(dut, fanouthosts, completeness_level) | ||
| candidates = self.__build_test_candidates(dut, fanouthosts) | ||
| if not candidates: | ||
| pytest.skip("Didn't find any port that is admin up and present in the connection graph") | ||
|
|
||
|
|
@@ -85,7 +88,5 @@ def run_link_flap_test(self, dut, fanouthosts, completeness_level): | |
|
|
||
| @pytest.mark.platform('physical') | ||
| def test_link_flap(request, duthost, fanouthosts): | ||
| normalized_level = [mark.args for mark in request.node.iter_markers(name="supported_completeness_level")][0] | ||
| logging.info("Completeness level set: {}".format(str(normalized_level))) | ||
| tlf = TestLinkFlap() | ||
| tlf.run_link_flap_test(duthost, fanouthosts, normalized_level) | ||
| tlf = TestLinkFlap(request) | ||
| tlf.run_link_flap_test(duthost, fanouthosts) | ||
|
||
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.
Can you clarify this some more? I think it is still a little confusing what the difference is between this new level and the existing levels. Maybe an example use-case would help?
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.
Improved the description and described what the level is ideally meant for.