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

[DPB/VLAN] Add test VS cases and fix FDB flush issues #1242

Merged
merged 10 commits into from
Jun 10, 2020

Conversation

vasant17
Copy link
Contributor

@vasant17 vasant17 commented Apr 6, 2020

What I did
Added DPB-VLAN dependency test cases
Fixed FDB flush issues encountered during test

Why I did it
When port is a member of VLAN and we do dynamic port breakout, we identify the dependency and remove the port from VLAN and then delete the port.
But, when we remove the port from VLAN, couple of things happen or should happen

  1. FDB entries associated with the bridge port ID of the port in all VLANs should be removed.
  2. Delete the bridge port.

This will enable/allow us to delete the port.

While testing we hit the following issue:
Bug: Even though we remove the port from all VLANS, we were unable to delete the port, as associated bridge port OID was still present

Root cause: The bridge port OID associated with port was NOT deleted because, associated FDB entries were NOT flushed.

Solution:
We are going to clear FDB entries in two cases:

  1. When port is shutdown
  2. When port is removed from VLAN.

Firstly, when port is shutdown, we are going to call SAI FDB flush API by passing bridge port OID. Note that we will do this only if the port has valid (NON NULL) bridge port OID. Thats because if you call SAI FDB flush without any valid bridge port OID or BVID, it will flush all FDB entries.

Secondly, whenever we remove the port from a VLAN, we are going to call SAI FDB flush API with valid <bridge port OID, BVID>

With both these fixes in place, irrespective of the order we will clean the FDB entries, delete bridge port OID and then delete the port. The order I am talking here is, whether the port is shutdown first or its removed from all VLANs.

How I verified it
Ran VS test cases

Details if related

vapatil@server09:~/workspace/DPB/sonic-buildimage/src/sonic-swss/tests$ sudo pytest --pdb -s -v --dvsname=vs-vp test_port_dpb_vlan.py
[sudo] password for vapatil: 
======================================================================= test session starts ========================================================================
platform linux2 -- Python 2.7.15+, pytest-3.3.0, py-1.8.0, pluggy-0.6.0 -- /usr/bin/python
cachedir: .cache
rootdir: /home/vapatil/workspace/DPB/sonic-buildimage/src/sonic-swss/tests, inifile:
collected 4 items                                                                                                                                                  

test_port_dpb_vlan.py::TestPortDPBVlan::test_dependency remove extra link dummy
PASSED                                                                                               [ 25%]
test_port_dpb_vlan.py::TestPortDPBVlan::test_one_port_one_vlan PASSED                                                                                        [ 50%]
test_port_dpb_vlan.py::TestPortDPBVlan::test_one_port_multiple_vlan PASSED                                                                                   [ 75%]
test_port_dpb_vlan.py::TestPortDPBVlan::test_all_port_10_vlans PASSED                                                                                        [100%]

==================================================================== 4 passed in 966.91 seconds ====================================================================

Test case results after refactoring code based on newly introduced dvslib.

vapatil@server09:~/workspace/DPB/sonic-buildimage/src/sonic-swss/tests$ sudo pytest -s -v --pdb --dvsname=vs-vp test_vlan.py 
================================================================================== test session starts ==================================================================================
platform linux2 -- Python 2.7.17, pytest-3.3.0, py-1.8.0, pluggy-0.6.0 -- /usr/bin/python
cachedir: .cache
rootdir: /home/vapatil/workspace/DPB/sonic-buildimage/src/sonic-swss/tests, inifile:
collected 25 items                                                                                                                                                                      

