Skip to content

Commit

Permalink
[VS]: fix occasional test_fdb_notifications vs test failure (sonic-ne…
Browse files Browse the repository at this point in the history
…t#813)

* [VS]: fix occasional test_fdb_notifications vs test failure

Signed-off-by: Jipan Yang <jipan.yang@alibaba-inc.com>

* [VS]: add remove_vlan() and remove_vlan_member() dvs member functions

Signed-off-by: Jipan Yang <jipan.yang@alibaba-inc.com>

* Update comments and remove duplicate check

Signed-off-by: Jipan Yang <jipan.yang@alibaba-inc.com>
  • Loading branch information
jipanyang authored and lguohan committed Mar 22, 2019
1 parent ea54825 commit a937f92
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 19 deletions.
10 changes: 10 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,16 @@ def create_vlan_member_tagged(self, vlan, interface):
tbl.set("Vlan" + vlan + "|" + interface, fvs)
time.sleep(1)

def remove_vlan_member(self, vlan, interface):
tbl = swsscommon.Table(self.cdb, "VLAN_MEMBER")
tbl._del("Vlan" + vlan + "|" + interface)
time.sleep(1)

def remove_vlan(self, vlan):
tbl = swsscommon.Table(self.cdb, "VLAN")
tbl._del("Vlan" + vlan)
time.sleep(1)

def set_interface_status(self, interface, admin_status):
if interface.startswith("PortChannel"):
tbl_name = "PORTCHANNEL"
Expand Down
23 changes: 7 additions & 16 deletions tests/test_fdb_cold.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,8 @@ def test_FDBAddedAfterMemberCreated(dvs, testlog):
vm_before = how_many_entries_exist(dvs.adb, "ASIC_STATE:SAI_OBJECT_TYPE_VLAN_MEMBER")

# create vlan
create_entry_tbl(
dvs.cdb,
"VLAN", "Vlan2",
[
("vlanid", "2"),
]
)

# create vlan member entry in application db
create_entry_tbl(
dvs.cdb,
"VLAN_MEMBER", "Vlan2|Ethernet0",
[
("tagging_mode", "untagged"),
]
)
dvs.create_vlan("2")
dvs.create_vlan_member("2", "Ethernet0")

# check that the vlan information was propagated
vlan_after = how_many_entries_exist(dvs.adb, "ASIC_STATE:SAI_OBJECT_TYPE_VLAN")
Expand All @@ -87,3 +73,8 @@ def test_FDBAddedAfterMemberCreated(dvs, testlog):
('SAI_FDB_ENTRY_ATTR_PACKET_ACTION', 'SAI_PACKET_ACTION_FORWARD')]
)
assert ok, str(extra)

dvs.runcmd("sonic-clear fdb all")
dvs.remove_vlan_member("2", "Ethernet0")
dvs.remove_vlan("2")

43 changes: 40 additions & 3 deletions tests/test_fdb_warm.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,13 @@ def test_fdb_notifications(dvs, testlog):

# bring up vlan and member
dvs.set_interface_status("Vlan6", "up")
dvs.set_interface_status("Vlan7", "up")
dvs.set_interface_status("Vlan8", "up")

dvs.add_ip_address("Vlan6", "6.6.6.1/24")
dvs.add_ip_address("Vlan7", "7.7.7.1/24")
dvs.add_ip_address("Vlan8", "8.8.8.1/24")

dvs.set_interface_status("Ethernet64", "up")
dvs.set_interface_status("Ethernet68", "up")
dvs.set_interface_status("Ethernet72", "up")
Expand All @@ -101,6 +106,11 @@ def test_fdb_notifications(dvs, testlog):
dvs.servers[19].runcmd("ifconfig eth0.8 8.8.8.7/24 up")
dvs.servers[19].runcmd("ip route add default via 8.8.8.1")

dvs.servers[18].runcmd("ifconfig eth0 7.7.7.6/24 up")
dvs.servers[18].runcmd("ip route add default via 7.7.7.1")
dvs.servers[19].runcmd("ifconfig eth0 7.7.7.7/24 up")
dvs.servers[19].runcmd("ip route add default via 7.7.7.1")

# get neighbor and arp entry
time.sleep(2)
rc = dvs.servers[16].runcmd("ping -c 1 6.6.6.7")
Expand All @@ -115,6 +125,11 @@ def test_fdb_notifications(dvs, testlog):
rc = dvs.servers[19].runcmd("ping -c 1 8.8.8.6")
assert rc == 0

time.sleep(2)
rc = dvs.servers[18].runcmd("ping -c 1 -I 7.7.7.6 7.7.7.7")
assert rc == 0
rc = dvs.servers[19].runcmd("ping -c 1 -I 7.7.7.7 7.7.7.6")
assert rc == 0

# check that the FDB entries were inserted into ASIC DB
ok, extra = dvs.is_fdb_entry_exists(dvs.adb, "ASIC_STATE:SAI_OBJECT_TYPE_FDB_ENTRY",
Expand Down Expand Up @@ -149,9 +164,13 @@ def test_fdb_notifications(dvs, testlog):

time.sleep(2)
counter_inserted = dvs.getCrmCounterValue('STATS', 'crm_stats_fdb_entry_used')
assert counter_inserted - counter_before == 4
# vlan 6: Ethernet64, Ethernet68;
# vlan 7: Ethernet72, Ethernet76;
# vlan 8 (tagged): Ethernet72, Ethernet76;
# 6 FDB entries wil be created in total
assert counter_inserted - counter_before == 6

# check that the FDB entries were inserted into State DB
# check that the FDB entries were inserted into State DB for Ethernet64, Ethernet68 with Vlan6
ok, extra = dvs.is_table_entry_exists(dvs.sdb, "FDB_TABLE",
"Vlan6:.*",
[("port", "Ethernet64"),
Expand All @@ -167,7 +186,25 @@ def test_fdb_notifications(dvs, testlog):
)
assert ok, str(extra)

# check that the FDB entries were inserted into State DB, Vlan8 while not Vlan7(untagged) in the key
# check that the FDB entries were inserted into State DB,
# Vlan7(untagged) in the key for Ethernet72, Ethernet76
ok, extra = dvs.is_table_entry_exists(dvs.sdb, "FDB_TABLE",
"Vlan7:.*",
[("port", "Ethernet72"),
("type", "dynamic"),
]
)
assert ok, str(extra)
ok, extra = dvs.is_table_entry_exists(dvs.sdb, "FDB_TABLE",
"Vlan7:*",
[("port", "Ethernet76"),
("type", "dynamic"),
]
)
assert ok, str(extra)

# check that the FDB entries were inserted into State DB,
# Vlan8 (tagged) in the key for Ethernet72, Ethernet76
ok, extra = dvs.is_table_entry_exists(dvs.sdb, "FDB_TABLE",
"Vlan8:.*",
[("port", "Ethernet72"),
Expand Down

0 comments on commit a937f92

Please sign in to comment.