Skip to content

Commit

Permalink
Skip test_read_mac_metadata if required parameters are missing (#10095)
Browse files Browse the repository at this point in the history
The test arguments image1, image2 and iteration are set to required arguments in test module test_read_mac_metadata.py . If the test pipeline doesn't set the argument, an error is thrown

ERROR: usage: __main__.py [options] [file_or_dir] [file_or_dir] [...]
__main__.py: error: the following arguments are required: --iteration, --image1, --image2
To reduce noise, the arguments are changed to be optional, and the test will be skipped if any of the arguments is missing.

What is the motivation for this PR?
This PR is to skip test_read_mac_metadata if required parameters are missing.

How did you do it?
To reduce noise, the arguments are changed to be optional, and the test will be skipped if any of the arguments is missing.

How did you verify/test it?
The change is verified on a physical testbed. The test is skipped if the argument is not set.

collected 1 item                                                                                                                                                                                      

read_mac/test_read_mac_metadata.py::test_read_mac_metadata[str-msn2700-22] SKIPPED (Skip test due to missing --image1 or --image2)                                                              [100%]
Any platform specific information?
No.

Supported testbed topology if it's a new test case?
Not a new test case.
  • Loading branch information
bingwang-ms authored and mssonicbld committed Oct 30, 2023
1 parent ff0b877 commit cda5cac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions tests/read_mac/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ def pytest_addoption(parser):
action="store",
type=int,
help="Number of image installing iterations",
required=True,
required=False,
)

read_mac_group.addoption(
'--image1',
action='store',
type=str,
help='1st image to download and install',
required=True,
required=False,
)

read_mac_group.addoption(
'--image2',
action='store',
type=str,
help='2nd image to download and install',
required=True,
required=False,
)

read_mac_group.addoption(
Expand Down
12 changes: 7 additions & 5 deletions tests/read_mac/test_read_mac_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ def cleanup_read_mac(duthosts, enum_rand_one_per_hwsku_frontend_hostname, localh

class ReadMACMetadata():
def __init__(self, request):
image1 = request.config.getoption("--image1")
image2 = request.config.getoption("--image2")
self.iteration = request.config.getoption("--iteration")
self.minigraph1 = request.config.getoption("--minigraph1")
self.minigraph2 = request.config.getoption("--minigraph2")
image1 = request.config.getoption("--image1", default=None)
image2 = request.config.getoption("--image2", default=None)
self.iteration = request.config.getoption("--iteration", default=1)
self.minigraph1 = request.config.getoption("--minigraph1", default=None)
self.minigraph2 = request.config.getoption("--minigraph2", default=None)
if not image1 or not image2:
pytest.skip("Skip test due to missing --image1 or --image2")

if self.iteration < 1:
pytest.fail("Please specify --iteration in correct range")
Expand Down

0 comments on commit cda5cac

Please sign in to comment.