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

[vlan] Revise sleep time for pytest case "test_addMaxVlan". #904

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions tests/test_vlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ def setup_db(self, dvs):
self.adb = swsscommon.DBConnector(1, dvs.redis_sock, 0)
self.cdb = swsscommon.DBConnector(4, dvs.redis_sock, 0)

def create_vlan(self, vlan):
def create_vlan(self, vlan, sleep=1):
tbl = swsscommon.Table(self.cdb, "VLAN")
fvs = swsscommon.FieldValuePairs([("vlanid", vlan)])
tbl.set("Vlan" + vlan, fvs)
time.sleep(1)
time.sleep(sleep)

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

def create_vlan_member(self, vlan, interface):
tbl = swsscommon.Table(self.cdb, "VLAN_MEMBER")
Expand Down Expand Up @@ -251,7 +251,6 @@ def test_AddVlanWithIncorrectValueType(self, dvs, testlog, test_input, expected)
#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 All @@ -261,8 +260,9 @@ def test_AddMaxVlan(self, dvs, testlog):
# create max vlan
vlan = min_vid
while vlan <= max_vid:
self.create_vlan(str(vlan))
self.create_vlan(str(vlan), 0)
vlan += 1
time.sleep(600)
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need to sleep for 10 minutes?

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 skip the sleep on create_vlan and remove_vlan function to shorten the test time. And call time.sleep to wait for the system to become stable after create/remove vlan.

I am waiting the test results on Jenkins. It seems 240 seconds does not enough to finish the test on 1st commit, so I extend the sleep time (10 minutes) to retest to check if the sleep time is enough or not

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lguohan The test is passed, it seems 10 minutes can finish the test. I will try other sleep time to find the most short time for the test.

test_vlan.py::TestVlan::test_AddMaxVlan PASSED [ 83%]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lguohan, @stcheng the final test time is :

  • take 6 minutes to add 4k vlan
  • take 7 minutes to remove 4k vlan

The test result of all VLAN cases are PASSED.
test_vlan.py::TestVlan::test_VlanAddRemove PASSED [ 75%]
test_vlan.py::TestVlan::test_MultipleVlan PASSED [ 76%]
test_vlan.py::TestVlan::test_AddVlanWithIncorrectKeyPrefix[test_input0-0] PASSED [ 77%]
test_vlan.py::TestVlan::test_AddVlanWithIncorrectKeyPrefix[test_input1-0] PASSED [ 78%]
test_vlan.py::TestVlan::test_AddVlanWithIncorrectKeyPrefix[test_input2-0] PASSED [ 79%]
test_vlan.py::TestVlan::test_AddVlanWithIncorrectKeyPrefix[test_input3-1] PASSED [ 79%]
test_vlan.py::TestVlan::test_AddVlanWithIncorrectValueType[test_input0-0] PASSED [ 80%]
test_vlan.py::TestVlan::test_AddVlanWithIncorrectValueType[test_input1-0] PASSED [ 81%]
test_vlan.py::TestVlan::test_AddVlanWithIncorrectValueType[test_input2-0] PASSED [ 82%]
test_vlan.py::TestVlan::test_AddVlanWithIncorrectValueType[test_input3-1] PASSED [ 83%]
test_vlan.py::TestVlan::test_AddMaxVlan PASSED [ 83%]


# check asic database
tbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_VLAN")
Expand All @@ -272,8 +272,9 @@ def test_AddMaxVlan(self, dvs, testlog):
# remove all vlan
vlan = min_vid
while vlan <= max_vid:
self.remove_vlan(str(vlan))
self.remove_vlan(str(vlan), 0)
vlan += 1
time.sleep(600)

# check asic database
tbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_VLAN")
Expand Down