Skip to content

[bgpmon]Add new test case test_bgpmon#2521

Merged
bingwang-ms merged 5 commits intosonic-net:masterfrom
bingwang-ms:add_bgpmon_test
Nov 18, 2020
Merged

[bgpmon]Add new test case test_bgpmon#2521
bingwang-ms merged 5 commits intosonic-net:masterfrom
bingwang-ms:add_bgpmon_test

Conversation

@bingwang-ms
Copy link
Collaborator

@bingwang-ms bingwang-ms commented Nov 12, 2020

Signed-off-by: bingwang [email protected]

Description of PR

Summary:
Fixes # (issue)
This PR implements a new test case test_bgpmon according following test plan.

Testplan:

  1. Choose some ip address which could be reached from the DUT through default routing only
  2. Configure BGPMON neighbor peer with the IP address from the previous item on DUT
  3. Start capturing traffic on DUT interfaces, which are used for the default routes
  4. The test is successfull if we found a syn tcp packet to the ip, and dst port 179 on one of the interfaces. We should capture the traffic for 2 minutes.
    By default bgp connection timer is 120 seconds

Type of change

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

Approach

What is the motivation for this PR?

This PR is to add a new test case for bgp monitor.

How did you do it?

How did you verify/test it?

Verified on Arista-7260cx3 (t0) and vtestbed (t1)

py.test --inventory ../ansible/str,../ansible/veos --host-pattern str-7260cx3-acs-2 --module-path ../ansible --testbed vms7-t0-7260-2 --testbed_file ../ansible/testbed.csv --junit-xml=tr.xml --log-cli-level warn --collect_techsupport=False --topology=t0,any,util bgp/test_bgpmon.py
========================================================================================= test session starts =========================================================================================
collected 1 item                                                                                                                                                                                      

bgp/test_bgpmon.py::test_bgpmon PASSED                                                                                                                                                          [100%]

------------------------------------------------------------------ generated xml file: /data/Networking-acs-sonic-mgmt/tests/tr.xml -------------------------------------------------------------------
====================================================================================== 1 passed in 34.23 seconds ======================================================================================
py.test --inventory ../ansible/veos_vtb --host-pattern vlab-01 --module-path ../ansible/library/ --testbed vms-kvm-t1 --testbed_file ../ansible/vtestbed.csv --junit-xml=tr.xml --log-cli-level warn -k 'not test_restart_syncd' --topology=t1,t0,any,util bgp/test_bgpmon.py
========================================================================================= test session starts =========================================================================================
collected 1 item                                                                                                                                                                                      

bgp/test_bgpmon.py::test_bgpmon PASSED                                                                                                                                                          [100%]

-------------------------------------------------------------------------- generated xml file: /data/sonic-mgmt/tests/tr.xml --------------------------------------------------------------------------
====================================================================================== 1 passed in 34.37 seconds ======================================================================================

Any platform specific information?

No.

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

Support any topo.

Documentation

@lguohan
Copy link
Contributor

lguohan commented Nov 12, 2020

can you add this to kvmtest.sh, let's try it on kvm switch as well.

@bingwang-ms
Copy link
Collaborator Author

can you add this to kvmtest.sh, let's try it on kvm switch as well.

Sure. Updated.

@@ -0,0 +1,15 @@
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

better to name bgpmon.json.j2 and save it under tests/bgp/templates/

'local_addr': local_addr,
'peer_name': 'bgp_monitor'
}
bgpmon_template = Template(open(BGPMON_TEMPLATE_FILE).read())
Copy link
Collaborator

@lolyu lolyu Nov 12, 2020

Choose a reason for hiding this comment

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

better to use Ansible module template to do this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We need to add those extra vars to a AnsibleHost such as ptfhost or duthost if we want to use template in Ansible module, right?

