summaryrefslogtreecommitdiffstats
path: root/test/test_sixrd.py
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2018-03-14 20:39:40 +0100
committerNeale Ranns <nranns@cisco.com>2018-03-15 14:59:08 +0000
commit46c1c11ba08512a5e37392de1ddb306b139a5bcf (patch)
treeb95b967b9f0dccdfc528c5cb3a319240fb7dc43e /test/test_sixrd.py
parentb9ca61be1af028a3c7d7004373e8447cae766132 (diff)
IPIP: Linter on test_*.py
Change-Id: Icd491e382a2da0e5d55a673458605bc37e39b669 Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'test/test_sixrd.py')
-rw-r--r--test/test_sixrd.py120
1 files changed, 47 insertions, 73 deletions
diff --git a/test/test_sixrd.py b/test/test_sixrd.py
index ac5061474d5..c6b3c088516 100644
--- a/test/test_sixrd.py
+++ b/test/test_sixrd.py
@@ -1,17 +1,13 @@
-#
-# 6RD RFC5969 functional tests
-#
+#!/usr/bin/env python
+""" 6RD RFC5969 functional tests """
import unittest
-from scapy.layers.inet import IP, UDP, ICMP
+from scapy.layers.inet import IP, UDP, Ether
from scapy.layers.inet6 import IPv6
-from scapy.layers.l2 import Ether, GRE
from scapy.packet import Raw
-
-from framework import VppTestCase
+from framework import VppTestCase, VppTestRunner
from vpp_ip_route import VppIpRoute, VppRoutePath, DpoProto
-from util import ppp
-from ipaddress import *
+from socket import AF_INET, AF_INET6, inet_pton
""" Test6rd is a subclass of VPPTestCase classes.
@@ -26,43 +22,31 @@ class Test6RD(VppTestCase):
@classmethod
def setUpClass(cls):
super(Test6RD, cls).setUpClass()
- try:
- cls.create_pg_interfaces(range(2))
- cls.interfaces = list(cls.pg_interfaces)
- except Exception:
- super(Test6RD, cls).tearDownClass()
- raise
+ cls.create_pg_interfaces(range(2))
+ cls.interfaces = list(cls.pg_interfaces)
def setUp(cls):
super(Test6RD, cls).setUp()
- try:
- for i in cls.interfaces:
- i.admin_up()
- i.config_ip4()
- i.config_ip6()
- i.disable_ipv6_ra()
- i.resolve_arp()
- i.resolve_ndp()
- except Exception:
- super(Test6RD, cls).tearDown()
- raise
+ for i in cls.interfaces:
+ i.admin_up()
+ i.config_ip4()
+ i.config_ip6()
+ i.disable_ipv6_ra()
+ i.resolve_arp()
+ i.resolve_ndp()
def tearDown(self):
super(Test6RD, self).tearDown()
if not self.vpp_dead:
- self.vapi.cli("show hardware")
- for i in self.pg_interfaces:
- i.unconfig_ip4()
- i.unconfig_ip6()
- i.admin_down()
- if type(self.tunnel_index) is list:
- for sw_if_index in self.tunnel_index:
- rv = self.vapi.ipip_6rd_del_tunnel(sw_if_index)
- self.assertEqual(rv.retval, 0)
- else:
- rv = self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
- self.assertEqual(rv.retval, 0)
- self.vapi.cli("show error")
+ for i in self.pg_interfaces:
+ i.unconfig_ip4()
+ i.unconfig_ip6()
+ i.admin_down()
+ if type(self.tunnel_index) is list:
+ for sw_if_index in self.tunnel_index:
+ self.vapi.ipip_6rd_del_tunnel(sw_if_index)
+ else:
+ self.vapi.ipip_6rd_del_tunnel(self.tunnel_index)
def validate_6in4(self, rx, expected):
if IP not in rx:
@@ -95,11 +79,9 @@ class Test6RD(VppTestCase):
p_ip6 = IPv6(src="1::1", dst="2002:AC10:0202::1", nh='UDP')
rv = self.vapi.ipip_6rd_add_tunnel(
- 0, str(ip_address('2002::').packed), 16,
- str(ip_address('0.0.0.0').packed), 0,
- str(ip_address(self.pg0.local_ip4).packed), True)
-
- self.assertEqual(rv.retval, 0)
+ 0, inet_pton(AF_INET6, '2002::'), 16,
+ inet_pton(AF_INET, '0.0.0.0'), 0,
+ self.pg0.local_ip4n, True)
self.tunnel_index = rv.sw_if_index
self.vapi.cli("show ip6 fib")
@@ -128,19 +110,16 @@ class Test6RD(VppTestCase):
""" ip4 -> ip6 (decap) 6rd test """
rv = self.vapi.ipip_6rd_add_tunnel(
- 0, str(ip_address('2002::').packed),
- 16, str(ip_address('0.0.0.0').packed),
- 0, str(ip_address(self.pg0.local_ip4).packed), True)
- self.assertEqual(rv.retval, 0)
+ 0, inet_pton(AF_INET6, '2002::'),
+ 16, inet_pton(AF_INET, '0.0.0.0'),
+ 0, self.pg0.local_ip4n, True)
self.tunnel_index = rv.sw_if_index
rv = self.vapi.ipip_6rd_del_tunnel(rv.sw_if_index)
- self.assertEqual(rv.retval, 0)
rv = self.vapi.ipip_6rd_add_tunnel(
- 0, str(ip_address('2002::').packed),
- 16, str(ip_address('0.0.0.0').packed),
- 0, str(ip_address(self.pg0.local_ip4).packed), True)
+ 0, inet_pton(AF_INET6, '2002::'),
+ 16, inet_pton(AF_INET, '0.0.0.0'),
+ 0, self.pg0.local_ip4n, True)
self.tunnel_index = rv.sw_if_index
- self.assertEqual(rv.retval, 0)
p_ip6 = (IPv6(src="2002:AC10:0202::1", dst=self.pg1.remote_ip6) /
UDP(sport=1234, dport=1234))
@@ -161,17 +140,15 @@ class Test6RD(VppTestCase):
self.tunnel_index = []
rv = self.vapi.ipip_6rd_add_tunnel(
- 0, str(ip_address('2002::').packed),
- 16, str(ip_address('0.0.0.0').packed),
- 0, str(ip_address(self.pg0.local_ip4).packed), True)
- self.assertEqual(rv.retval, 0)
+ 0, inet_pton(AF_INET6, '2002::'),
+ 16, inet_pton(AF_INET, '0.0.0.0'),
+ 0, self.pg0.local_ip4n, True)
self.tunnel_index.append(rv.sw_if_index)
rv = self.vapi.ipip_6rd_add_tunnel(
- 0, str(ip_address('2003::').packed),
- 16, str(ip_address('0.0.0.0').packed),
- 0, str(ip_address(self.pg1.local_ip4).packed), True)
- self.assertEqual(rv.retval, 0)
+ 0, inet_pton(AF_INET6, '2003::'),
+ 16, inet_pton(AF_INET, '0.0.0.0'),
+ 0, self.pg1.local_ip4n, True)
self.tunnel_index.append(rv.sw_if_index)
self.vapi.cli("show ip6 fib")
@@ -196,10 +173,9 @@ class Test6RD(VppTestCase):
""" ip4 -> ip6 (decap) 6rd test """
rv = self.vapi.ipip_6rd_add_tunnel(
- 0, str(ip_address('2002::').packed), 16,
- str(ip_address('172.0.0.0').packed), 8,
- str(ip_address(self.pg0.local_ip4).packed), True)
- self.assertEqual(rv.retval, 0)
+ 0, inet_pton(AF_INET6, '2002::'), 16,
+ inet_pton(AF_INET, '172.0.0.0'), 8,
+ self.pg0.local_ip4n, True)
self.tunnel_index = rv.sw_if_index
@@ -218,10 +194,9 @@ class Test6RD(VppTestCase):
""" ip4 -> ip6 (decap) security check 6rd test """
rv = self.vapi.ipip_6rd_add_tunnel(
- 0, str(ip_address('2002::').packed),
- 16, str(ip_address('0.0.0.0').packed),
- 0, str(ip_address(self.pg0.local_ip4).packed), True)
- self.assertEqual(rv.retval, 0)
+ 0, inet_pton(AF_INET6, '2002::'),
+ 16, inet_pton(AF_INET, '0.0.0.0'),
+ 0, self.pg0.local_ip4n, True)
self.tunnel_index = rv.sw_if_index
self.vapi.cli("show ip6 fib")
@@ -251,10 +226,9 @@ class Test6RD(VppTestCase):
""" 6rd BGP tunnel """
rv = self.vapi.ipip_6rd_add_tunnel(
- 0, str(ip_address('2002::').packed),
- 16, str(ip_address('0.0.0.0').packed),
- 0, str(ip_address(self.pg0.local_ip4).packed), False)
- self.assertEqual(rv.retval, 0)
+ 0, inet_pton(AF_INET6, '2002::'),
+ 16, inet_pton(AF_INET, '0.0.0.0'),
+ 0, self.pg0.local_ip4n, False)
self.tunnel_index = rv.sw_if_index
default_route = VppIpRoute(