X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Ftest_lisp.py;h=0a6e752515993fdf8cbb61213b1b206bca913566;hb=01c1fa41f04fbc584165806d3f785cfbbd62cedc;hp=f66fcf79bc041fc7f594ea6901bb071a89fcf901;hpb=3bce8ebfdfaf2a4b576012beb3516d1f4030c20c;p=vpp.git diff --git a/test/test_lisp.py b/test/test_lisp.py index f66fcf79bc0..0a6e7525159 100644 --- a/test/test_lisp.py +++ b/test/test_lisp.py @@ -1,7 +1,6 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import abc -import six import unittest from scapy.fields import BitField, ByteField, FlagsField, IntField @@ -10,8 +9,9 @@ from scapy.layers.inet import IP, UDP, Ether from scapy.layers.inet6 import IPv6 from framework import VppTestCase, VppTestRunner -from lisp import * -from util import ppp, ForeignAddressFactory +from lisp import VppLocalMapping, VppLispAdjacency, VppLispLocator, \ + VppLispLocatorSet, VppRemoteMapping, LispRemoteLocator +from util import ppp # From py_lispnetworking.lisp.py: # GNU General Public License v2.0 @@ -31,8 +31,20 @@ bind_layers(LISP_GPE_Header, IPv6, next_proto=2) bind_layers(LISP_GPE_Header, Ether, next_proto=3) -@six.add_metaclass(abc.ABCMeta) -class Driver(object): +class ForeignAddressFactory(object): + count = 0 + prefix_len = 24 + net_template = '10.10.10.{}' + net = net_template.format(0) + '/' + str(prefix_len) + + def get_ip4(self): + if self.count > 255: + raise Exception("Network host address exhaustion") + self.count += 1 + return self.net_template.format(self.count) + + +class Driver(metaclass=abc.ABCMeta): config_order = ['locator-sets', 'locators', @@ -144,17 +156,21 @@ class TestLisp(VppTestCase): i.config_ip4() # configure IPv4 address on the interface i.resolve_arp() # resolve ARP, so that we know VPP MAC + @classmethod + def tearDownClass(cls): + super(TestLisp, cls).tearDownClass() + def setUp(self): super(TestLisp, self).setUp() - self.vapi.lisp_enable_disable(is_enabled=1) + self.vapi.lisp_enable_disable(is_enable=1) def test_lisp_basic_encap(self): """Test case for basic encapsulation""" self.deid_ip4_net = self.faf.net self.deid_ip4 = self.faf.get_ip4() - self.seid_ip4 = '{}/{}'.format(self.pg0.local_ip4, 32) - self.rloc_ip4 = self.pg1.remote_ip4n + self.seid_ip4 = '{!s}/{!s}'.format(self.pg0.local_ip4, 32) + self.rloc_ip4 = self.pg1.remote_ip4 test_cases = [ { @@ -168,12 +184,7 @@ class TestLisp(VppTestCase): ], 'remote-mappings': [ VppRemoteMapping(self, self.deid_ip4_net, - [{ - "is_ip4": 1, - "priority": 1, - "weight": 1, - "addr": self.rloc_ip4 - }]) + [LispRemoteLocator(self.rloc_ip4)]) ], 'adjacencies': [ VppLispAdjacency(self, self.seid_ip4, self.deid_ip4_net) @@ -184,5 +195,25 @@ class TestLisp(VppTestCase): self.test_driver.run(self.deid_ip4) +class TestLispUT(VppTestCase): + """ Lisp UT """ + + @classmethod + def setUpClass(cls): + super(TestLispUT, cls).setUpClass() + + @classmethod + def tearDownClass(cls): + super(TestLispUT, cls).tearDownClass() + + def test_fib(self): + """ LISP Unit Tests """ + error = self.vapi.cli("test lisp cp") + + if error: + self.logger.critical(error) + self.assertNotIn("Failed", error) + + if __name__ == '__main__': unittest.main(testRunner=VppTestRunner)