Skip to content

[pytest] improvements for pytest infrastructure#1038

Merged
lguohan merged 26 commits intosonic-net:masterfrom
stepanblyschak:ptfadapter_infra
Aug 2, 2019
Merged

[pytest] improvements for pytest infrastructure#1038
lguohan merged 26 commits intosonic-net:masterfrom
stepanblyschak:ptfadapter_infra

Conversation

@stepanblyschak
Copy link
Contributor

@stepanblyschak stepanblyschak commented Jul 29, 2019

Description of PR

Summary:

  • pytest:
    • W/A some issues with pytest-ansible plugin and provided fixtures
    • add ptf adapter package and fixture to send/receive PTF traffic controlled from pytest
    • translate fdb test to use PTF adapter
    • Divide LLDP test into two test cases
  • ansible
    • add pytest_runner.yml to wrap pytest in ansible run
    • remove lldp.yml test code ansible and lldp_neighbor.yml. Instead lldp.yml will run pytest test_lldp.py

TODO:

  • upgrade PTF version and install PTF in sonic-mgmt container
  • get community string for LLDP test from eos.yml or introduce another configuration file
    ( in our testbed community string is 'public' while test_lldp.py hardcodes 'strcommunity' )

Fixes # (issue)

Type of change

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

Approach

How did you do it?

How did you verify/test it?

stepanb@62c67c04c2bd:/stepanb/sonic-mgmt/tests$ py.test -k 'not platform'  --testbed=$SWITCH-t0 --testbed_file=testbed.csv --inventory=../ansible/inventory --host-pattern $SWITCH-t0 -v --ignore=ptftests
=========================================================================================================== test session starts ===========================================================================================================
platform linux2 -- Python 2.7.12, pytest-4.6.4, py-1.8.0, pluggy-0.12.0 -- /usr/bin/python
cachedir: .pytest_cache
Using --randomly-seed=1564067815
ansible: 2.0.0.2
rootdir: /stepanb/sonic-mgmt/tests, inifile: pytest.ini
plugins: randomly-1.2.3, ansible-2.0.2
collected 16 items / 11 deselected / 5 selected                                                                                                                                                                                           

test_bgp_fact.py::test_bgp_facts PASSED                                                                                                                                                                                             [ 20%]
test_lldp.py::test_lldp PASSED                                                                                                                                                                                                      [ 40%]
test_lldp.py::test_lldp_neighbor PASSED                                                                                                                                                                                             [ 60%]
test_bgp_speaker.py::test_bgp_speaker SKIPPED                                                                                                                                                                                       [ 80%]
fdb/test_fdb.py::test_fdb PASSED                                                                                                                                                                                                    [100%]

========================================================================================== 4 passed, 1 skipped, 11 deselected in 147.06 seconds ===========================================================================================

Verify ansible LLDP test

ansible-playbook test_sonic.yml -i inventory -l r-boxer-sw01 -e testbed_name=r-boxer-sw01-t0 -e topo=t0 -e testcase_name=lldp -vvvvvv

Any platform specific information?

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

Documentation

@lguohan
Copy link
Contributor

lguohan commented Aug 1, 2019

LGTM overall

Stepan Blyschak added 22 commits August 1, 2019 11:56
…e issues

There are two issues with pytest-ansible I found:
- ansible_adhoc is limited to function scope which makes it not usable for wider scope test fixtures
- localhost fixture has some hidden dependency on ansible_adhoc (even without changing default scope)
  e.g.:

   def test_x(ansible_adhoc, testbed):
       duthost = AnsibleHost(ansible_adhoc, testbed['dut'])
       pass

   def test_y(ansible_adhoc, localhost, testbed):
       pass

  This snippet of test code fails to evaluate localhost fixture in test_y:

  test_x.py::test_x PASSED                                                                                                                                                                                                            [ 50%]
  test_x.py::test_y ERROR                                                                                                                                                                                                             [100%]

  Part of error log:

        host = self.get_host(hostname)
        if host is None:
>           raise AnsibleError("no host vars as host is not in inventory: %s" % hostname)
E           AnsibleError: ERROR! no host vars as host is not in inventory: arc-switch1025

Signed-off-by: Stepan Blyschak <[email protected]>
…trol PTF traffic from sonic-mgmt node

Signed-off-by: Stepan Blyschak <[email protected]>
Signed-off-by: Stepan Blyschak <[email protected]>
Signed-off-by: Stepan Blyschak <[email protected]>
Signed-off-by: Stepan Blyschak <[email protected]>
Signed-off-by: Stepan Blyschak <[email protected]>
… cases for lldp should be done in pytest

Signed-off-by: Stepan Blyschak <[email protected]>
Signed-off-by: Stepan Blyschak <[email protected]>
Stepan Blyschak added 3 commits August 1, 2019 11:58
@lguohan lguohan merged commit f085ae7 into sonic-net:master Aug 2, 2019
@dawnbeauty
Copy link
Contributor

@stepanblyschak

  1. Can we support configuring nn_rcv_buff and nn_snd_buff size within ptf_nn_agent.conf.ptf.j2. Without that, may drop pkts due to heavy traffic on ptf side.
  2. I think we should add stop_pcap when kill dataplane.

@stepanblyschak
Copy link
Contributor Author

@dawnbeauty
I believe PTF adapter will become more configurable when more tests will use it, right now its first stage for simple traffic tests like fdb, fib, acl which do not expect to send, receive much traffic.

  1. Yes, we can and I believe we'll add this for copp and other tests which require to send lots of packets
  2. We haven't started pcap, so we didn't stop pcap in kill(). I believe we can add pcap writer.

I'm about to convert ACL and everflow tests so I will consider your comments. Thanks

Pterosaur pushed a commit to Pterosaur/sonic-mgmt that referenced this pull request Mar 25, 2026
<!--
Please make sure you've read and understood our contributing guidelines;
https://github.com/sonic-net/SONiC/blob/gh-pages/CONTRIBUTING.md

Please provide following information to help code review process a bit
easier:
-->
### Description of PR
<!--
- Please include a summary of the change and which issue is fixed.
- Please also include relevant motivation and context. Where should
reviewer start? background context?
- List any dependencies that are required for this change.
-->

Summary:
With Broadcom ASICs, don't wait for the ACL rule counters to change from
'N/A' to 0 since it isn't needed (and will cause the test to time out
and fail).

### Type of change

<!--
- Fill x for your type of change.
- e.g.
- [x] Bug fix
-->

- [ ] Bug fix
- [ ] Testbed and Framework(new/improvement)
- [ ] New Test case
    - [ ] Skipped for non-supported platforms
- [x] Test case improvement

Signed-off-by: Fraser Gordon <[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