make test: fix packet counter assert
Change-Id: Ic6e6ac0629bbf07f7dad1803a85aabfdccbc2035
Signed-off-by: Klement Sekera <ksekera@cisco.com>
diff --git a/test/framework.py b/test/framework.py
index 85bd661..efb1e6b 100644
--- a/test/framework.py
+++ b/test/framework.py
@@ -144,12 +144,14 @@
def _is_skip_aarch64_set():
return os.getenv('SKIP_AARCH64', 'n').lower() in ('yes', 'y', '1')
+
is_skip_aarch64_set = _is_skip_aarch64_set()
def _is_platform_aarch64():
return platform.machine() == 'aarch64'
+
is_platform_aarch64 = _is_platform_aarch64()
@@ -157,6 +159,7 @@
s = os.getenv("EXTENDED_TESTS", "n")
return True if s.lower() in ("y", "yes", "1") else False
+
running_extended_tests = _running_extended_tests()
@@ -164,6 +167,7 @@
os_id = os.getenv("OS_ID", "")
return True if "centos" in os_id.lower() else False
+
running_on_centos = _running_on_centos
@@ -926,8 +930,8 @@
for cf in checksum_fields:
if hasattr(layer, cf):
if ignore_zero_udp_checksums and \
- 0 == getattr(layer, cf) and \
- layer.name in udp_layers:
+ 0 == getattr(layer, cf) and \
+ layer.name in udp_layers:
continue
delattr(layer, cf)
checksums.append((counter, cf))
@@ -1005,7 +1009,7 @@
counter_value = self.statistics.get_counter(counter)
else:
counters = self.vapi.cli("sh errors").split('\n')
- counter_value = -1
+ counter_value = 0
for i in range(1, len(counters) - 1):
results = counters[i].split()
if results[1] == counter:
@@ -1014,18 +1018,9 @@
return counter_value
def assert_packet_counter_equal(self, counter, expected_value):
- if counter.startswith("/"):
- counter_value = self.statistics.get_counter(counter)
- self.assert_equal(counter_value, expected_value,
- "packet counter `%s'" % counter)
- else:
- counters = self.vapi.cli("sh errors").split('\n')
- counter_value = -1
- for i in range(1, len(counters) - 1):
- results = counters[i].split()
- if results[1] == counter:
- counter_value = int(results[0])
- break
+ counter_value = self.get_packet_counter(counter)
+ self.assert_equal(counter_value, expected_value,
+ "packet counter `%s'" % counter)
def assert_error_counter_equal(self, counter, expected_value):
counter_value = self.statistics.get_err_counter(counter)
@@ -1455,5 +1450,6 @@
self.logger.info(single_line_delim)
self.result = self.process.returncode
+
if __name__ == '__main__':
pass
diff --git a/test/template_ipsec.py b/test/template_ipsec.py
index 84b8784..87565ed 100644
--- a/test/template_ipsec.py
+++ b/test/template_ipsec.py
@@ -527,7 +527,9 @@
class IpsecTun4(object):
""" verify methods for Tunnel v4 """
- def verify_counters(self, p, count):
+ def verify_counters4(self, p, count, n_frags=None):
+ if not n_frags:
+ n_frags = count
if (hasattr(p, "spd_policy_in_any")):
pkts = p.spd_policy_in_any.get_stats()['packets']
self.assertEqual(pkts, count,
@@ -544,7 +546,7 @@
"incorrect SA out counts: expected %d != %d" %
(count, pkts))
- self.assert_packet_counter_equal(self.tun4_encrypt_node_name, count)
+ self.assert_packet_counter_equal(self.tun4_encrypt_node_name, n_frags)
self.assert_packet_counter_equal(self.tun4_decrypt_node_name, count)
def verify_decrypted(self, p, rxs):
@@ -600,7 +602,7 @@
self.logger.info(self.vapi.ppcli("show error"))
self.logger.info(self.vapi.ppcli("show ipsec all"))
- self.verify_counters(p, count)
+ self.verify_counters4(p, count, n_rx)
def verify_tun_64(self, p, count=1):
self.vapi.cli("clear errors")
@@ -638,7 +640,7 @@
self.logger.info(self.vapi.ppcli("show error"))
self.logger.info(self.vapi.ppcli("show ipsec all"))
- self.verify_counters(p, count)
+ self.verify_counters4(p, count)
class IpsecTun4Tests(IpsecTun4):
@@ -654,7 +656,7 @@
class IpsecTun6(object):
""" verify methods for Tunnel v6 """
- def verify_counters(self, p, count):
+ def verify_counters6(self, p, count):
if (hasattr(p, "tun_sa_in")):
pkts = p.tun_sa_in.get_stats()['packets']
self.assertEqual(pkts, count,
@@ -706,7 +708,7 @@
finally:
self.logger.info(self.vapi.ppcli("show error"))
self.logger.info(self.vapi.ppcli("show ipsec all"))
- self.verify_counters(p, count)
+ self.verify_counters6(p, count)
def verify_tun_46(self, p, count=1):
""" ipsec 4o6 tunnel basic test """
@@ -745,7 +747,7 @@
finally:
self.logger.info(self.vapi.ppcli("show error"))
self.logger.info(self.vapi.ppcli("show ipsec all"))
- self.verify_counters(p, count)
+ self.verify_counters6(p, count)
class IpsecTun6Tests(IpsecTun6):
diff --git a/test/test_ipsec_tun_if_esp.py b/test/test_ipsec_tun_if_esp.py
index 8f1bd7c..47b138f 100644
--- a/test/test_ipsec_tun_if_esp.py
+++ b/test/test_ipsec_tun_if_esp.py
@@ -64,19 +64,25 @@
class TestIpsec4TunIfEsp1(TemplateIpsec4TunIfEsp, IpsecTun4Tests):
""" Ipsec ESP - TUN tests """
- tun4_encrypt_node_name = "esp4-encrypt"
+ tun4_encrypt_node_name = "esp4-encrypt-tun"
tun4_decrypt_node_name = "esp4-decrypt"
def test_tun_basic64(self):
""" ipsec 6o4 tunnel basic test """
+ self.tun4_encrypt_node_name = "esp6-encrypt-tun"
+
self.verify_tun_64(self.params[socket.AF_INET], count=1)
def test_tun_burst64(self):
""" ipsec 6o4 tunnel basic test """
+ self.tun4_encrypt_node_name = "esp6-encrypt-tun"
+
self.verify_tun_64(self.params[socket.AF_INET], count=257)
def test_tun_basic_frag44(self):
""" ipsec 4o4 tunnel frag basic test """
+ self.tun4_encrypt_node_name = "esp4-encrypt-tun"
+
p = self.ipv4_params
self.vapi.sw_interface_set_mtu(p.tun_if.sw_if_index,
@@ -130,15 +136,17 @@
class TestIpsec6TunIfEsp1(TemplateIpsec6TunIfEsp, IpsecTun6Tests):
""" Ipsec ESP - TUN tests """
- tun6_encrypt_node_name = "esp6-encrypt"
+ tun6_encrypt_node_name = "esp6-encrypt-tun"
tun6_decrypt_node_name = "esp6-decrypt"
def test_tun_basic46(self):
""" ipsec 4o6 tunnel basic test """
+ self.tun6_encrypt_node_name = "esp4-encrypt-tun"
self.verify_tun_46(self.params[socket.AF_INET6], count=1)
def test_tun_burst46(self):
""" ipsec 4o6 tunnel burst test """
+ self.tun6_encrypt_node_name = "esp4-encrypt-tun"
self.verify_tun_46(self.params[socket.AF_INET6], count=257)
@@ -146,7 +154,7 @@
""" IPsec IPv4 Multi Tunnel interface """
encryption_type = ESP
- tun4_encrypt_node_name = "esp4-encrypt"
+ tun4_encrypt_node_name = "esp4-encrypt-tun"
tun4_decrypt_node_name = "esp4-decrypt"
def setUp(self):
@@ -206,7 +214,7 @@
""" IPsec IPv4 Tunnel interface all Algos """
encryption_type = ESP
- tun4_encrypt_node_name = "esp4-encrypt"
+ tun4_encrypt_node_name = "esp4-encrypt-tun"
tun4_decrypt_node_name = "esp4-decrypt"
def config_network(self, p):
@@ -388,7 +396,7 @@
""" IPsec IPv6 Multi Tunnel interface """
encryption_type = ESP
- tun6_encrypt_node_name = "esp6-encrypt"
+ tun6_encrypt_node_name = "esp6-encrypt-tun"
tun6_decrypt_node_name = "esp6-decrypt"
def setUp(self):