blob: 8e03968d19af4bcf7198faf66cb5ed8b97152d6d [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
Andrew Yourtchenko8dc0d482021-01-29 13:17:19 +00005from framework import tag_fixme_vpp_workers
Florin Coras3ea6ce22017-12-11 09:09:05 -08006from framework import VppTestCase, VppTestRunner
Andrew Yourtchenko06f32812021-01-14 10:19:08 +00007from framework import tag_run_solo
Florin Corasa332c462018-01-31 06:52:17 -08008from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath
Florin Coras3ea6ce22017-12-11 09:09:05 -08009
10
Andrew Yourtchenko8dc0d482021-01-29 13:17:19 +000011@tag_fixme_vpp_workers
Florin Coras3ea6ce22017-12-11 09:09:05 -080012class TestSession(VppTestCase):
13 """ Session Test Case """
14
15 @classmethod
16 def setUpClass(cls):
17 super(TestSession, cls).setUpClass()
18
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -070019 @classmethod
20 def tearDownClass(cls):
21 super(TestSession, cls).tearDownClass()
22
Florin Coras3ea6ce22017-12-11 09:09:05 -080023 def setUp(self):
24 super(TestSession, self).setUp()
25
Jakub Grajciar6a2794e2020-11-24 11:22:01 +010026 self.vapi.session_enable_disable(is_enable=1)
Klement Sekerab9ef2732018-06-24 22:49:33 +020027 self.create_loopback_interfaces(2)
Florin Corasa332c462018-01-31 06:52:17 -080028
29 table_id = 0
30
31 for i in self.lo_interfaces:
32 i.admin_up()
33
34 if table_id != 0:
35 tbl = VppIpTable(self, table_id)
36 tbl.add_vpp_config()
37
38 i.set_table_ip4(table_id)
39 i.config_ip4()
40 table_id += 1
41
42 # Configure namespaces
Jakub Grajciarb4e5e502020-01-31 09:35:29 +010043 self.vapi.app_namespace_add_del(namespace_id="0",
Ole Troane1ade682019-03-04 23:55:43 +010044 sw_if_index=self.loop0.sw_if_index)
Jakub Grajciarb4e5e502020-01-31 09:35:29 +010045 self.vapi.app_namespace_add_del(namespace_id="1",
Ole Troane1ade682019-03-04 23:55:43 +010046 sw_if_index=self.loop1.sw_if_index)
Florin Corasa332c462018-01-31 06:52:17 -080047
Florin Coras3ea6ce22017-12-11 09:09:05 -080048 def tearDown(self):
Florin Corasa332c462018-01-31 06:52:17 -080049 for i in self.lo_interfaces:
50 i.unconfig_ip4()
51 i.set_table_ip4(0)
52 i.admin_down()
53
Florin Coras3ea6ce22017-12-11 09:09:05 -080054 super(TestSession, self).tearDown()
Jakub Grajciar6a2794e2020-11-24 11:22:01 +010055 self.vapi.session_enable_disable(is_enable=1)
Florin Coras3ea6ce22017-12-11 09:09:05 -080056
Florin Corasa332c462018-01-31 06:52:17 -080057 def test_segment_manager_alloc(self):
58 """ Session Segment Manager Multiple Segment Allocation """
59
60 # Add inter-table routes
61 ip_t01 = VppIpRoute(self, self.loop1.local_ip4, 32,
62 [VppRoutePath("0.0.0.0",
63 0xffffffff,
64 nh_table_id=1)])
65 ip_t10 = VppIpRoute(self, self.loop0.local_ip4, 32,
66 [VppRoutePath("0.0.0.0",
67 0xffffffff,
68 nh_table_id=0)], table_id=1)
69 ip_t01.add_vpp_config()
70 ip_t10.add_vpp_config()
71
72 # Start builtin server and client with small private segments
73 uri = "tcp://" + self.loop0.local_ip4 + "/1234"
74 error = self.vapi.cli("test echo server appns 0 fifo-size 64 " +
75 "private-segment-size 1m uri " + uri)
76 if error:
77 self.logger.critical(error)
Paul Vinciguerra9a6dafd2019-03-06 15:11:28 -080078 self.assertNotIn("failed", error)
Florin Corasa332c462018-01-31 06:52:17 -080079
80 error = self.vapi.cli("test echo client nclients 100 appns 1 " +
81 "no-output fifo-size 64 syn-timeout 2 " +
82 "private-segment-size 1m uri " + uri)
83 if error:
84 self.logger.critical(error)
Paul Vinciguerra9a6dafd2019-03-06 15:11:28 -080085 self.assertNotIn("failed", error)
Florin Corasa332c462018-01-31 06:52:17 -080086
Florin Corasf8f516a2018-02-08 15:10:09 -080087 if self.vpp_dead:
88 self.assert_equal(0)
89
Florin Corasa332c462018-01-31 06:52:17 -080090 # Delete inter-table routes
91 ip_t01.remove_vpp_config()
92 ip_t10.remove_vpp_config()
Florin Coras3ea6ce22017-12-11 09:09:05 -080093
Florin Coras5665ced2018-10-25 18:03:45 -070094
Andrew Yourtchenko8dc0d482021-01-29 13:17:19 +000095@tag_fixme_vpp_workers
Florin Coras5665ced2018-10-25 18:03:45 -070096class TestSessionUnitTests(VppTestCase):
97 """ Session Unit Tests Case """
98
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -070099 @classmethod
100 def setUpClass(cls):
101 super(TestSessionUnitTests, cls).setUpClass()
102
103 @classmethod
104 def tearDownClass(cls):
105 super(TestSessionUnitTests, cls).tearDownClass()
106
Florin Coras5665ced2018-10-25 18:03:45 -0700107 def setUp(self):
108 super(TestSessionUnitTests, self).setUp()
Jakub Grajciar6a2794e2020-11-24 11:22:01 +0100109 self.vapi.session_enable_disable(is_enable=1)
Florin Coras5665ced2018-10-25 18:03:45 -0700110
111 def test_session(self):
112 """ Session Unit Tests """
113 error = self.vapi.cli("test session all")
114
115 if error:
116 self.logger.critical(error)
Paul Vinciguerra9a6dafd2019-03-06 15:11:28 -0800117 self.assertNotIn("failed", error)
Florin Coras5665ced2018-10-25 18:03:45 -0700118
119 def tearDown(self):
120 super(TestSessionUnitTests, self).tearDown()
Jakub Grajciar6a2794e2020-11-24 11:22:01 +0100121 self.vapi.session_enable_disable(is_enable=0)
Florin Coras5665ced2018-10-25 18:03:45 -0700122
Florin Corasf682fac2019-04-18 20:50:50 -0700123
Andrew Yourtchenko06f32812021-01-14 10:19:08 +0000124@tag_run_solo
Florin Corasf682fac2019-04-18 20:50:50 -0700125class TestSvmFifoUnitTests(VppTestCase):
126 """ SVM Fifo Unit Tests Case """
127
128 @classmethod
129 def setUpClass(cls):
130 super(TestSvmFifoUnitTests, cls).setUpClass()
131
132 @classmethod
133 def tearDownClass(cls):
134 super(TestSvmFifoUnitTests, cls).tearDownClass()
135
136 def setUp(self):
137 super(TestSvmFifoUnitTests, self).setUp()
138
139 def test_svm_fifo(self):
140 """ SVM Fifo Unit Tests """
141 error = self.vapi.cli("test svm fifo all")
142
143 if error:
144 self.logger.critical(error)
145 self.assertNotIn("failed", error)
146
147 def tearDown(self):
148 super(TestSvmFifoUnitTests, self).tearDown()
149
Florin Coras3ea6ce22017-12-11 09:09:05 -0800150if __name__ == '__main__':
151 unittest.main(testRunner=VppTestRunner)