test_vlan.py::TestVlan::test_VlanAddRemove remove extra link dummy
PASSED                                                                                                                                 [  4%]
test_vlan.py::TestVlan::test_MultipleVlan PASSED                                                                                                                                  [  8%]
test_vlan.py::TestVlan::test_VlanIncrementalConfig PASSED                                                                                                                         [ 12%]
test_vlan.py::TestVlan::test_AddVlanWithIncorrectKeyPrefix[test_input0-0] PASSED                                                                                                  [ 16%]
test_vlan.py::TestVlan::test_AddVlanWithIncorrectKeyPrefix[test_input1-0] PASSED                                                                                                  [ 20%]
test_vlan.py::TestVlan::test_AddVlanWithIncorrectKeyPrefix[test_input2-0] PASSED                                                                                                  [ 24%]
test_vlan.py::TestVlan::test_AddVlanWithIncorrectKeyPrefix[test_input3-1] PASSED                                                                                                  [ 28%]
test_vlan.py::TestVlan::test_AddVlanWithIncorrectValueType[test_input0-0] PASSED                                                                                                  [ 32%]
test_vlan.py::TestVlan::test_AddVlanWithIncorrectValueType[test_input1-0] PASSED                                                                                                  [ 36%]
test_vlan.py::TestVlan::test_AddVlanWithIncorrectValueType[test_input2-0] PASSED                                                                                                  [ 40%]
test_vlan.py::TestVlan::test_AddVlanWithIncorrectValueType[test_input3-1] PASSED                                                                                                  [ 44%]
test_vlan.py::TestVlan::test_AddPortChannelToVlan PASSED                                                                                                                          [ 48%]
test_vlan.py::TestVlan::test_AddVlanMemberWithNonExistVlan PASSED                                                                                                                 [ 52%]
test_vlan.py::TestVlan::test_RemoveNonexistentVlan PASSED                                                                                                                         [ 56%]
test_vlan.py::TestVlan::test_VlanMemberTaggingMode[test_input0-expected0] PASSED                                                                                                  [ 60%]
test_vlan.py::TestVlan::test_VlanMemberTaggingMode[test_input1-expected1] PASSED                                                                                                  [ 64%]
test_vlan.py::TestVlan::test_VlanMemberTaggingMode[test_input2-expected2] PASSED                                                                                                  [ 68%]
test_vlan.py::TestVlan::test_VlanMemberTaggingMode[test_input3-expected3] PASSED                                                                                                  [ 72%]
test_vlan.py::TestVlan::test_VlanMemberTaggingMode[test_input4-expected4] PASSED                                                                                                  [ 76%]
test_vlan.py::TestVlan::test_AddMaxVlan SKIPPED                                                                                                                                   [ 80%]
test_vlan.py::TestVlan::test_RemoveVlanWithRouterInterface PASSED                                                                                                                 [ 84%]
test_vlan.py::TestVlan::test_VlanDbData PASSED                                                                                                                                    [ 88%]
test_vlan.py::TestVlan::test_VlanMemberDbData[test_input0-expected0] PASSED                                                                                                       [ 92%]
test_vlan.py::TestVlan::test_VlanMemberDbData[test_input1-expected1] PASSED                                                                                                       [ 96%]
test_vlan.py::TestVlan::test_VlanMemberDbData[test_input2-expected2] PASSED                                                                                                       [100%]Exception AssertionError: AssertionError(u"assert 0 > 0\n +  where 0 = int('0')\n +    where '0' = <built-in method group of _sre.SRE_Match object at 0x7efd169a6ab0>(1)\n +      where <built-in method group of _sre.SRE_Match object at 0x7efd169a6ab0> = <_sre.SRE_Match object at 0x7efd169a6ab0>.group",) in <bound method ApplDbValidator.__del__ of <conftest.ApplDbValidator object at 0x7efd169f12d0>> ignored


========================================================================= 24 passed, 1 skipped in 96.55 seconds =========================================================================
vapatil@server09:~/workspace/DPB/sonic-buildimage/src/sonic-swss/tests$

vapatil@server09:~/workspace/DPB/sonic-buildimage/src/sonic-swss/tests$ sudo pytest -s -v --pdb --dvsname=vs-vp test_port_dpb_vlan.py
================================================================================== test session starts ==================================================================================
platform linux2 -- Python 2.7.17, pytest-3.3.0, py-1.8.0, pluggy-0.6.0 -- /usr/bin/python
cachedir: .cache
rootdir: /home/vapatil/workspace/DPB/sonic-buildimage/src/sonic-swss/tests, inifile:
collected 4 items

