Skip to content

Commit

Permalink
Don't call expensive fixtures if skipping sanity (sonic-net#13188)
Browse files Browse the repository at this point in the history
If the `--skip_sanity` option has been given, then don't call expensive
fixtures and get the values of those fixtures just to end up not using
them. Instead, have a small function that only gets the request
fixture, and if sanity checks are not skipped, then call the full
function that gets all fixtures.

This saves about 20-30 seconds of time.

Signed-off-by: Saikrishna Arcot <[email protected]>
  • Loading branch information
saiarcot895 authored Jun 13, 2024
1 parent 616799d commit be348b3
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions tests/common/plugins/sanity_check/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,8 @@ def do_checks(request, check_items, *args, **kwargs):
return check_results


@pytest.fixture(scope="module", autouse=True)
def sanity_check(localhost, duthosts, request, fanouthosts, nbrhosts, tbinfo):
if request.config.option.skip_sanity:
logger.info("Skip sanity check according to command line argument")
yield
return

@pytest.fixture(scope="module")
def sanity_check_full(localhost, duthosts, request, fanouthosts, nbrhosts, tbinfo):
logger.info("Prepare sanity check")

skip_sanity = False
Expand Down Expand Up @@ -303,3 +298,12 @@ def sanity_check(localhost, duthosts, request, fanouthosts, nbrhosts, tbinfo):
logger.info("Done post-test sanity check")
else:
logger.info('No post-test sanity check item, skip post-test sanity check.')


@pytest.fixture(scope="module", autouse=True)
def sanity_check(request):
if request.config.option.skip_sanity:
logger.info("Skip sanity check according to command line argument")
yield
else:
yield request.getfixturevalue('sanity_check_full')

0 comments on commit be348b3

Please sign in to comment.