blob: 6854cb8a8bd6eac887265e4215b984101641a302 [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
Andrew Yourtchenko06f32812021-01-14 10:19:08 +00006from framework import tag_run_solo
Florin Corasa332c462018-01-31 06:52:17 -08007from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath
Florin Coras3ea6ce22017-12-11 09:09:05 -08008
9
10class TestSession(VppTestCase):
11 """ Session Test Case """
12
13 @classmethod
14 def setUpClass(cls):
15 super(TestSession, cls).setUpClass()
16
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -070017 @classmethod
18 def tearDownClass(cls):
19 super(TestSession, cls).tearDownClass()
20
Florin Coras3ea6ce22017-12-11 09:09:05 -080021 def setUp(self):
22 super(TestSession, self).setUp()
23
Jakub Grajciar6a2794e2020-11-24 11:22:01 +010024 self.vapi.session_enable_disable(is_enable=1)
Klement Sekerab9ef2732018-06-24 22:49:33 +020025 self.create_loopback_interfaces(2)
Florin Corasa332c462018-01-31 06:52:17 -080026
27 table_id = 0
28
29 for i in self.lo_interfaces:
30 i.admin_up()
31
32 if table_id != 0:
33 tbl = VppIpTable(self, table_id)
34 tbl.add_vpp_config()
35
36 i.set_table_ip4(table_id)
37 i.config_ip4()
38 table_id += 1
39
40 # Configure namespaces
Jakub Grajciarb4e5e502020-01-31 09:35:29 +010041 self.vapi.app_namespace_add_del(namespace_id="0",
Ole Troane1ade682019-03-04 23:55:43 +010042 sw_if_index=self.loop0.sw_if_index)
Jakub Grajciarb4e5e502020-01-31 09:35:29 +010043 self.vapi.app_namespace_add_del(namespace_id="1",
Ole Troane1ade682019-03-04 23:55:43 +010044 sw_if_index=self.loop1.sw_if_index)
Florin Corasa332c462018-01-31 06:52:17 -080045
Florin Coras3ea6ce22017-12-11 09:09:05 -080046 def tearDown(self):
Florin Corasa332c462018-01-31 06:52:17 -080047 for i in self.lo_interfaces:
48 i.unconfig_ip4()
49 i.set_table_ip4(0)
50 i.admin_down()
51
Florin Coras3ea6ce22017-12-11 09:09:05 -080052 super(TestSession, self).tearDown()
Jakub Grajciar6a2794e2020-11-24 11:22:01 +010053 self.vapi.session_enable_disable(is_enable=1)
Florin Coras3ea6ce22017-12-11 09:09:05 -080054
Florin Corasa332c462018-01-31 06:52:17 -080055 def test_segment_manager_alloc(self):
56 """ Session Segment Manager Multiple Segment Allocation """
57
58 # Add inter-table routes
59 ip_t01 = VppIpRoute(self, self.loop1.local_ip4, 32,
60 [VppRoutePath("0.0.0.0",
61 0xffffffff,
62 nh_table_id=1)])
63 ip_t10 = VppIpRoute(self, self.loop0.local_ip4, 32,
64 [VppRoutePath("0.0.0.0",
65 0xffffffff,
66 nh_table_id=0)], table_id=1)
67 ip_t01.add_vpp_config()
68 ip_t10.add_vpp_config()
69
70 # Start builtin server and client with small private segments
71 uri = "tcp://" + self.loop0.local_ip4 + "/1234"
72 error = self.vapi.cli("test echo server appns 0 fifo-size 64 " +
73 "private-segment-size 1m uri " + uri)
74 if error:
75 self.logger.critical(error)
Paul Vinciguerra9a6dafd2019-03-06 15:11:28 -080076 self.assertNotIn("failed", error)
Florin Corasa332c462018-01-31 06:52:17 -080077
78 error = self.vapi.cli("test echo client nclients 100 appns 1 " +
79 "no-output fifo-size 64 syn-timeout 2 " +
80 "private-segment-size 1m uri " + uri)
81 if error:
82 self.logger.critical(error)
Paul Vinciguerra9a6dafd2019-03-06 15:11:28 -080083 self.assertNotIn("failed", error)
Florin Corasa332c462018-01-31 06:52:17 -080084
Florin Corasf8f516a2018-02-08 15:10:09 -080085 if self.vpp_dead:
86 self.assert_equal(0)
87
Florin Corasa332c462018-01-31 06:52:17 -080088 # Delete inter-table routes
89 ip_t01.remove_vpp_config()
90 ip_t10.remove_vpp_config()
Florin Coras3ea6ce22017-12-11 09:09:05 -080091
Florin Coras5665ced2018-10-25 18:03:45 -070092
93class TestSessionUnitTests(VppTestCase):
94 """ Session Unit Tests Case """
95
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -070096 @classmethod
97 def setUpClass(cls):
98 super(TestSessionUnitTests, cls).setUpClass()
99
100 @classmethod
101 def tearDownClass(cls):
102 super(TestSessionUnitTests, cls).tearDownClass()
103
Florin Coras5665ced2018-10-25 18:03:45 -0700104 def setUp(self):
105 super(TestSessionUnitTests, self).setUp()
Jakub Grajciar6a2794e2020-11-24 11:22:01 +0100106 self.vapi.session_enable_disable(is_enable=1)
Florin Coras5665ced2018-10-25 18:03:45 -0700107
108 def test_session(self):
109 """ Session Unit Tests """
110 error = self.vapi.cli("test session all")
111
112 if error:
113 self.logger.critical(error)
Paul Vinciguerra9a6dafd2019-03-06 15:11:28 -0800114 self.assertNotIn("failed", error)
Florin Coras5665ced2018-10-25 18:03:45 -0700115
116 def tearDown(self):
117 super(TestSessionUnitTests, self).tearDown()
Jakub Grajciar6a2794e2020-11-24 11:22:01 +0100118 self.vapi.session_enable_disable(is_enable=0)
Florin Coras5665ced2018-10-25 18:03:45 -0700119
Florin Corasf682fac2019-04-18 20:50:50 -0700120
Andrew Yourtchenko06f32812021-01-14 10:19:08 +0000121@tag_run_solo
Florin Corasf682fac2019-04-18 20:50:50 -0700122class TestSvmFifoUnitTests(VppTestCase):
123 """ SVM Fifo Unit Tests Case """
124
125 @classmethod
126 def setUpClass(cls):
127 super(TestSvmFifoUnitTests, cls).setUpClass()
128
129 @classmethod
130 def tearDownClass(cls):
131 super(TestSvmFifoUnitTests, cls).tearDownClass()
132
133 def setUp(self):
134 super(TestSvmFifoUnitTests, self).setUp()
135
136 def test_svm_fifo(self):
137 """ SVM Fifo Unit Tests """
138 error = self.vapi.cli("test svm fifo all")
139
140 if error:
141 self.logger.critical(error)
142 self.assertNotIn("failed", error)
143
144 def tearDown(self):
145 super(TestSvmFifoUnitTests, self).tearDown()
146
Florin Coras3ea6ce22017-12-11 09:09:05 -0800147if __name__ == '__main__':
148 unittest.main(testRunner=VppTestRunner)