test_port_dpb_vlan.py::TestPortDPBVlan::test_dependency remove extra link dummy
remove extra link Vlan100@Bridge
remove extra link Vlan101@Bridge
remove extra link Vlan102@Bridge
remove extra link Vlan103@Bridge
remove extra link Vlan104@Bridge
remove extra link Vlan105@Bridge
remove extra link Vlan106@Bridge
remove extra link Vlan107@Bridge
remove extra link Vlan108@Bridge
remove extra link Vlan109@Bridge
Exception AssertionError: AssertionError(u"assert 0 > 0\n +  where 0 = int('0')\n +    where '0' = <built-in method group of _sre.SRE_Match object at 0x7fc3c05c9cb0>(1)\n +      where <built-in method group of _sre.SRE_Match object at 0x7fc3c05c9cb0> = <_sre.SRE_Match object at 0x7fc3c05c9cb0>.group",) in <bound method ApplDbValidator.__del__ of <conftest.ApplDbValidator object at 0x7fc3c0690b90>> ignored
PASSED                                                                                                                    [ 25%]
test_port_dpb_vlan.py::TestPortDPBVlan::test_one_port_one_vlan PASSED                                                                                                             [ 50%]
test_port_dpb_vlan.py::TestPortDPBVlan::test_one_port_multiple_vlan PASSED                                                                                                        [ 75%]
test_port_dpb_vlan.py::TestPortDPBVlan::test_all_port_10_vlans PASSED                                                                                                             [100%]Exception AssertionError: AssertionError(u"assert 0 > 0\n +  where 0 = int('0')\n +    where '0' = <built-in method group of _sre.SRE_Match object at 0x7fc3c05bc8b0>(1)\n +      where <built-in method group of _sre.SRE_Match object at 0x7fc3c05bc8b0> = <_sre.SRE_Match object at 0x7fc3c05bc8b0>.group",) in <bound method ApplDbValidator.__del__ of <conftest.ApplDbValidator object at 0x7fc3c0661490>> ignored


============================================================================== 4 passed in 299.05 seconds ===============================================================================
vapatil@server09:~/workspace/DPB/sonic-buildimage/src/sonic-swss/tests$

@vasant17 vasant17 force-pushed the DPB_VLAN_TEST_CASE_AND_FLUSH_FDB branch from 9dbd861 to 47793d4 Compare April 6, 2020 22:35
@lguohan
Copy link
Contributor

lguohan commented Apr 8, 2020

retest this please

@lguohan
Copy link
Contributor

lguohan commented Apr 12, 2020

please use the new test assert api. check with @daall 's recent pr

@vasant17
Copy link
Contributor Author

please use the new test assert api. check with @daall 's recent pr

Could you please provide me the PR# and if possible elaborate on what API you are talking abiut

@lgtm-com
Copy link

lgtm-com bot commented May 7, 2020

This pull request introduces 10 alerts when merging 90141af into bfaadcd - view on LGTM.com

new alerts:

  • 6 for Unused import
  • 2 for Unused local variable
  • 1 for First parameter of a method is not named 'self'
  • 1 for 'import *' may pollute namespace

@vasant17 vasant17 force-pushed the DPB_VLAN_TEST_CASE_AND_FLUSH_FDB branch 3 times, most recently from fe5eeb0 to 1c656d9 Compare May 7, 2020 20:23
@vasant17
Copy link
Contributor Author

retest this please

@zhenggen-xu zhenggen-xu requested a review from daall May 11, 2020 21:12
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.

See comments. I mostly focused on the testing code. @prsunny can you help verify the FDB changes?

