blob: 94218d08e8e8470609ce78c3a40ff026715d3462 [file] [log] [blame]
Renato Botelho do Coutoead1e532019-10-31 13:31:07 -05001#!/usr/bin/env python3
Florin Coras3ea6ce22017-12-11 09:09:05 -08002
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
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -070016 @classmethod
17 def tearDownClass(cls):
18 super(TestSession, cls).tearDownClass()
19
Florin Coras3ea6ce22017-12-11 09:09:05 -080020 def setUp(self):
21 super(TestSession, self).setUp()
22
Florin Corasa332c462018-01-31 06:52:17 -080023 self.vapi.session_enable_disable(is_enabled=1)
Klement Sekerab9ef2732018-06-24 22:49:33 +020024 self.create_loopback_interfaces(2)
Florin Corasa332c462018-01-31 06:52:17 -080025
26 table_id = 0
27
28 for i in self.lo_interfaces:
29 i.admin_up()
30
31 if table_id != 0:
32 tbl = VppIpTable(self, table_id)
33 tbl.add_vpp_config()
34
35 i.set_table_ip4(table_id)
36 i.config_ip4()
37 table_id += 1
38
39 # Configure namespaces
Jakub Grajciarb4e5e502020-01-31 09:35:29 +010040 self.vapi.app_namespace_add_del(namespace_id="0",
Ole Troane1ade682019-03-04 23:55:43 +010041 sw_if_index=self.loop0.sw_if_index)
Jakub Grajciarb4e5e502020-01-31 09:35:29 +010042 self.vapi.app_namespace_add_del(namespace_id="1",
Ole Troane1ade682019-03-04 23:55:43 +010043 sw_if_index=self.loop1.sw_if_index)
Florin Corasa332c462018-01-31 06:52:17 -080044
Florin Coras3ea6ce22017-12-11 09:09:05 -080045 def tearDown(self):
Florin Corasa332c462018-01-31 06:52:17 -080046 for i in self.lo_interfaces:
47 i.unconfig_ip4()
48 i.set_table_ip4(0)
49 i.admin_down()
50
Florin Coras3ea6ce22017-12-11 09:09:05 -080051 super(TestSession, self).tearDown()
52 self.vapi.session_enable_disable(is_enabled=1)
53
Florin Corasa332c462018-01-31 06:52:17 -080054 def test_segment_manager_alloc(self):
55 """ Session Segment Manager Multiple Segment Allocation """
56
57 # Add inter-table routes
58 ip_t01 = VppIpRoute(self, self.loop1.local_ip4, 32,
59 [VppRoutePath("0.0.0.0",
60 0xffffffff,
61 nh_table_id=1)])
62 ip_t10 = VppIpRoute(self, self.loop0.local_ip4, 32,
63 [VppRoutePath("0.0.0.0",
64 0xffffffff,
65 nh_table_id=0)], table_id=1)
66 ip_t01.add_vpp_config()
67 ip_t10.add_vpp_config()
68
69 # Start builtin server and client with small private segments
70 uri = "tcp://" + self.loop0.local_ip4 + "/1234"
71 error = self.vapi.cli("test echo server appns 0 fifo-size 64 " +
72 "private-segment-size 1m uri " + uri)
73 if error:
74 self.logger.critical(error)
Paul Vinciguerra9a6dafd2019-03-06 15:11:28 -080075 self.assertNotIn("failed", error)
Florin Corasa332c462018-01-31 06:52:17 -080076
77 error = self.vapi.cli("test echo client nclients 100 appns 1 " +
78 "no-output fifo-size 64 syn-timeout 2 " +
79 "private-segment-size 1m uri " + uri)
80 if error:
81 self.logger.critical(error)
Paul Vinciguerra9a6dafd2019-03-06 15:11:28 -080082 self.assertNotIn("failed", error)
Florin Corasa332c462018-01-31 06:52:17 -080083
Florin Corasf8f516a2018-02-08 15:10:09 -080084 if self.vpp_dead:
85 self.assert_equal(0)
86
Florin Corasa332c462018-01-31 06:52:17 -080087 # Delete inter-table routes
88 ip_t01.remove_vpp_config()
89 ip_t10.remove_vpp_config()
Florin Coras3ea6ce22017-12-11 09:09:05 -080090
Florin Coras5665ced2018-10-25 18:03:45 -070091
92class TestSessionUnitTests(VppTestCase):
93 """ Session Unit Tests Case """
94
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -070095 @classmethod
96 def setUpClass(cls):
97 super(TestSessionUnitTests, cls).setUpClass()
98
99 @classmethod
100 def tearDownClass(cls):
101 super(TestSessionUnitTests, cls).tearDownClass()
102
Florin Coras5665ced2018-10-25 18:03:45 -0700103 def setUp(self):
104 super(TestSessionUnitTests, self).setUp()
105 self.vapi.session_enable_disable(is_enabled=1)
106
107 def test_session(self):
108 """ Session Unit Tests """
109 error = self.vapi.cli("test session all")
110
111 if error:
112 self.logger.critical(error)
Paul Vinciguerra9a6dafd2019-03-06 15:11:28 -0800113 self.assertNotIn("failed", error)
Florin Coras5665ced2018-10-25 18:03:45 -0700114
115 def tearDown(self):
116 super(TestSessionUnitTests, self).tearDown()
117 self.vapi.session_enable_disable(is_enabled=0)
118
Florin Corasf682fac2019-04-18 20:50:50 -0700119
120class TestSvmFifoUnitTests(VppTestCase):
121 """ SVM Fifo Unit Tests Case """
122
123 @classmethod
124 def setUpClass(cls):
125 super(TestSvmFifoUnitTests, cls).setUpClass()
126
127 @classmethod
128 def tearDownClass(cls):
129 super(TestSvmFifoUnitTests, cls).tearDownClass()
130
131 def setUp(self):
132 super(TestSvmFifoUnitTests, self).setUp()
133
134 def test_svm_fifo(self):
135 """ SVM Fifo Unit Tests """
136 error = self.vapi.cli("test svm fifo all")
137
138 if error:
139 self.logger.critical(error)
140 self.assertNotIn("failed", error)
141
142 def tearDown(self):
143 super(TestSvmFifoUnitTests, self).tearDown()
144
Florin Coras3ea6ce22017-12-11 09:09:05 -0800145if __name__ == '__main__':
146 unittest.main(testRunner=VppTestRunner)