blob: 047b8ca553aad3fec5f1269652df553ffd6f7a6a [file] [log] [blame]
Florin Coras3ea6ce22017-12-11 09:09:05 -08001#!/usr/bin/env python
2
3import unittest
4
5from framework import VppTestCase, VppTestRunner
Florin Corasa332c462018-01-31 06:52:17 -08006from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath
Florin Coras3ea6ce22017-12-11 09:09:05 -08007
8
9class TestSession(VppTestCase):
10 """ Session Test Case """
11
12 @classmethod
13 def setUpClass(cls):
14 super(TestSession, cls).setUpClass()
15
16 def setUp(self):
17 super(TestSession, self).setUp()
18
Florin Corasa332c462018-01-31 06:52:17 -080019 self.vapi.session_enable_disable(is_enabled=1)
20 self.create_loopback_interfaces(range(2))
21
22 table_id = 0
23
24 for i in self.lo_interfaces:
25 i.admin_up()
26
27 if table_id != 0:
28 tbl = VppIpTable(self, table_id)
29 tbl.add_vpp_config()
30
31 i.set_table_ip4(table_id)
32 i.config_ip4()
33 table_id += 1
34
35 # Configure namespaces
36 self.vapi.app_namespace_add(namespace_id="0",
37 sw_if_index=self.loop0.sw_if_index)
38 self.vapi.app_namespace_add(namespace_id="1",
39 sw_if_index=self.loop1.sw_if_index)
40
Florin Coras3ea6ce22017-12-11 09:09:05 -080041 def tearDown(self):
Florin Corasa332c462018-01-31 06:52:17 -080042 for i in self.lo_interfaces:
43 i.unconfig_ip4()
44 i.set_table_ip4(0)
45 i.admin_down()
46
Florin Coras3ea6ce22017-12-11 09:09:05 -080047 super(TestSession, self).tearDown()
48 self.vapi.session_enable_disable(is_enabled=1)
49
50 def test_session(self):
51 """ Session Unit Tests """
52 error = self.vapi.cli("test session all")
53
54 if error:
55 self.logger.critical(error)
Florin Corasa332c462018-01-31 06:52:17 -080056 self.assertEqual(error.find("failed"), -1)
57
58 def test_segment_manager_alloc(self):
59 """ Session Segment Manager Multiple Segment Allocation """
60
61 # Add inter-table routes
62 ip_t01 = VppIpRoute(self, self.loop1.local_ip4, 32,
63 [VppRoutePath("0.0.0.0",
64 0xffffffff,
65 nh_table_id=1)])
66 ip_t10 = VppIpRoute(self, self.loop0.local_ip4, 32,
67 [VppRoutePath("0.0.0.0",
68 0xffffffff,
69 nh_table_id=0)], table_id=1)
70 ip_t01.add_vpp_config()
71 ip_t10.add_vpp_config()
72
73 # Start builtin server and client with small private segments
74 uri = "tcp://" + self.loop0.local_ip4 + "/1234"
75 error = self.vapi.cli("test echo server appns 0 fifo-size 64 " +
76 "private-segment-size 1m uri " + uri)
77 if error:
78 self.logger.critical(error)
79 self.assertEqual(error.find("failed"), -1)
80
81 error = self.vapi.cli("test echo client nclients 100 appns 1 " +
82 "no-output fifo-size 64 syn-timeout 2 " +
83 "private-segment-size 1m uri " + uri)
84 if error:
85 self.logger.critical(error)
86 self.assertEqual(error.find("failed"), -1)
87
Florin Corasf8f516a2018-02-08 15:10:09 -080088 if self.vpp_dead:
89 self.assert_equal(0)
90
Florin Corasa332c462018-01-31 06:52:17 -080091 # Delete inter-table routes
92 ip_t01.remove_vpp_config()
93 ip_t10.remove_vpp_config()
Florin Coras3ea6ce22017-12-11 09:09:05 -080094
95if __name__ == '__main__':
96 unittest.main(testRunner=VppTestRunner)