orchagent/fdborch.cpp Outdated Show resolved Hide resolved
tests/dvslib/dvs_vlan.py Outdated Show resolved Hide resolved
tests/test_port_dpb_vlan.py Show resolved Hide resolved
tests/test_port_dpb_vlan.py Outdated Show resolved Hide resolved
tests/test_port_dpb_vlan.py Outdated Show resolved Hide resolved
assert(p.exists_in_asic_db() == True)

self.dvs_vlan.remove_vlan_member(vlan, p.get_name())
time.sleep(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

If I'm understanding the flow correctly then I think this sleep can be replaced by waiting for the vlan member to be deleted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This sleep was NOT there to wait for VLAN member to be deleted. Instead, when we remove port from VLAN member, port dependency gets removed and the ports gets deleted. Then we can verify that port is deleted from ASIC DB. This was correct. But anyways, I have introduced "not_exists_in_asic_db()" method in port_dpb.py class which uses the wai_for_deleted_entry() function to verify that port is deleted.

Since we are here, I have a questions for you. I saw that you have introduced field, value match method (wait_for_field_match()). Can we introduce one for just field. Why I am asking is:

Suppose I want to verify that port is added to to PORT_NAME_MAP key in counter DB, I can use it. Similary wait_for_field_delete_entry().

Copy link
Contributor

Choose a reason for hiding this comment

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

That could work! I'm wondering if it might be cleaner to support "don't cares" or even wild carding rather than adding another method.

@daall daall requested a review from prsunny May 12, 2020 19:16
@vasant17 vasant17 force-pushed the DPB_VLAN_TEST_CASE_AND_FLUSH_FDB branch 2 times, most recently from 7cd3814 to f4023f6 Compare May 14, 2020 08:23
@lgtm-com
Copy link

lgtm-com bot commented May 14, 2020

This pull request introduces 1 alert when merging f4023f6 into 727a518 - view on LGTM.com

new alerts:

  • 1 for Unused import

@vasant17 vasant17 force-pushed the DPB_VLAN_TEST_CASE_AND_FLUSH_FDB branch from f4023f6 to ed7a3a5 Compare May 14, 2020 17:07
orchagent/fdborch.cpp Outdated Show resolved Hide resolved

SWSS_LOG_INFO("Flushing FDB bridge_port_oid: 0x%" PRIx64 ", and bvid_oid:0x%" PRIx64 ".", bridge_port_oid, vlan_oid);

rv = sai_fdb_api->flush_fdb_entries(gSwitchId, (uint32_t)attrs.size(), attrs.data());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Need CRM counters update. Can you check?

@@ -3983,3 +3997,22 @@ void PortsOrch::getPortSerdesVal(const std::string& val_str,
lane_values.push_back(lane_val);
}
}

void PortsOrch::flushFDBEntries(sai_object_id_t bridge_port_id)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is flushFDBEntries in portsorch? IMO, this should be handled in fdborch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. I cherrypicked these changes. Is it ok if I handle it in next PR or you insist on doing it in this PR?

Copy link
Collaborator

@prsunny prsunny May 28, 2020

Choose a reason for hiding this comment

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

I think it is better to handle it in this PR itself. The functionality doesn't fit correctly in portsorch

attr.id = SAI_FDB_FLUSH_ATTR_BRIDGE_PORT_ID;
attr.value.oid = bridge_port_id;
attrs.push_back(attr);
rv = sai_fdb_api->flush_fdb_entries(gSwitchId, (uint32_t)attrs.size(), attrs.data());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing CRM counter update

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are updated on receiving flush notification in function storeFdbEntryState()

@qiluo-msft
Copy link
Contributor

Could you fix the build? It is blocking vs and also LGTM checker.

@vasant17
Copy link
Contributor Author

vasant17 commented May 29, 2020 via email

@vasant17 vasant17 force-pushed the DPB_VLAN_TEST_CASE_AND_FLUSH_FDB branch 3 times, most recently from fb3994a to 63fc891 Compare May 30, 2020 02:22

gNeighOrch->ifChangeInformNextHop(alias,
(operation_status == "down") ?
false : true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it the same as operation_status != "down" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you simplify the code as I mentioned?


In reply to: 433554505 [](ancestors = 433554505)

{
gNeighOrch->ifChangeInformNextHop(alias, true);
operation_status_changed = (string_oper_status.at(operation_status) != lag.m_oper_status) ?
true : false;
Copy link
Contributor

Choose a reason for hiding this comment

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

true : false; [](start = 50, length = 14)

remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry I dint get what to remove. Could you please elaborate?

Copy link
Contributor

Choose a reason for hiding this comment

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

Remove ? true : false. The original bool statement is good enough.


In reply to: 433554653 [](ancestors = 433554653)

Copy link
Contributor

@qiluo-msft qiluo-msft left a comment

Choose a reason for hiding this comment

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

As comments

zhenggen-xu and others added 7 commits June 6, 2020 13:58
* Flush fdb entries when port/LAG is operational down

Signed-off-by: Zhenggen Xu <zxu@linkedin.com>

* Added vs-test cases, fixed one bug and addressed review feedback

Signed-off-by: Zhenggen Xu <zxu@linkedin.com>
* FIX bugs and add VLAN scale test

* Code-review comments addressed

* Addressed code-review comments

Co-authored-by: Vasant <vapatil@linkedin.com>
@vasant17 vasant17 force-pushed the DPB_VLAN_TEST_CASE_AND_FLUSH_FDB branch from 63fc891 to 8e4ab1e Compare June 6, 2020 22:27
@vasant17 vasant17 requested a review from qiluo-msft June 7, 2020 01:11
qiluo-msft
qiluo-msft previously approved these changes Jun 9, 2020
Copy link
Contributor

@qiluo-msft qiluo-msft left a comment

Choose a reason for hiding this comment

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

LGTM. Please also check with other reviewers.

@vasant17
Copy link
Contributor Author

vasant17 commented Jun 9, 2020

retest this please

daall
daall previously approved these changes Jun 9, 2020
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.

One minor nitpick, rest LGTM.

Comment on lines 33 to 49
def create_port_channel(self, lag_id, admin_status="up", mtu="1500"):
lag = "PortChannel{}".format(lag_id)
lag_entry = {"admin_status": admin_status, "mtu": mtu}
self.config_db.create_entry("PORTCHANNEL", lag, lag_entry)

def remove_port_channel(self, lag_id):
lag = "PortChannel{}".format(lag_id)
self.config_db.delete_entry("PORTCHANNEL", lag)

def create_port_channel_member(self, lag_id, interface):
member = "PortChannel{}|{}".format(lag_id, interface)
member_entry = {"NULL": "NULL"}
self.config_db.create_entry("PORTCHANNEL_MEMBER", member, member_entry)

def remove_port_channel_member(self, lag_id, interface):
member = "PortChannel{}|{}".format(lag_id, interface)
self.config_db.delete_entry("PORTCHANNEL_MEMBER", member)
Copy link
Contributor

Choose a reason for hiding this comment

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

These were moved to dvs_lag so can we delete them from here?

@vasant17 vasant17 dismissed stale reviews from daall and qiluo-msft via a5dedc2 June 10, 2020 00:10
@vasant17
Copy link
Contributor Author

retest this please

@prsunny prsunny merged commit 2127fb9 into sonic-net:master Jun 10, 2020
@vasant17
Copy link
Contributor Author

vasant17 commented Jun 10, 2020 via email

EdenGri pushed a commit to EdenGri/sonic-swss that referenced this pull request Feb 28, 2022
…mponent fw updates (sonic-net#1242)

- What I did
Add the support for the automatic platform component fw updates
- How I did it
Add fwutil auto_update interfaces
- How to verify it
Work with dell to verify the auto_update interfaces with ssd firmware update.
- Previous command output (if the output of a command-line utility has changed)
- New command output (if the output of a command-line utility has changed)
New added command outputs are available in the following HLD:
sonic-net/SONiC#648
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.

6 participants