Skip to content

Commit

Permalink
[vlan] Add pytest cases to validate nonexistent vlan behavior. (sonic…
Browse files Browse the repository at this point in the history
…-net#874)

* [vlan] Add pytest cases to validate nonexistent vlan behavior.

Signed-off-by: Emma Lin <emma_lin@edge-core.com>
  • Loading branch information
linemma authored and lguohan committed Jun 19, 2019
1 parent d9314dd commit 3f93ee3
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/test_vlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,50 @@ def test_AddVlanWithIncorrectValueType(self, dvs, testlog, test_input, expected)
#remove vlan
self.remove_vlan(vlan)

def test_AddVlanMemberWithNonExistVlan(self, dvs, testlog):
self.setup_db(dvs)
marker = dvs.add_log_marker()
vlan = "2"

# create vlan member
self.create_vlan_member(vlan, "Ethernet0")

# check asic database
tbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_VLAN")
vlan_entries = [k for k in tbl.getKeys() if k != dvs.asicdb.default_vlan_id]
assert len(vlan_entries) == 0

tbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_VLAN_MEMBER")
vlan_member_entries = tbl.getKeys()
assert len(vlan_member_entries) == 0

# remove vlan member from cfgdb
self.remove_vlan_member(vlan, "Ethernet0")

def test_RemoveNonexistentVlan(self, dvs, testlog):
self.setup_db(dvs)
marker = dvs.add_log_marker()
vlan = "2"

# check asic database
tbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_VLAN")
vlan_entries = [k for k in tbl.getKeys() if k != dvs.asicdb.default_vlan_id]
assert len(vlan_entries) == 0

# remove nonexistent vlan
self.remove_vlan(vlan)

# create vlan
self.create_vlan(vlan)

# check asic database
tbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_VLAN")
vlan_entries = [k for k in tbl.getKeys() if k != dvs.asicdb.default_vlan_id]
assert len(vlan_entries) == 1

# remove vlan
self.remove_vlan(vlan)

@pytest.mark.skip(reason="AddMaxVlan take too long to execute")
def test_AddMaxVlan(self, dvs, testlog):
self.setup_db(dvs)
Expand Down

0 comments on commit 3f93ee3

Please sign in to comment.