From 151396e8f14d309d4294754b57c72789de62e4fd Mon Sep 17 00:00:00 2001 From: iris Date: Fri, 19 Apr 2019 15:29:59 +0800 Subject: [PATCH 1/2] Add the tests of SWSS_LOG_WARN for CRM threshold by syslog checking. --- tests/test_crm.py | 83 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/tests/test_crm.py b/tests/test_crm.py index eeba6f5a4b..568665e9bc 100644 --- a/tests/test_crm.py +++ b/tests/test_crm.py @@ -95,6 +95,16 @@ def test_CrmFdbEntry(dvs, testlog): assert new_avail_counter == avail_counter + + dvs.runcmd("crm config polling interval 2") + dvs.runcmd("crm config thresholds fdb high 90") + dvs.runcmd("crm config thresholds fdb type free") + time.sleep(2) + + fileaString = dvs.runcmd("cat /var/log/syslog") + idPosition = fileaString[1].find("FDB_ENTRY THRESHOLD_EXCEEDED for TH_FREE") + assert idPosition != -1 + # enable ipv6 on server 2 dvs.servers[2].runcmd("sysctl -w net.ipv6.conf.eth0.disable_ipv6=0") @@ -150,6 +160,15 @@ def test_CrmIpv4Route(dvs, testlog): assert new_used_counter == used_counter assert new_avail_counter == avail_counter + dvs.runcmd("crm config polling interval 2") + dvs.runcmd("crm config thresholds ipv4 route high 90") + dvs.runcmd("crm config thresholds ipv4 route type free") + time.sleep(2) + + fileaString = dvs.runcmd_output("cat /var/log/syslog") + idPosition = fileaString.find("IPV4_ROUTE THRESHOLD_EXCEEDED for TH_FREE") + assert idPosition != -1 + intf_tbl._del("Ethernet0|10.0.0.0/31") time.sleep(2) @@ -213,6 +232,15 @@ def test_CrmIpv6Route(dvs, testlog): assert new_used_counter == used_counter assert new_avail_counter == avail_counter + dvs.runcmd("crm config polling interval 2") + dvs.runcmd("crm config thresholds ipv6 route high 90") + dvs.runcmd("crm config thresholds ipv6 route type free") + time.sleep(2) + + fileaString = dvs.runcmd("cat /var/log/syslog") + idPosition = fileaString[1].find("IPV6_ROUTE THRESHOLD_EXCEEDED for TH_FREE") + assert idPosition != -1 + intf_tbl._del("Ethernet0|fc00::1/126") time.sleep(2) @@ -261,6 +289,15 @@ def test_CrmIpv4Nexthop(dvs, testlog): assert new_used_counter == used_counter assert new_avail_counter == avail_counter + dvs.runcmd("crm config polling interval 2") + dvs.runcmd("crm config thresholds ipv4 nexthop high 90") + dvs.runcmd("crm config thresholds ipv4 nexthop type free") + time.sleep(2) + + fileaString = dvs.runcmd("cat /var/log/syslog") + idPosition = fileaString[1].find("IPV4_NEXTHOP THRESHOLD_EXCEEDED for TH_FREE") + assert idPosition != -1 + intf_tbl._del("Ethernet0|10.0.0.0/31") time.sleep(2) @@ -313,6 +350,15 @@ def test_CrmIpv6Nexthop(dvs, testlog): assert new_used_counter == used_counter assert new_avail_counter == avail_counter + dvs.runcmd("crm config polling interval 2") + dvs.runcmd("crm config thresholds ipv6 nexthop high 90") + dvs.runcmd("crm config thresholds ipv6 nexthop type free") + time.sleep(2) + + fileaString = dvs.runcmd("cat /var/log/syslog") + idPosition = fileaString[1].find("IPV6_NEXTHOP THRESHOLD_EXCEEDED for TH_FREE") + assert idPosition != -1 + intf_tbl._del("Ethernet0|fc00::1/126") time.sleep(2) @@ -361,6 +407,15 @@ def test_CrmIpv4Neighbor(dvs, testlog): assert new_used_counter == used_counter assert new_avail_counter == avail_counter + dvs.runcmd("crm config polling interval 2") + dvs.runcmd("crm config thresholds ipv4 neighbor high 90") + dvs.runcmd("crm config thresholds ipv4 neighbor type free") + time.sleep(2) + + fileaString = dvs.runcmd("cat /var/log/syslog") + idPosition = fileaString[1].find("IPV4_NEIGHBOR THRESHOLD_EXCEEDED for TH_FREE") + assert idPosition != -1 + intf_tbl._del("Ethernet0|10.0.0.0/31") time.sleep(2) @@ -413,6 +468,16 @@ def test_CrmIpv6Neighbor(dvs, testlog): assert new_used_counter == used_counter assert new_avail_counter == avail_counter + dvs.runcmd("crm config polling interval 2") + dvs.runcmd("crm config thresholds ipv6 neighbor high 90") + dvs.runcmd("crm config thresholds ipv6 neighbor type free") + time.sleep(2) + + fileaString = dvs.runcmd("cat /var/log/syslog") + idPosition = fileaString[1].find("IPV6_NEIGHBOR THRESHOLD_EXCEEDED for TH_FREE") + assert idPosition != -1 + + intf_tbl._del("Ethernet0|fc00::1/126") time.sleep(2) @@ -473,6 +538,15 @@ def test_CrmNexthopGroup(dvs, testlog): assert new_used_counter == used_counter assert new_avail_counter == avail_counter + dvs.runcmd("crm config polling interval 2") + dvs.runcmd("crm config thresholds nexthop group member high 90") + dvs.runcmd("crm config thresholds nexthop group object type free") + time.sleep(2) + + fileaString = dvs.runcmd("cat /var/log/syslog") + idPosition = fileaString[1].find("NEXTHOP_GROUP THRESHOLD_EXCEEDED for TH_FREE") + assert idPosition != -1 + intf_tbl._del("Ethernet0|10.0.0.0/31") intf_tbl._del("Ethernet4|10.0.0.2/31") time.sleep(2) @@ -540,6 +614,15 @@ def test_CrmNexthopGroupMember(dvs, testlog): assert new_used_counter == used_counter assert new_avail_counter == avail_counter + dvs.runcmd("crm config polling interval 2") + dvs.runcmd("crm config thresholds nexthop group member high 90") + dvs.runcmd("crm config thresholds nexthop group member type free") + time.sleep(2) + + fileaString = dvs.runcmd("cat /var/log/syslog") + idPosition = fileaString[1].find("NEXTHOP_GROUP_MEMBER THRESHOLD_EXCEEDED for TH_FREE") + assert idPosition != -1 + intf_tbl._del("Ethernet0|10.0.0.0/31") intf_tbl._del("Ethernet4|10.0.0.2/31") time.sleep(2) From ba3cca6da4dea9d3ef2e200b2833de76d8506319 Mon Sep 17 00:00:00 2001 From: iris Date: Tue, 23 Apr 2019 15:16:15 +0800 Subject: [PATCH 2/2] modify output strimg cmd from dvs.runcmd_output to dvs.runcmd. --- tests/test_crm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_crm.py b/tests/test_crm.py index 568665e9bc..babd90b165 100644 --- a/tests/test_crm.py +++ b/tests/test_crm.py @@ -165,7 +165,7 @@ def test_CrmIpv4Route(dvs, testlog): dvs.runcmd("crm config thresholds ipv4 route type free") time.sleep(2) - fileaString = dvs.runcmd_output("cat /var/log/syslog") + fileaString = dvs.runcmd("cat /var/log/syslog") idPosition = fileaString.find("IPV4_ROUTE THRESHOLD_EXCEEDED for TH_FREE") assert idPosition != -1