Skip to content

[test runner] add a script to run pytests#1861

Merged
wangxin merged 7 commits intosonic-net:masterfrom
yxieca:run_test
Jul 8, 2020
Merged

[test runner] add a script to run pytests#1861
wangxin merged 7 commits intosonic-net:masterfrom
yxieca:run_test

Conversation

@yxieca
Copy link
Collaborator

@yxieca yxieca commented Jul 7, 2020

Summary:
Fixes # (issue)

Type of change

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

Approach

What is the motivation for this PR?

Provide a common way for the community to run pytests.

How did you do it?

Provide common infrastructure to run pytest. Test can be run in
2 different methods:

  1. group execution: test case are executed in groups. First execute
    the util group, then executed the specified topology group.
    1.1. in group execution mode, user can specify option -c to run
    a (list of) test cases/files.
  2. individual execution: first execute the util group. Then execute
    specified topology group individually.

Signed-off-by: Ying Xie [email protected]

How did you verify/test it?

yinxi@acs-trusty8:/var/src/sonic-mgmt/tests$ ./run_tests.sh -d str-dx010-acs-1 -n vms3-t1-dx010-1 -t t1,any -s "test_vrf.py test_vrf_attr.py test_mgmtvrf.py copp/test_copp.py" -i /var/src/sonic-mgmt/ansible/str,/var/src/sonic-mgmt/ansible/veo -e --collect-only -m group -o -u -c platform_tests/test_reboot.py
=== running tests in groups ===
================================================================================== test session starts ===================================================================================
platform linux2 -- Python 2.7.12, pytest-4.6.5, py-1.8.1, pluggy-0.13.1
ansible: 2.8.7
rootdir: /var/src/sonic-mgmt/tests, inifile: pytest.ini
plugins: ansible-2.2.2, xdist-1.28.0, forked-1.1.3, repeat-0.8.0
collected 7 items
<Package /var/src/sonic-mgmt/tests/platform_tests>




<Function test_power_off_reboot[15]>
<Function test_power_off_reboot[5]>

Provide common infrastructure to run pytest. Test can be run in
two different methods:

1. Group execution: test case are executed in groups. First execute
   the util group, then executed the specified topology group.
   1.1. in group execution mode, user can specify option -c to run
        a (list of) test cases/files.
2. Individual execution: first execute the util group. Then execute
   specified topology group individually.

Signed-off-by: Ying Xie <[email protected]>
Copy link
Contributor

@daall daall left a comment

Choose a reason for hiding this comment

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

Added a few random thoughts, I don't think any of them are blocking issues though.

TEST_CASES=""
OMIT_FILE_LOG="False"
BYPASS_UTIL="False"
RETAIN_SUCCUSESS_LOG="False"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
RETAIN_SUCCUSESS_LOG="False"
RETAIN_SUCCESSES_LOG="False"

typo

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My face red. Thanks!

Copy link
Contributor

@daall daall left a comment

Choose a reason for hiding this comment

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

Just one more q, but overall LGTM.

function run_group_tests()
{
if [[ x"${BYPASS_UTIL}" == x"False" ]]; then
echo "=== Runing utility test cases ==="
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this language be confusing? Should we describe this as "pre-steps" or "test setup" or something similar? I'm just wondering because we're not really testing anything per se (at least I don't think so?), we're preparing the testbed for further steps.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks! Changed.

{
if [[ x"${BYPASS_UTIL}" == x"False" ]]; then
echo "=== Runing pre-test cases ==="
py.test ${PYTEST_COMMON_OPTS} ${UTIL_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} -k "not test_restart_syncd" ${EXTRA_PARAMETERS}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This test_restart_syncd case in tests/platform_tests/test_sequential_restart.py has been marked as skip. It's unnecessary to skip it again here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be better to add sleep 120 here to wait a while for the DUT to learn all the IP routes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks! Changed both.

py.test ${PYTEST_COMMON_OPTS} ${UTIL_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} -k "not test_restart_syncd" ${EXTRA_PARAMETERS}
fi
echo "=== Running tests in groups ==="
py.test ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} -k "not test_restart_syncd" ${EXTRA_PARAMETERS} ${TEST_CASES}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same for test_restart_syncd here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed.

{
if [[ x"${BYPASS_UTIL}" == x"False" ]]; then
echo "=== Runing pre-test cases ==="
py.test ${PYTEST_COMMON_OPTS} ${UTIL_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} -k "not test_restart_syncd" ${EXTRA_PARAMETERS}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same for test_restart_syncd here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed.

@wangxin wangxin merged commit 77a6d1c into sonic-net:master Jul 8, 2020
@yxieca yxieca deleted the run_test branch July 8, 2020 05:56
kazinator-arista pushed a commit to kazinator-arista/sonic-mgmt that referenced this pull request Mar 4, 2026
8768089 (HEAD -> 202012, origin/202012) Remove exec from platform_reboot_plugin call to handle any hang issue. (sonic-net#1879)
ae5d90c Validate input of ```config mirror_session add``` (sonic-net#1825)
44d3a3b [show][config] fix the muxcable commands for interface naming mode (sonic-net#1862)
0a4933e [TH3] Skipp Control Plane Assist on WARM Reboot for TH3 HWSKUs (sonic-net#1861)

Signed-off-by: vaibhav-dahiya <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants