Typos. A bunch of typos I've been collecting.
[vpp.git] / test / test_udp.py
index b0c6ee9..3010a1d 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 import unittest
 from framework import VppTestCase, VppTestRunner
-from vpp_udp_encap import *
+from vpp_udp_encap import find_udp_encap, VppUdpEncap
 from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpTable, VppMplsLabel
 
 from scapy.packet import Raw
@@ -85,23 +85,23 @@ class TestUdpEncap(VppTestCase):
 
         #
         # construct a UDP encap object through each of the peers
-        # v4 through the first two peears, v6 through the second.
+        # v4 through the first two peers, v6 through the second.
         #
-        udp_encap_0 = VppUdpEncap(self, 0,
+        udp_encap_0 = VppUdpEncap(self,
                                   self.pg0.local_ip4,
                                   self.pg0.remote_ip4,
                                   330, 440)
-        udp_encap_1 = VppUdpEncap(self, 1,
+        udp_encap_1 = VppUdpEncap(self,
                                   self.pg1.local_ip4,
                                   self.pg1.remote_ip4,
                                   331, 441,
                                   table_id=1)
-        udp_encap_2 = VppUdpEncap(self, 2,
+        udp_encap_2 = VppUdpEncap(self,
                                   self.pg2.local_ip6,
                                   self.pg2.remote_ip6,
                                   332, 442,
                                   table_id=2)
-        udp_encap_3 = VppUdpEncap(self, 3,
+        udp_encap_3 = VppUdpEncap(self,
                                   self.pg3.local_ip6,
                                   self.pg3.remote_ip6,
                                   333, 443,
@@ -125,23 +125,23 @@ class TestUdpEncap(VppTestCase):
                                [VppRoutePath("0.0.0.0",
                                              0xFFFFFFFF,
                                              is_udp_encap=1,
-                                             next_hop_id=0)])
+                                             next_hop_id=udp_encap_0.id)])
         route_4o6 = VppIpRoute(self, "1.1.2.1", 32,
                                [VppRoutePath("0.0.0.0",
                                              0xFFFFFFFF,
                                              is_udp_encap=1,
-                                             next_hop_id=2)])
+                                             next_hop_id=udp_encap_2.id)])
         route_6o4 = VppIpRoute(self, "2001::1", 128,
                                [VppRoutePath("0.0.0.0",
                                              0xFFFFFFFF,
                                              is_udp_encap=1,
-                                             next_hop_id=1)],
+                                             next_hop_id=udp_encap_1.id)],
                                is_ip6=1)
         route_6o6 = VppIpRoute(self, "2001::3", 128,
                                [VppRoutePath("0.0.0.0",
                                              0xFFFFFFFF,
                                              is_udp_encap=1,
-                                             next_hop_id=3)],
+                                             next_hop_id=udp_encap_3.id)],
                                is_ip6=1)
         route_4o4.add_vpp_config()
         route_4o6.add_vpp_config()
@@ -161,6 +161,7 @@ class TestUdpEncap(VppTestCase):
             self.validate_outer4(p, udp_encap_0)
             p = IP(p["UDP"].payload.load)
             self.validate_inner4(p, p_4o4)
+        self.assertEqual(udp_encap_0.get_stats()['packets'], 65)
 
         #
         # 4o6 encap
@@ -175,6 +176,7 @@ class TestUdpEncap(VppTestCase):
             self.validate_outer6(p, udp_encap_2)
             p = IP(p["UDP"].payload.load)
             self.validate_inner4(p, p_4o6)
+        self.assertEqual(udp_encap_2.get_stats()['packets'], 65)
 
         #
         # 6o4 encap
@@ -189,6 +191,7 @@ class TestUdpEncap(VppTestCase):
             self.validate_outer4(p, udp_encap_1)
             p = IPv6(p["UDP"].payload.load)
             self.validate_inner6(p, p_6o4)
+        self.assertEqual(udp_encap_1.get_stats()['packets'], 65)
 
         #
         # 6o6 encap
@@ -203,6 +206,7 @@ class TestUdpEncap(VppTestCase):
             self.validate_outer6(p, udp_encap_3)
             p = IPv6(p["UDP"].payload.load)
             self.validate_inner6(p, p_6o6)
+        self.assertEqual(udp_encap_3.get_stats()['packets'], 65)
 
         #
         # A route with an output label
@@ -226,6 +230,7 @@ class TestUdpEncap(VppTestCase):
             self.validate_outer4(p, udp_encap_1)
             p = MPLS(p["UDP"].payload.load)
             self.validate_inner4(p, p_4omo4, ttl=63)
+        self.assertEqual(udp_encap_1.get_stats()['packets'], 130)
 
 
 class TestUDP(VppTestCase):
@@ -254,10 +259,10 @@ class TestUDP(VppTestCase):
             table_id += 1
 
         # Configure namespaces
-        self.vapi.app_namespace_add(namespace_id="0",
-                                    sw_if_index=self.loop0.sw_if_index)
-        self.vapi.app_namespace_add(namespace_id="1",
-                                    sw_if_index=self.loop1.sw_if_index)
+        self.vapi.app_namespace_add_del(namespace_id="0",
+                                        sw_if_index=self.loop0.sw_if_index)
+        self.vapi.app_namespace_add_del(namespace_id="1",
+                                        sw_if_index=self.loop1.sw_if_index)
 
     def tearDown(self):
         for i in self.lo_interfaces:
@@ -288,14 +293,14 @@ class TestUDP(VppTestCase):
                               "uri " + uri)
         if error:
             self.logger.critical(error)
-            self.assertEqual(error.find("failed"), -1)
+            self.assertNotIn("failed", error)
 
         error = self.vapi.cli("test echo client mbytes 10 appns 1 " +
                               "fifo-size 4 no-output test-bytes " +
                               "syn-timeout 2 no-return uri " + uri)
         if error:
             self.logger.critical(error)
-            self.assertEqual(error.find("failed"), -1)
+            self.assertNotIn("failed", error)
 
         # Delete inter-table routes
         ip_t01.remove_vpp_config()