diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/test_mpls.py | 21 | ||||
-rw-r--r-- | test/vpp_ip_route.py | 24 |
2 files changed, 42 insertions, 3 deletions
diff --git a/test/test_mpls.py b/test/test_mpls.py index d943f8281e9..1a4dad18e30 100644 --- a/test/test_mpls.py +++ b/test/test_mpls.py @@ -389,6 +389,8 @@ class TestMPLS(VppTestCase): self.verify_capture_labelled(self.pg0, rx, tx, [VppMplsLabel(33, ttl=31, exp=1)]) + self.assertEqual(route_32_eos.get_stats_to()['packets'], 257) + # # A simple MPLS xconnect - non-eos label in label out # @@ -409,6 +411,7 @@ class TestMPLS(VppTestCase): self.verify_capture_labelled(self.pg0, rx, tx, [VppMplsLabel(33, ttl=20, exp=7), VppMplsLabel(99)]) + self.assertEqual(route_32_neos.get_stats_to()['packets'], 257) # # A simple MPLS xconnect - non-eos label in label out, uniform mode @@ -575,6 +578,9 @@ class TestMPLS(VppTestCase): VppMplsLabel(44), VppMplsLabel(45, ttl=2)]) + self.assertEqual(route_34_eos.get_stats_to()['packets'], 257) + self.assertEqual(route_32_neos.get_stats_via()['packets'], 257) + # # A recursive EOS x-connect, which resolves through another x-connect # in uniform mode @@ -635,6 +641,7 @@ class TestMPLS(VppTestCase): VppMplsLabel(44), VppMplsLabel(46), VppMplsLabel(55)]) + self.assertEqual(ip_10_0_0_1.get_stats_to()['packets'], 257) ip_10_0_0_1.remove_vpp_config() route_34_neos.remove_vpp_config() @@ -782,6 +789,8 @@ class TestMPLS(VppTestCase): [VppMplsLabel(32), VppMplsLabel(44)]) + self.assertEqual(route_11_0_0_1.get_stats_to()['packets'], 257) + # # add a recursive path, with 2 labels, via the 3 label route # @@ -805,6 +814,18 @@ class TestMPLS(VppTestCase): VppMplsLabel(44), VppMplsLabel(45)]) + self.assertEqual(route_11_0_0_2.get_stats_to()['packets'], 257) + + rx = self.send_and_expect(self.pg0, tx, self.pg0) + self.verify_capture_labelled_ip4(self.pg0, rx, tx, + [VppMplsLabel(32), + VppMplsLabel(33), + VppMplsLabel(34), + VppMplsLabel(44), + VppMplsLabel(45)]) + + self.assertEqual(route_11_0_0_2.get_stats_to()['packets'], 514) + # # cleanup # diff --git a/test/vpp_ip_route.py b/test/vpp_ip_route.py index 18c27ffa942..d24e4b1e487 100644 --- a/test/vpp_ip_route.py +++ b/test/vpp_ip_route.py @@ -244,7 +244,7 @@ class VppIpRoute(VppObject): def add_vpp_config(self): if self.is_local or self.is_unreach or \ self.is_prohibit or self.is_drop: - self._test.vapi.ip_add_del_route( + r = self._test.vapi.ip_add_del_route( self.dest_addr, self.dest_addr_len, inet_pton(AF_INET6, "::"), @@ -259,7 +259,7 @@ class VppIpRoute(VppObject): for path in self.paths: lstack = path.encode_labels() - self._test.vapi.ip_add_del_route( + r = self._test.vapi.ip_add_del_route( self.dest_addr, self.dest_addr_len, path.nh_addr, @@ -277,6 +277,7 @@ class VppIpRoute(VppObject): is_source_lookup=path.is_source_lookup, is_udp_encap=path.is_udp_encap, is_multipath=1 if len(self.paths) > 1 else 0) + self.stats_index = r.stats_index self._test.registry.register(self, self._test.logger) def remove_vpp_config(self): @@ -325,6 +326,14 @@ class VppIpRoute(VppObject): self.dest_addr_p, self.dest_addr_len)) + def get_stats_to(self): + c = self._test.statistics.get_counter("/net/route/to") + return c[0][self.stats_index] + + def get_stats_via(self): + c = self._test.statistics.get_counter("/net/route/via") + return c[0][self.stats_index] + class VppIpMRoute(VppObject): """ @@ -581,7 +590,7 @@ class VppMplsRoute(VppObject): for path in self.paths: lstack = path.encode_labels() - self._test.vapi.mpls_route_add_del( + r = self._test.vapi.mpls_route_add_del( self.local_label, self.eos_bit, path.proto, @@ -596,6 +605,7 @@ class VppMplsRoute(VppObject): next_hop_n_out_labels=len(lstack), next_hop_via_label=path.nh_via_label, next_hop_table_id=path.nh_table_id) + self.stats_index = r.stats_index self._test.registry.register(self, self._test.logger) def remove_vpp_config(self): @@ -626,3 +636,11 @@ class VppMplsRoute(VppObject): % (self.table_id, self.local_label, 20+self.eos_bit)) + + def get_stats_to(self): + c = self._test.statistics.get_counter("/net/route/to") + return c[0][self.stats_index] + + def get_stats_via(self): + c = self._test.statistics.get_counter("/net/route/via") + return c[0][self.stats_index] |