summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/framework.py2
-rw-r--r--test/template_ipsec.py5
-rw-r--r--test/test_ipsec_tun_if_esp.py144
-rw-r--r--test/test_stats_client.py4
-rw-r--r--test/vpp_interface.py8
-rw-r--r--test/vpp_neighbor.py2
6 files changed, 59 insertions, 106 deletions
diff --git a/test/framework.py b/test/framework.py
index 22a9509f030..f3c74ceec3e 100644
--- a/test/framework.py
+++ b/test/framework.py
@@ -1177,7 +1177,7 @@ class VppTestCase(unittest.TestCase):
"packet counter `%s'" % counter)
def assert_error_counter_equal(self, counter, expected_value):
- counter_value = self.statistics.get_err_counter(counter)
+ counter_value = self.statistics[counter].sum()
self.assert_equal(counter_value, expected_value,
"error counter `%s'" % counter)
diff --git a/test/template_ipsec.py b/test/template_ipsec.py
index 62271d33579..fd9d91f3cfb 100644
--- a/test/template_ipsec.py
+++ b/test/template_ipsec.py
@@ -328,8 +328,9 @@ class IpsecTra4(object):
p = self.params[socket.AF_INET]
esn_en = p.vpp_tra_sa.esn_en
- seq_cycle_node_name = ('/err/%s/sequence number cycled' %
- self.tra4_encrypt_node_name)
+ seq_cycle_node_name = \
+ ('/err/%s/sequence number cycled (packet dropped)' %
+ self.tra4_encrypt_node_name)
replay_count = self.get_replay_counts(p)
hash_failed_count = self.get_hash_failed_counts(p)
seq_cycle_count = self.statistics.get_err_counter(seq_cycle_node_name)
diff --git a/test/test_ipsec_tun_if_esp.py b/test/test_ipsec_tun_if_esp.py
index b72d464c663..6534dd66190 100644
--- a/test/test_ipsec_tun_if_esp.py
+++ b/test/test_ipsec_tun_if_esp.py
@@ -654,10 +654,8 @@ class TestIpsec4MultiTunIfEsp(TemplateIpsec4TunProtect,
"""Multiple IPSEC tunnel interfaces """
for p in self.multi_params:
self.verify_tun_44(p, count=127)
- c = p.tun_if.get_rx_stats()
- self.assertEqual(c['packets'], 127)
- c = p.tun_if.get_tx_stats()
- self.assertEqual(c['packets'], 127)
+ self.assertEqual(p.tun_if.get_rx_stats(), 127)
+ self.assertEqual(p.tun_if.get_tx_stats(), 127)
def test_tun_rr_44(self):
""" Round-robin packets acrros multiple interface """
@@ -929,10 +927,8 @@ class TestIpsec6MultiTunIfEsp(TemplateIpsec6TunProtect,
"""Multiple IPSEC tunnel interfaces """
for p in self.multi_params:
self.verify_tun_66(p, count=127)
- c = p.tun_if.get_rx_stats()
- self.assertEqual(c['packets'], 127)
- c = p.tun_if.get_tx_stats()
- self.assertEqual(c['packets'], 127)
+ self.assertEqual(p.tun_if.get_rx_stats(), 127)
+ self.assertEqual(p.tun_if.get_tx_stats(), 127)
class TestIpsecGreTebIfEsp(TemplateIpsec,
@@ -1997,17 +1993,13 @@ class TestIpsec4TunProtect(TemplateIpsec,
self.config_protect(p)
self.verify_tun_44(p, count=127)
- c = p.tun_if.get_rx_stats()
- self.assertEqual(c['packets'], 127)
- c = p.tun_if.get_tx_stats()
- self.assertEqual(c['packets'], 127)
+ self.assertEqual(p.tun_if.get_rx_stats(), 127)
+ self.assertEqual(p.tun_if.get_tx_stats(), 127)
self.vapi.cli("clear ipsec sa")
self.verify_tun_64(p, count=127)
- c = p.tun_if.get_rx_stats()
- self.assertEqual(c['packets'], 254)
- c = p.tun_if.get_tx_stats()
- self.assertEqual(c['packets'], 254)
+ self.assertEqual(p.tun_if.get_rx_stats(), 254)
+ self.assertEqual(p.tun_if.get_tx_stats(), 254)
# rekey - create new SAs and update the tunnel protection
np = copy.copy(p)
@@ -2024,10 +2016,8 @@ class TestIpsec4TunProtect(TemplateIpsec,
self.unconfig_sa(p)
self.verify_tun_44(np, count=127)
- c = p.tun_if.get_rx_stats()
- self.assertEqual(c['packets'], 381)
- c = p.tun_if.get_tx_stats()
- self.assertEqual(c['packets'], 381)
+ self.assertEqual(p.tun_if.get_rx_stats(), 381)
+ self.assertEqual(p.tun_if.get_tx_stats(), 381)
# teardown
self.unconfig_protect(np)
@@ -2074,10 +2064,8 @@ class TestIpsec4TunProtectUdp(TemplateIpsec,
p = self.ipv4_params
self.verify_tun_44(p, count=127)
- c = p.tun_if.get_rx_stats()
- self.assertEqual(c['packets'], 127)
- c = p.tun_if.get_tx_stats()
- self.assertEqual(c['packets'], 127)
+ self.assertEqual(p.tun_if.get_rx_stats(), 127)
+ self.assertEqual(p.tun_if.get_tx_stats(), 127)
def test_keepalive(self):
""" IPSEC NAT Keepalive """
@@ -2168,10 +2156,8 @@ class TestIpsec4TunProtectTun(TemplateIpsec,
self.verify_tun_44(p, count=127)
- c = p.tun_if.get_rx_stats()
- self.assertEqual(c['packets'], 127)
- c = p.tun_if.get_tx_stats()
- self.assertEqual(c['packets'], 127)
+ self.assertEqual(p.tun_if.get_rx_stats(), 127)
+ self.assertEqual(p.tun_if.get_tx_stats(), 127)
# rekey - create new SAs and update the tunnel protection
np = copy.copy(p)
@@ -2188,10 +2174,8 @@ class TestIpsec4TunProtectTun(TemplateIpsec,
self.unconfig_sa(p)
self.verify_tun_44(np, count=127)
- c = p.tun_if.get_rx_stats()
- self.assertEqual(c['packets'], 254)
- c = p.tun_if.get_tx_stats()
- self.assertEqual(c['packets'], 254)
+ self.assertEqual(p.tun_if.get_rx_stats(), 254)
+ self.assertEqual(p.tun_if.get_tx_stats(), 254)
# teardown
self.unconfig_protect(np)
@@ -2275,10 +2259,8 @@ class TestIpsec6TunProtect(TemplateIpsec,
self.config_protect(p)
self.verify_tun_66(p, count=127)
- c = p.tun_if.get_rx_stats()
- self.assertEqual(c['packets'], 127)
- c = p.tun_if.get_tx_stats()
- self.assertEqual(c['packets'], 127)
+ self.assertEqual(p.tun_if.get_rx_stats(), 127)
+ self.assertEqual(p.tun_if.get_tx_stats(), 127)
# rekey - create new SAs and update the tunnel protection
np = copy.copy(p)
@@ -2295,10 +2277,8 @@ class TestIpsec6TunProtect(TemplateIpsec,
self.unconfig_sa(p)
self.verify_tun_66(np, count=127)
- c = p.tun_if.get_rx_stats()
- self.assertEqual(c['packets'], 254)
- c = p.tun_if.get_tx_stats()
- self.assertEqual(c['packets'], 254)
+ self.assertEqual(p.tun_if.get_rx_stats(), 254)
+ self.assertEqual(p.tun_if.get_tx_stats(), 254)
# bounce the interface state
p.tun_if.admin_down()
@@ -2342,10 +2322,8 @@ class TestIpsec6TunProtect(TemplateIpsec,
self.verify_tun_66(np3, np3, count=127)
self.verify_drop_tun_66(np, count=127)
- c = p.tun_if.get_rx_stats()
- self.assertEqual(c['packets'], 127*9)
- c = p.tun_if.get_tx_stats()
- self.assertEqual(c['packets'], 127*8)
+ self.assertEqual(p.tun_if.get_rx_stats(), 127*9)
+ self.assertEqual(p.tun_if.get_tx_stats(), 127*8)
self.unconfig_sa(np)
# teardown
@@ -2363,10 +2341,8 @@ class TestIpsec6TunProtect(TemplateIpsec,
self.config_protect(p)
self.verify_tun_46(p, count=127)
- c = p.tun_if.get_rx_stats()
- self.assertEqual(c['packets'], 127)
- c = p.tun_if.get_tx_stats()
- self.assertEqual(c['packets'], 127)
+ self.assertEqual(p.tun_if.get_rx_stats(), 127)
+ self.assertEqual(p.tun_if.get_tx_stats(), 127)
# teardown
self.unconfig_protect(p)
@@ -2447,10 +2423,8 @@ class TestIpsec6TunProtectTun(TemplateIpsec,
self.verify_tun_66(p, count=127)
- c = p.tun_if.get_rx_stats()
- self.assertEqual(c['packets'], 127)
- c = p.tun_if.get_tx_stats()
- self.assertEqual(c['packets'], 127)
+ self.assertEqual(p.tun_if.get_rx_stats(), 127)
+ self.assertEqual(p.tun_if.get_tx_stats(), 127)
# rekey - create new SAs and update the tunnel protection
np = copy.copy(p)
@@ -2467,10 +2441,8 @@ class TestIpsec6TunProtectTun(TemplateIpsec,
self.unconfig_sa(p)
self.verify_tun_66(np, count=127)
- c = p.tun_if.get_rx_stats()
- self.assertEqual(c['packets'], 254)
- c = p.tun_if.get_tx_stats()
- self.assertEqual(c['packets'], 254)
+ self.assertEqual(p.tun_if.get_rx_stats(), 254)
+ self.assertEqual(p.tun_if.get_tx_stats(), 254)
# teardown
self.unconfig_protect(np)
@@ -2630,29 +2602,23 @@ class TestIpsecItf4(TemplateIpsec,
self.config_protect(p)
self.verify_tun_44(p, count=n_pkts)
- c = p.tun_if.get_rx_stats()
- self.assertEqual(c['packets'], n_pkts)
- c = p.tun_if.get_tx_stats()
- self.assertEqual(c['packets'], n_pkts)
+ self.assertEqual(p.tun_if.get_rx_stats(), n_pkts)
+ self.assertEqual(p.tun_if.get_tx_stats(), n_pkts)
p.tun_if.admin_down()
self.verify_tun_dropped_44(p, count=n_pkts)
p.tun_if.admin_up()
self.verify_tun_44(p, count=n_pkts)
- c = p.tun_if.get_rx_stats()
- self.assertEqual(c['packets'], 3*n_pkts)
- c = p.tun_if.get_tx_stats()
- self.assertEqual(c['packets'], 2*n_pkts)
+ self.assertEqual(p.tun_if.get_rx_stats(), 3*n_pkts)
+ self.assertEqual(p.tun_if.get_tx_stats(), 2*n_pkts)
# it's a v6 packet when its encrypted
self.tun4_encrypt_node_name = "esp6-encrypt-tun"
self.verify_tun_64(p, count=n_pkts)
- c = p.tun_if.get_rx_stats()
- self.assertEqual(c['packets'], 4*n_pkts)
- c = p.tun_if.get_tx_stats()
- self.assertEqual(c['packets'], 3*n_pkts)
+ self.assertEqual(p.tun_if.get_rx_stats(), 4*n_pkts)
+ self.assertEqual(p.tun_if.get_tx_stats(), 3*n_pkts)
self.tun4_encrypt_node_name = "esp4-encrypt-tun"
@@ -2675,10 +2641,8 @@ class TestIpsecItf4(TemplateIpsec,
self.unconfig_sa(p)
self.verify_tun_44(np, count=n_pkts)
- c = p.tun_if.get_rx_stats()
- self.assertEqual(c['packets'], n_pkts)
- c = p.tun_if.get_tx_stats()
- self.assertEqual(c['packets'], n_pkts)
+ self.assertEqual(p.tun_if.get_rx_stats(), n_pkts)
+ self.assertEqual(p.tun_if.get_tx_stats(), n_pkts)
# teardown
self.unconfig_protect(np)
@@ -2735,10 +2699,8 @@ class TestIpsecItf4(TemplateIpsec,
policer.apply_vpp_config(p.tun_if.sw_if_index, True)
self.verify_tun_44(p, count=n_pkts)
- c = p.tun_if.get_rx_stats()
- self.assertEqual(c['packets'], n_pkts)
- c = p.tun_if.get_tx_stats()
- self.assertEqual(c['packets'], n_pkts)
+ self.assertEqual(p.tun_if.get_rx_stats(), n_pkts)
+ self.assertEqual(p.tun_if.get_tx_stats(), n_pkts)
stats = policer.get_stats()
@@ -2942,29 +2904,23 @@ class TestIpsecItf6(TemplateIpsec,
self.config_protect(p)
self.verify_tun_66(p, count=n_pkts)
- c = p.tun_if.get_rx_stats()
- self.assertEqual(c['packets'], n_pkts)
- c = p.tun_if.get_tx_stats()
- self.assertEqual(c['packets'], n_pkts)
+ self.assertEqual(p.tun_if.get_rx_stats(), n_pkts)
+ self.assertEqual(p.tun_if.get_tx_stats(), n_pkts)
p.tun_if.admin_down()
self.verify_drop_tun_66(p, count=n_pkts)
p.tun_if.admin_up()
self.verify_tun_66(p, count=n_pkts)
- c = p.tun_if.get_rx_stats()
- self.assertEqual(c['packets'], 3*n_pkts)
- c = p.tun_if.get_tx_stats()
- self.assertEqual(c['packets'], 2*n_pkts)
+ self.assertEqual(p.tun_if.get_rx_stats(), 3*n_pkts)
+ self.assertEqual(p.tun_if.get_tx_stats(), 2*n_pkts)
# it's a v4 packet when its encrypted
self.tun6_encrypt_node_name = "esp4-encrypt-tun"
self.verify_tun_46(p, count=n_pkts)
- c = p.tun_if.get_rx_stats()
- self.assertEqual(c['packets'], 4*n_pkts)
- c = p.tun_if.get_tx_stats()
- self.assertEqual(c['packets'], 3*n_pkts)
+ self.assertEqual(p.tun_if.get_rx_stats(), 4*n_pkts)
+ self.assertEqual(p.tun_if.get_tx_stats(), 3*n_pkts)
self.tun6_encrypt_node_name = "esp6-encrypt-tun"
@@ -2993,10 +2949,8 @@ class TestIpsecItf6(TemplateIpsec,
self.unconfig_sa(p)
self.verify_tun_66(np, count=n_pkts)
- c = p.tun_if.get_rx_stats()
- self.assertEqual(c['packets'], n_pkts)
- c = p.tun_if.get_tx_stats()
- self.assertEqual(c['packets'], n_pkts)
+ self.assertEqual(p.tun_if.get_rx_stats(), n_pkts)
+ self.assertEqual(p.tun_if.get_tx_stats(), n_pkts)
# teardown
self.unconfig_protect(np)
@@ -3032,10 +2986,8 @@ class TestIpsecItf6(TemplateIpsec,
policer.apply_vpp_config(p.tun_if.sw_if_index, True)
self.verify_tun_66(p, count=n_pkts)
- c = p.tun_if.get_rx_stats()
- self.assertEqual(c['packets'], n_pkts)
- c = p.tun_if.get_tx_stats()
- self.assertEqual(c['packets'], n_pkts)
+ self.assertEqual(p.tun_if.get_rx_stats(), n_pkts)
+ self.assertEqual(p.tun_if.get_tx_stats(), n_pkts)
stats = policer.get_stats()
diff --git a/test/test_stats_client.py b/test/test_stats_client.py
index 300e8208a87..0fa87a370c1 100644
--- a/test/test_stats_client.py
+++ b/test/test_stats_client.py
@@ -23,8 +23,8 @@ class StatsClientTestCase(VppTestCase):
def test_set_errors(self):
"""Test set errors"""
self.assertEqual(self.statistics.set_errors(), {})
- self.assertEqual(self.statistics.get_counter('/err/ethernet-input/no'),
- [0])
+ self.assertEqual(
+ self.statistics.get_counter('/err/ethernet-input/no error'), [0])
def test_client_fd_leak(self):
"""Test file descriptor count - VPP-1486"""
diff --git a/test/vpp_interface.py b/test/vpp_interface.py
index 7eb586c010c..b7c830b06fd 100644
--- a/test/vpp_interface.py
+++ b/test/vpp_interface.py
@@ -478,12 +478,12 @@ class VppInterface(metaclass=abc.ABCMeta):
return self.name
def get_rx_stats(self):
- c = self.test.statistics.get_counter("^/if/rx$")
- return c[0][self.sw_if_index]
+ return (self.test.statistics["/if/rx"]
+ [:, self.sw_if_index].sum_packets())
def get_tx_stats(self):
- c = self.test.statistics.get_counter("^/if/tx$")
- return c[0][self.sw_if_index]
+ return (self.test.statistics["/if/tx"]
+ [:, self.sw_if_index].sum_packets())
def set_l3_mtu(self, mtu):
self.test.vapi.sw_interface_set_mtu(self.sw_if_index, [mtu, 0, 0, 0])
diff --git a/test/vpp_neighbor.py b/test/vpp_neighbor.py
index 6f5426180fb..9ba87005c46 100644
--- a/test/vpp_neighbor.py
+++ b/test/vpp_neighbor.py
@@ -83,5 +83,5 @@ class VppNeighbor(VppObject):
return ("%d:%s" % (self.sw_if_index, self.nbr_addr))
def get_stats(self):
- c = self._test.statistics.get_counter("/net/adjacency")
+ c = self._test.statistics["/net/adjacency"]
return c[0][self.stats_index]