Skip to content
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

Use correct scope when parametrizing tests based on duts/asics #4961

Merged
merged 1 commit into from
Feb 8, 2022

Conversation

vcheketx
Copy link
Contributor

Description of PR

Summary:
Fixes parametrization based on duts/asics occuring per collected test instead of once per module

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • Test case(new/improvement)

Back port request

  • 201911

Approach

What is the motivation for this PR?

Currently we are using enum fixtures for parametrization based on available duts/asics (e.g. enum_dut_hostname, enum_frontend_asic_index). These fixtures are parametrized inside pytest_generate_tests function using metafunc.parametrize with scope='module'.
If any test already has parametrization using @pytest.mark.parametrize, these enum fixtures will be recreated for each collected test, ignoring above mentioned scope.
This behavior can be easily noticed during copp/test_copp.py. Even on testbed with single DUT, examining setup/teardown during test shows that enum_rand_one_per_hwsku_frontend_hostname is recreated after each pair of tests, triggering teardown/setup of dependent fixtures. This adds ~40 minutes to test_copp.py execution time.

How did you do it?

Added override for enum fixtures outside of pytest_generate_tests with correct scope.

How did you verify/test it?

Run copp/test_copp.py - execution time decreased from ~55 minutes to ~15 minutes.

Note: tested only on single-DUT testbed.

Any platform specific information?

Supported testbed topology if it's a new test case?

Documentation

Copy link
Contributor

@abdosi abdosi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Verified

@abdosi abdosi linked an issue Feb 8, 2022 that may be closed by this pull request
@abdosi abdosi merged commit e19a72b into sonic-net:master Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

for copp test case class scope fixture not working correctly.
2 participants