2019-10-31 13:31:07 -05:00
|
|
|
#!/usr/bin/env python3
|
2017-12-11 09:09:05 -08:00
|
|
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
from framework import VppTestCase, VppTestRunner
|
2018-01-31 06:52:17 -08:00
|
|
|
from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath
|
2017-12-11 09:09:05 -08:00
|
|
|
|
|
|
|
|
|
|
|
class TestSession(VppTestCase):
|
|
|
|
""" Session Test Case """
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
|
|
|
super(TestSession, cls).setUpClass()
|
|
|
|
|
2019-03-12 19:23:27 -07:00
|
|
|
@classmethod
|
|
|
|
def tearDownClass(cls):
|
|
|
|
super(TestSession, cls).tearDownClass()
|
|
|
|
|
2017-12-11 09:09:05 -08:00
|
|
|
def setUp(self):
|
|
|
|
super(TestSession, self).setUp()
|
|
|
|
|
2020-11-24 11:22:01 +01:00
|
|
|
self.vapi.session_enable_disable(is_enable=1)
|
2018-06-24 22:49:33 +02:00
|
|
|
self.create_loopback_interfaces(2)
|
2018-01-31 06:52:17 -08:00
|
|
|
|
|
|
|
table_id = 0
|
|
|
|
|
|
|
|
for i in self.lo_interfaces:
|
|
|
|
i.admin_up()
|
|
|
|
|
|
|
|
if table_id != 0:
|
|
|
|
tbl = VppIpTable(self, table_id)
|
|
|
|
tbl.add_vpp_config()
|
|
|
|
|
|
|
|
i.set_table_ip4(table_id)
|
|
|
|
i.config_ip4()
|
|
|
|
table_id += 1
|
|
|
|
|
|
|
|
# Configure namespaces
|
2020-01-31 09:35:29 +01:00
|
|
|
self.vapi.app_namespace_add_del(namespace_id="0",
|
2019-03-04 23:55:43 +01:00
|
|
|
sw_if_index=self.loop0.sw_if_index)
|
2020-01-31 09:35:29 +01:00
|
|
|
self.vapi.app_namespace_add_del(namespace_id="1",
|
2019-03-04 23:55:43 +01:00
|
|
|
sw_if_index=self.loop1.sw_if_index)
|
2018-01-31 06:52:17 -08:00
|
|
|
|
2017-12-11 09:09:05 -08:00
|
|
|
def tearDown(self):
|
2018-01-31 06:52:17 -08:00
|
|
|
for i in self.lo_interfaces:
|
|
|
|
i.unconfig_ip4()
|
|
|
|
i.set_table_ip4(0)
|
|
|
|
i.admin_down()
|
|
|
|
|
2017-12-11 09:09:05 -08:00
|
|
|
super(TestSession, self).tearDown()
|
2020-11-24 11:22:01 +01:00
|
|
|
self.vapi.session_enable_disable(is_enable=1)
|
2017-12-11 09:09:05 -08:00
|
|
|
|
2018-01-31 06:52:17 -08:00
|
|
|
def test_segment_manager_alloc(self):
|
|
|
|
""" Session Segment Manager Multiple Segment Allocation """
|
|
|
|
|
|
|
|
# Add inter-table routes
|
|
|
|
ip_t01 = VppIpRoute(self, self.loop1.local_ip4, 32,
|
|
|
|
[VppRoutePath("0.0.0.0",
|
|
|
|
0xffffffff,
|
|
|
|
nh_table_id=1)])
|
|
|
|
ip_t10 = VppIpRoute(self, self.loop0.local_ip4, 32,
|
|
|
|
[VppRoutePath("0.0.0.0",
|
|
|
|
0xffffffff,
|
|
|
|
nh_table_id=0)], table_id=1)
|
|
|
|
ip_t01.add_vpp_config()
|
|
|
|
ip_t10.add_vpp_config()
|
|
|
|
|
|
|
|
# Start builtin server and client with small private segments
|
|
|
|
uri = "tcp://" + self.loop0.local_ip4 + "/1234"
|
|
|
|
error = self.vapi.cli("test echo server appns 0 fifo-size 64 " +
|
|
|
|
"private-segment-size 1m uri " + uri)
|
|
|
|
if error:
|
|
|
|
self.logger.critical(error)
|
2019-03-06 15:11:28 -08:00
|
|
|
self.assertNotIn("failed", error)
|
2018-01-31 06:52:17 -08:00
|
|
|
|
|
|
|
error = self.vapi.cli("test echo client nclients 100 appns 1 " +
|
|
|
|
"no-output fifo-size 64 syn-timeout 2 " +
|
|
|
|
"private-segment-size 1m uri " + uri)
|
|
|
|
if error:
|
|
|
|
self.logger.critical(error)
|
2019-03-06 15:11:28 -08:00
|
|
|
self.assertNotIn("failed", error)
|
2018-01-31 06:52:17 -08:00
|
|
|
|
2018-02-08 15:10:09 -08:00
|
|
|
if self.vpp_dead:
|
|
|
|
self.assert_equal(0)
|
|
|
|
|
2018-01-31 06:52:17 -08:00
|
|
|
# Delete inter-table routes
|
|
|
|
ip_t01.remove_vpp_config()
|
|
|
|
ip_t10.remove_vpp_config()
|
2017-12-11 09:09:05 -08:00
|
|
|
|
2018-10-25 18:03:45 -07:00
|
|
|
|
|
|
|
class TestSessionUnitTests(VppTestCase):
|
|
|
|
""" Session Unit Tests Case """
|
|
|
|
|
2019-03-12 19:23:27 -07:00
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
|
|
|
super(TestSessionUnitTests, cls).setUpClass()
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def tearDownClass(cls):
|
|
|
|
super(TestSessionUnitTests, cls).tearDownClass()
|
|
|
|
|
2018-10-25 18:03:45 -07:00
|
|
|
def setUp(self):
|
|
|
|
super(TestSessionUnitTests, self).setUp()
|
2020-11-24 11:22:01 +01:00
|
|
|
self.vapi.session_enable_disable(is_enable=1)
|
2018-10-25 18:03:45 -07:00
|
|
|
|
|
|
|
def test_session(self):
|
|
|
|
""" Session Unit Tests """
|
|
|
|
error = self.vapi.cli("test session all")
|
|
|
|
|
|
|
|
if error:
|
|
|
|
self.logger.critical(error)
|
2019-03-06 15:11:28 -08:00
|
|
|
self.assertNotIn("failed", error)
|
2018-10-25 18:03:45 -07:00
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
super(TestSessionUnitTests, self).tearDown()
|
2020-11-24 11:22:01 +01:00
|
|
|
self.vapi.session_enable_disable(is_enable=0)
|
2018-10-25 18:03:45 -07:00
|
|
|
|
2019-04-18 20:50:50 -07:00
|
|
|
|
|
|
|
class TestSvmFifoUnitTests(VppTestCase):
|
|
|
|
""" SVM Fifo Unit Tests Case """
|
|
|
|
|
2020-08-26 14:33:54 +00:00
|
|
|
@classmethod
|
|
|
|
def force_solo(cls):
|
|
|
|
return True
|
|
|
|
|
2019-04-18 20:50:50 -07:00
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
|
|
|
super(TestSvmFifoUnitTests, cls).setUpClass()
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def tearDownClass(cls):
|
|
|
|
super(TestSvmFifoUnitTests, cls).tearDownClass()
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
super(TestSvmFifoUnitTests, self).setUp()
|
|
|
|
|
|
|
|
def test_svm_fifo(self):
|
|
|
|
""" SVM Fifo Unit Tests """
|
|
|
|
error = self.vapi.cli("test svm fifo all")
|
|
|
|
|
|
|
|
if error:
|
|
|
|
self.logger.critical(error)
|
|
|
|
self.assertNotIn("failed", error)
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
super(TestSvmFifoUnitTests, self).tearDown()
|
|
|
|
|
2017-12-11 09:09:05 -08:00
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main(testRunner=VppTestRunner)
|