Skip to content

Commit

Permalink
[vstest]: Update Route test to check for added entry (sonic-net#1088)
Browse files Browse the repository at this point in the history
* Update Route test to check for added entry

* check_syslog (awk) is taking ~2 seconds, in which an extra log can get generated
  • Loading branch information
prsunny authored and lguohan committed Oct 11, 2019
1 parent e658b64 commit 4c10260
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
36 changes: 18 additions & 18 deletions tests/test_crm.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ def test_CrmFdbEntry(self, dvs, testlog):
assert new_avail_counter == avail_counter

marker = dvs.add_log_marker()
dvs.runcmd("crm config polling interval 2")
dvs.runcmd("crm config polling interval 3")
dvs.runcmd("crm config thresholds fdb high 90")
dvs.runcmd("crm config thresholds fdb type free")
time.sleep(2)
time.sleep(3)
check_syslog(dvs, marker, "FDB_ENTRY THRESHOLD_EXCEEDED for TH_FREE", 1)

# enable ipv6 on server 2
Expand Down Expand Up @@ -183,10 +183,10 @@ def test_CrmIpv4Route(self, dvs, testlog):
assert new_avail_counter == avail_counter

marker = dvs.add_log_marker()
dvs.runcmd("crm config polling interval 2")
dvs.runcmd("crm config polling interval 3")
dvs.runcmd("crm config thresholds ipv4 route high 90")
dvs.runcmd("crm config thresholds ipv4 route type free")
time.sleep(2)
time.sleep(3)
check_syslog(dvs, marker, "IPV4_ROUTE THRESHOLD_EXCEEDED for TH_FREE",1)

intf_tbl._del("Ethernet0|10.0.0.0/31")
Expand Down Expand Up @@ -253,10 +253,10 @@ def test_CrmIpv6Route(self, dvs, testlog):
assert new_avail_counter == avail_counter

marker = dvs.add_log_marker()
dvs.runcmd("crm config polling interval 2")
dvs.runcmd("crm config polling interval 3")
dvs.runcmd("crm config thresholds ipv6 route high 90")
dvs.runcmd("crm config thresholds ipv6 route type free")
time.sleep(2)
time.sleep(3)
check_syslog(dvs, marker, "IPV6_ROUTE THRESHOLD_EXCEEDED for TH_FREE",1)

intf_tbl._del("Ethernet0|fc00::1/126")
Expand Down Expand Up @@ -308,10 +308,10 @@ def test_CrmIpv4Nexthop(self, dvs, testlog):
assert new_avail_counter == avail_counter

marker = dvs.add_log_marker()
dvs.runcmd("crm config polling interval 2")
dvs.runcmd("crm config polling interval 3")
dvs.runcmd("crm config thresholds ipv4 nexthop high 90")
dvs.runcmd("crm config thresholds ipv4 nexthop type free")
time.sleep(2)
time.sleep(3)
check_syslog(dvs, marker, "IPV4_NEXTHOP THRESHOLD_EXCEEDED for TH_FREE",1)

intf_tbl._del("Ethernet0|10.0.0.0/31")
Expand Down Expand Up @@ -367,10 +367,10 @@ def test_CrmIpv6Nexthop(self, dvs, testlog):
assert new_avail_counter == avail_counter

marker = dvs.add_log_marker()
dvs.runcmd("crm config polling interval 2")
dvs.runcmd("crm config polling interval 3")
dvs.runcmd("crm config thresholds ipv6 nexthop high 90")
dvs.runcmd("crm config thresholds ipv6 nexthop type free")
time.sleep(2)
time.sleep(3)
check_syslog(dvs, marker, "IPV6_NEXTHOP THRESHOLD_EXCEEDED for TH_FREE",1)

intf_tbl._del("Ethernet0|fc00::1/126")
Expand Down Expand Up @@ -422,10 +422,10 @@ def test_CrmIpv4Neighbor(self, dvs, testlog):
assert new_avail_counter == avail_counter

marker = dvs.add_log_marker()
dvs.runcmd("crm config polling interval 2")
dvs.runcmd("crm config polling interval 3")
dvs.runcmd("crm config thresholds ipv4 neighbor high 90")
dvs.runcmd("crm config thresholds ipv4 neighbor type free")
time.sleep(2)
time.sleep(3)
check_syslog(dvs, marker, "IPV4_NEIGHBOR THRESHOLD_EXCEEDED for TH_FREE",1)

intf_tbl._del("Ethernet0|10.0.0.0/31")
Expand Down Expand Up @@ -481,10 +481,10 @@ def test_CrmIpv6Neighbor(self, dvs, testlog):
assert new_avail_counter == avail_counter

marker = dvs.add_log_marker()
dvs.runcmd("crm config polling interval 2")
dvs.runcmd("crm config polling interval 3")
dvs.runcmd("crm config thresholds ipv6 neighbor high 90")
dvs.runcmd("crm config thresholds ipv6 neighbor type free")
time.sleep(2)
time.sleep(3)
check_syslog(dvs, marker, "IPV6_NEIGHBOR THRESHOLD_EXCEEDED for TH_FREE",1)

intf_tbl._del("Ethernet0|fc00::1/126")
Expand Down Expand Up @@ -549,10 +549,10 @@ def test_CrmNexthopGroup(self, dvs, testlog):
assert new_avail_counter == avail_counter

marker = dvs.add_log_marker()
dvs.runcmd("crm config polling interval 2")
dvs.runcmd("crm config polling interval 3")
dvs.runcmd("crm config thresholds nexthop group member high 90")
dvs.runcmd("crm config thresholds nexthop group object type free")
time.sleep(2)
time.sleep(3)
check_syslog(dvs, marker, "NEXTHOP_GROUP THRESHOLD_EXCEEDED for TH_FREE",1)

intf_tbl._del("Ethernet0|10.0.0.0/31")
Expand Down Expand Up @@ -624,10 +624,10 @@ def test_CrmNexthopGroupMember(self, dvs, testlog):
assert new_avail_counter == avail_counter

marker = dvs.add_log_marker()
dvs.runcmd("crm config polling interval 2")
dvs.runcmd("crm config polling interval 3")
dvs.runcmd("crm config thresholds nexthop group member high 90")
dvs.runcmd("crm config thresholds nexthop group member type free")
time.sleep(2)
time.sleep(3)
check_syslog(dvs, marker, "NEXTHOP_GROUP_MEMBER THRESHOLD_EXCEEDED for TH_FREE",1)

intf_tbl._del("Ethernet0|10.0.0.0/31")
Expand Down
14 changes: 11 additions & 3 deletions tests/test_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,16 @@ def test_RouteAdd(self, dvs, testlog):

(addobjs, delobjs) = dvs.GetSubscribedAsicDbObjects(pubsub)

assert len(addobjs) == 1
assert len(addobjs) >= 1

rt_key = json.loads(addobjs[0]['key'])
adb = swsscommon.DBConnector(swsscommon.ASIC_DB, dvs.redis_sock, 0)
atbl = swsscommon.Table(adb, "ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY")
keys = atbl.getKeys()
found = False

assert rt_key['dest'] == "2.2.2.0/24"
for key in keys:
route = json.loads(key)
if route['dest'] == "2.2.2.0/24":
found = True

assert found

0 comments on commit 4c10260

Please sign in to comment.