@pytest.fixture
def common_setup_teardown(duthost, ptfhost):
mg_facts = duthost.minigraph_facts(host=duthost.hostname)['ansible_facts']
peer_addr = generate_ips(1, "%s/%s" % (mg_facts['minigraph_vlan_interfaces'][0]['addr'],
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if the testbed is a t1?

Copy link
Contributor

@pavel-shirshov pavel-shirshov left a comment

Choose a reason for hiding this comment

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

Thank you for the test case
I think the logic should be following:

  1. Generate random ip address
  2. Check that the ip address is routed through default routes, if not - go to item 1
  3. Extract physical interfaces which are used as interfaces in default routes
  4. Start capturing on the interfaces.

BGPMON_TEMPLATE_FILE = 'bgp/bgpmon.j2'
BGPMON_CONFIG_FILE = '/tmp/bgpmon.json'
BGP_PORT = 179
BGP_CONNECT_TIMEOUT = 120
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest to make the timeout to 121. Just to be double sure

@pytest.fixture
def common_setup_teardown(duthost, ptfhost):
mg_facts = duthost.minigraph_facts(host=duthost.hostname)['ansible_facts']
peer_addr = generate_ips(1, "%s/%s" % (mg_facts['minigraph_vlan_interfaces'][0]['addr'],
Copy link
Contributor

Choose a reason for hiding this comment

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

As I remember we need to generate a random ip address and check that 'ip route get ' will return default route

1.Move bgpmon.j2 to templates
2.Generate random IP address for test
3.Capture on all interfaces in default routes

Signed-off-by: bingwang <[email protected]>
@bingwang-ms
Copy link
Collaborator Author

Updated. Please help to review @pavel-shirshov @lolyu
Thanks very much

@lguohan
Copy link
Contributor

lguohan commented Nov 13, 2020

@pavel-shirshov , can you put the test cases under doc directory so that we can have a reference there?


def generate_ip_through_default_route(host):
# Generate an IP address routed through default routes
ip_addrs = generate_ips(200, "200.0.0.1/24", [])
Copy link
Contributor

Choose a reason for hiding this comment

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

This code will iterate through the same 200.0.0.0/24 subnet.
So if the first prefix fail, other prefixes would fail too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated. Thanks!

Copy link
Contributor

@pavel-shirshov pavel-shirshov left a comment

Choose a reason for hiding this comment

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

LGTM

@lguohan
Copy link
Contributor

lguohan commented Nov 13, 2020

@pavel-shirshov , can you provide the bgp commands to disable the nexthop tracking so that they can test it and make sure the test does not pass for negative case? i'd like to make sure the case does catch issue.

Copy link
Contributor

@pavel-shirshov pavel-shirshov left a comment

Choose a reason for hiding this comment

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

Can you please check that your test will FAIL when you remove
ip nht resolve-via-default
from the FRR config?

The ptf hosts are placed under sonic group, and the
ansible_user will be overwriten by that in ansible/group_vars/sonic/variables, which is ```admin``` in default.
As a result, the login to ptf container will failed on vtestbed because
of incorrect user. This commit address this issue.

Signed-off-by: bingwang <[email protected]>
@bingwang-ms
Copy link
Collaborator Author

Can you please check that your test will FAIL when you remove
ip nht resolve-via-default
from the FRR config?

Sure. Added a new test case for verifying this. Please help to review. Thanks

@bingwang-ms bingwang-ms force-pushed the add_bgpmon_test branch 2 times, most recently from 3329dea to 2f3e74a Compare November 17, 2020 03:41
@yxieca
Copy link
Collaborator

yxieca commented Nov 17, 2020

retest vsimage please

1 similar comment
@bingwang-ms
Copy link
Collaborator Author

retest vsimage please

@bingwang-ms bingwang-ms merged commit bbaaf00 into sonic-net:master Nov 18, 2020
kazinator-arista pushed a commit to kazinator-arista/sonic-mgmt that referenced this pull request Mar 4, 2026
swss:
* 7e274a4 2022-11-18 | [Fdbsyncd] Bug Fix for remote MAC move to local MAC and Fix for Static MAC advertisement in EVPN. (sonic-net#2521) (HEAD -> 202205, github/202205) [KISHORE KUNAL]
* 434e80c 2022-11-02 | Fix vs test issue: failed to remove vlan due to referenced by vlan interface (sonic-net#2504) [Stephen Sun]
* 11bef87 2022-11-27 | [dual-tor] add missing SAI attribte in order to create IPNIP tunnel (sonic-net#2503) [Andriy Yurkiv]
* 11aba29 2022-11-09 | [SWSS] Innovium platform specific changes in PFC Detect lua script (sonic-net#2493) [maulik_patel_marvell]
* 4a165ee 2022-11-14 | Revert "[vlanmgr] Disable `arp_evict_nocarrier` for vlan host intf (sonic-net#2469)" (sonic-net#2518) [Longxiang Lyu]

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

Signed-off-by: Ying Xie <[email protected]>
kazinator-arista pushed a commit to kazinator-arista/sonic-mgmt that referenced this pull request Mar 4, 2026
Update sonic-swss submodule pointer to include the following:
* 782a2ef Align watermark flow with port configuration ([sonic-net#2525](sonic-net/sonic-swss#2525))
* dca78d8 [Fdbsyncd] Bug Fix for remote MAC move to local MAC and Fix for Static MAC advertisement in EVPN. ([sonic-net#2521](sonic-net/sonic-swss#2521))
* 28aa309 [fpm] Fix FpmLink to read all netlink messages from FPM message ([sonic-net#2492](sonic-net/sonic-swss#2492))

Signed-off-by: dprital <[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.

5 participants