Skip to content

[pytest]: various tests re-written in pytest#802

Merged
lguohan merged 6 commits intosonic-net:masterfrom
lguohan:pytest
Apr 7, 2019
Merged

[pytest]: various tests re-written in pytest#802
lguohan merged 6 commits intosonic-net:masterfrom
lguohan:pytest

Conversation

@lguohan
Copy link
Contributor

@lguohan lguohan commented Feb 6, 2019

requires pytest-ansible module

  1. bgp_facts
  2. lldp
  3. bgp_speaker_test

Signed-off-by: Guohan Lu [email protected]

Description of PR

Summary:
Fixes # (issue)

Type of change

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

Approach

How did you do it?

this is equivalent of bgp_facts.yml test but much simpler.

How did you verify/test it?

johnar@768fc4f448e2:/data/sonic-mgmt/tests$ py.test --inventory veos.vtb --host-pattern all --user admin -vvv --show-capture stdout --testbed vms-kvm-t0 --testbed_file vtestbed.csv 
========================================================= test session starts ==========================================================
platform linux2 -- Python 2.7.12, pytest-4.3.0, py-1.8.0, pluggy-0.9.0 -- /usr/bin/python
cachedir: .pytest_cache
ansible: 2.7.10
rootdir: /data/sonic-mgmt/tests, inifile: setup.cfg
plugins: ansible-2.0.2
collected 3 items                                                                                                                      

test_bgp_fact.py::test_bgp_facts PASSED                                                                                          [ 33%]
test_bgp_speaker.py::test_bgp_speaker PASSED                                                                                     [ 66%]
test_lldp.py::test_lldp PASSED              

Any platform specific information?

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

Documentation

requires pytest-ansible module

Signed-off-by: Guohan Lu <[email protected]>
Signed-off-by: Guohan Lu <[email protected]>
@lguohan lguohan changed the title [pytest]: bgp_facts written in pytest [pytest]: various tests re-written in pytest Feb 11, 2019
Signed-off-by: Guohan Lu <[email protected]>
@lguohan
Copy link
Contributor Author

lguohan commented Apr 5, 2019

next task is to add inventory management

@lguohan lguohan merged commit a4db98b into sonic-net:master Apr 7, 2019
auspham pushed a commit to auspham/sonic-mgmt that referenced this pull request Feb 3, 2026
Initialize lldpctl_interface in ansible/tests/lldp/test_lldpsyncd.py in
order to prevent potential UnboundLocalError.

<!--
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:
Fixes # (issue)

Fix potential UnboundLocalError in ansible/tests/lldp/test_lldp_syncd.py
by initializing lldpctl_interface to None.  The assertion this variable
is passed to performs an existence check, and so will fail the testlet
appropriately if lldpctl_interface is not set.

### Type of change

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

### Back port request
- [ ] 202205
- [ ] 202305
- [ ] 202311
- [ ] 202405
- [ ] 202411
- [x] 202505

### Approach
#### What is the motivation for this PR?
Enhance the debug-ability of ansible/tests/lldp/test_lldpsyncd.py such
that in the even that no lldp interface is identified in the test, the
error is propagated up to and reported by the verification method and
does not simply throw UnboundLocalError.

#### How did you do it?
Fix is to initialize the variable lldpctl_interface to None outside of
conditional logic so that it has a value when passed to the test
verification method.

#### How did you verify/test it?
Verified that the same failing test case no longer throws
UnboundLocalError and fails in a meaningful way for further debug.
kazinator-arista pushed a commit to kazinator-arista/sonic-mgmt that referenced this pull request Mar 4, 2026
…on (sonic-net#3443)

Submodule src/sonic-platform-common ac7fde6..58f9672:
  > [sfp_base] Raise exceptions (previously was incorrectly returning them) (sonic-net#61)

Submodule src/sonic-swss 660530e..2974844:
  > Fix MIRROR_SESSION table macro name (sonic-net#802)
  > Don't try to remove a vxlan tunnel if it has associated tunnel maps (sonic-net#1052)

Submodule src/sonic-swss-common d6140fa..d7b1f53:
  > Fix MIRROR_SESSION table macro name (sonic-net#264)

Signed-off-by: Ying Xie <[email protected]>
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.

3 participants