blob: 8a7faad6f0c6af7f5017322e6240ae21769fbf50 [file] [log] [blame]
Dave Wallacecfcf2f42018-02-16 18:31:56 -05001#!/usr/bin/env python
2""" Vpp VCL tests """
3
4import unittest
5import os
Dave Wallace816833f2018-03-14 20:01:28 -04006import subprocess
Dave Wallacecfcf2f42018-02-16 18:31:56 -05007import signal
Dave Wallaced85075e2018-03-02 13:19:30 -05008from framework import VppTestCase, VppTestRunner, running_extended_tests, \
9 Worker
Florin Coras56b39f62018-03-27 17:29:32 -070010from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath, DpoProto
Dave Wallacecfcf2f42018-02-16 18:31:56 -050011
12
Dave Wallace816833f2018-03-14 20:01:28 -040013class VCLAppWorker(Worker):
Dave Wallace42996c02018-02-26 14:40:13 -050014 """ VCL Test Application Worker """
15
Dave Wallaced85075e2018-03-02 13:19:30 -050016 def __init__(self, build_dir, appname, args, logger, env={}):
Damjan Marion855e2682018-08-24 13:37:45 +020017 vcl_lib_dir = "%s/vpp/lib" % build_dir
Dave Wallace816833f2018-03-14 20:01:28 -040018 if "iperf" in appname:
19 app = appname
Dave Wallace9f11c012018-02-28 17:55:23 -050020 env.update({'LD_PRELOAD':
Damjan Marion855e2682018-08-24 13:37:45 +020021 "%s/libvcl_ldpreload.so" % vcl_lib_dir})
Florin Corasab2f6db2018-08-31 14:31:41 -070022 elif "sock" in appname:
23 app = "%s/vpp/bin/%s" % (build_dir, appname)
24 env.update({'LD_PRELOAD':
25 "%s/libvcl_ldpreload.so" % vcl_lib_dir})
Dave Wallace816833f2018-03-14 20:01:28 -040026 else:
Florin Corasab2f6db2018-08-31 14:31:41 -070027 app = "%s/vpp/bin/%s" % (build_dir, appname)
Dave Wallace9f11c012018-02-28 17:55:23 -050028 self.args = [app] + args
Dave Wallace816833f2018-03-14 20:01:28 -040029 super(VCLAppWorker, self).__init__(self.args, logger, env)
Dave Wallace42996c02018-02-26 14:40:13 -050030
31
Dave Wallace816833f2018-03-14 20:01:28 -040032class VCLTestCase(VppTestCase):
Dave Wallace42996c02018-02-26 14:40:13 -050033 """ VCL Test Class """
34
Dave Wallace9f11c012018-02-28 17:55:23 -050035 def __init__(self, methodName):
Dave Wallaced85075e2018-03-02 13:19:30 -050036 var = "VPP_TEST_BUILD_DIR"
37 self.build_dir = os.getenv(var, None)
38 if self.build_dir is None:
39 raise Exception("Environment variable `%s' not set" % var)
40 self.vppDebug = 'vpp_debug' in self.build_dir
Dave Wallace9f11c012018-02-28 17:55:23 -050041 self.server_addr = "127.0.0.1"
42 self.server_port = "22000"
Dave Wallace816833f2018-03-14 20:01:28 -040043 self.server_args = [self.server_port]
Dave Wallacede910062018-03-20 09:22:13 -040044 self.server_ipv6_addr = "::1"
45 self.server_ipv6_args = ["-6", self.server_port]
Florin Coras54693d22018-07-17 10:46:29 -070046 self.timeout = 10
Dave Wallace9f11c012018-02-28 17:55:23 -050047 self.echo_phrase = "Hello, world! Jenny is a friend of mine."
Dave Wallace42996c02018-02-26 14:40:13 -050048
Dave Wallace816833f2018-03-14 20:01:28 -040049 super(VCLTestCase, self).__init__(methodName)
Dave Wallace42996c02018-02-26 14:40:13 -050050
Dave Wallace9f11c012018-02-28 17:55:23 -050051 def cut_thru_setup(self):
Dave Wallacea67a03e2018-02-20 12:39:37 -050052 self.vapi.session_enable_disable(is_enabled=1)
53
Dave Wallace9f11c012018-02-28 17:55:23 -050054 def cut_thru_tear_down(self):
Dave Wallacea67a03e2018-02-20 12:39:37 -050055 self.vapi.session_enable_disable(is_enabled=0)
56
Dave Wallace816833f2018-03-14 20:01:28 -040057 def cut_thru_test(self, server_app, server_args, client_app, client_args):
Dave Wallace42996c02018-02-26 14:40:13 -050058 self.env = {'VCL_API_PREFIX': self.shm_prefix,
59 'VCL_APP_SCOPE_LOCAL': "true"}
60
Dave Wallace816833f2018-03-14 20:01:28 -040061 worker_server = VCLAppWorker(self.build_dir, server_app, server_args,
Dave Wallace42996c02018-02-26 14:40:13 -050062 self.logger, self.env)
Dave Wallacecfcf2f42018-02-16 18:31:56 -050063 worker_server.start()
Dave Wallace42996c02018-02-26 14:40:13 -050064 self.sleep(0.2)
Dave Wallace816833f2018-03-14 20:01:28 -040065 worker_client = VCLAppWorker(self.build_dir, client_app, client_args,
Dave Wallace42996c02018-02-26 14:40:13 -050066 self.logger, self.env)
Dave Wallacecfcf2f42018-02-16 18:31:56 -050067 worker_client.start()
Dave Wallace42996c02018-02-26 14:40:13 -050068 worker_client.join(self.timeout)
Dave Wallacefef3f7b2018-03-09 12:04:10 -050069 try:
70 self.validateResults(worker_client, worker_server, self.timeout)
Klement Sekerab9ef2732018-06-24 22:49:33 +020071 except Exception as error:
Dave Wallacefef3f7b2018-03-09 12:04:10 -050072 self.fail("Failed with %s" % error)
Dave Wallacecfcf2f42018-02-16 18:31:56 -050073
Dave Wallace9f11c012018-02-28 17:55:23 -050074 def thru_host_stack_setup(self):
Dave Wallacea67a03e2018-02-20 12:39:37 -050075 self.vapi.session_enable_disable(is_enabled=1)
Klement Sekerab9ef2732018-06-24 22:49:33 +020076 self.create_loopback_interfaces(2)
Dave Wallacea67a03e2018-02-20 12:39:37 -050077
Florin Coras56b39f62018-03-27 17:29:32 -070078 table_id = 1
Dave Wallacea67a03e2018-02-20 12:39:37 -050079
80 for i in self.lo_interfaces:
81 i.admin_up()
82
83 if table_id != 0:
84 tbl = VppIpTable(self, table_id)
85 tbl.add_vpp_config()
86
87 i.set_table_ip4(table_id)
88 i.config_ip4()
89 table_id += 1
90
91 # Configure namespaces
Florin Coras56b39f62018-03-27 17:29:32 -070092 self.vapi.app_namespace_add(namespace_id="1", secret=1234,
Dave Wallacea67a03e2018-02-20 12:39:37 -050093 sw_if_index=self.loop0.sw_if_index)
Florin Coras56b39f62018-03-27 17:29:32 -070094 self.vapi.app_namespace_add(namespace_id="2", secret=5678,
Dave Wallacea67a03e2018-02-20 12:39:37 -050095 sw_if_index=self.loop1.sw_if_index)
96
Dave Wallacea67a03e2018-02-20 12:39:37 -050097 # Add inter-table routes
98 ip_t01 = VppIpRoute(self, self.loop1.local_ip4, 32,
99 [VppRoutePath("0.0.0.0",
100 0xffffffff,
Florin Coras56b39f62018-03-27 17:29:32 -0700101 nh_table_id=2)], table_id=1)
Dave Wallacea67a03e2018-02-20 12:39:37 -0500102 ip_t10 = VppIpRoute(self, self.loop0.local_ip4, 32,
103 [VppRoutePath("0.0.0.0",
104 0xffffffff,
Florin Coras56b39f62018-03-27 17:29:32 -0700105 nh_table_id=1)], table_id=2)
Dave Wallacea67a03e2018-02-20 12:39:37 -0500106 ip_t01.add_vpp_config()
107 ip_t10.add_vpp_config()
Florin Coras56b39f62018-03-27 17:29:32 -0700108 self.logger.debug(self.vapi.cli("show ip fib"))
Dave Wallacea67a03e2018-02-20 12:39:37 -0500109
Dave Wallace9f11c012018-02-28 17:55:23 -0500110 def thru_host_stack_tear_down(self):
111 for i in self.lo_interfaces:
112 i.unconfig_ip4()
113 i.set_table_ip4(0)
114 i.admin_down()
115
116 self.vapi.session_enable_disable(is_enabled=0)
117
Dave Wallacede910062018-03-20 09:22:13 -0400118 def thru_host_stack_ipv6_setup(self):
119 self.vapi.session_enable_disable(is_enabled=1)
Klement Sekerab9ef2732018-06-24 22:49:33 +0200120 self.create_loopback_interfaces(2)
Dave Wallacede910062018-03-20 09:22:13 -0400121
122 table_id = 1
123
124 for i in self.lo_interfaces:
125 i.admin_up()
126
127 tbl = VppIpTable(self, table_id, is_ip6=1)
128 tbl.add_vpp_config()
129
130 i.set_table_ip6(table_id)
131 i.config_ip6()
132 table_id += 1
133
134 # Configure namespaces
Florin Coras56b39f62018-03-27 17:29:32 -0700135 self.vapi.app_namespace_add(namespace_id="1", secret=1234,
Dave Wallacede910062018-03-20 09:22:13 -0400136 sw_if_index=self.loop0.sw_if_index)
Florin Coras56b39f62018-03-27 17:29:32 -0700137 self.vapi.app_namespace_add(namespace_id="2", secret=5678,
Dave Wallacede910062018-03-20 09:22:13 -0400138 sw_if_index=self.loop1.sw_if_index)
139
140 # Add inter-table routes
141 ip_t01 = VppIpRoute(self, self.loop1.local_ip6, 128,
Florin Coras56b39f62018-03-27 17:29:32 -0700142 [VppRoutePath("::0", 0xffffffff,
143 nh_table_id=2,
144 proto=DpoProto.DPO_PROTO_IP6)],
Dave Wallacede910062018-03-20 09:22:13 -0400145 table_id=1, is_ip6=1)
146 ip_t10 = VppIpRoute(self, self.loop0.local_ip6, 128,
Florin Coras56b39f62018-03-27 17:29:32 -0700147 [VppRoutePath("::0", 0xffffffff,
148 nh_table_id=1,
149 proto=DpoProto.DPO_PROTO_IP6)],
Dave Wallacede910062018-03-20 09:22:13 -0400150 table_id=2, is_ip6=1)
151 ip_t01.add_vpp_config()
152 ip_t10.add_vpp_config()
153 self.logger.debug(self.vapi.cli("show interface addr"))
154 self.logger.debug(self.vapi.cli("show ip6 fib"))
155
156 def thru_host_stack_ipv6_tear_down(self):
157 for i in self.lo_interfaces:
158 i.unconfig_ip6()
159 i.set_table_ip6(0)
160 i.admin_down()
161
162 self.vapi.session_enable_disable(is_enabled=0)
163
Dave Wallace816833f2018-03-14 20:01:28 -0400164 def thru_host_stack_test(self, server_app, server_args,
165 client_app, client_args):
Dave Wallace9f11c012018-02-28 17:55:23 -0500166 self.env = {'VCL_API_PREFIX': self.shm_prefix,
167 'VCL_APP_SCOPE_GLOBAL': "true",
Florin Coras56b39f62018-03-27 17:29:32 -0700168 'VCL_APP_NAMESPACE_ID': "1",
Dave Wallace9f11c012018-02-28 17:55:23 -0500169 'VCL_APP_NAMESPACE_SECRET': "1234"}
170
Dave Wallace816833f2018-03-14 20:01:28 -0400171 worker_server = VCLAppWorker(self.build_dir, server_app, server_args,
Dave Wallace42996c02018-02-26 14:40:13 -0500172 self.logger, self.env)
Dave Wallacea67a03e2018-02-20 12:39:37 -0500173 worker_server.start()
Dave Wallace42996c02018-02-26 14:40:13 -0500174 self.sleep(0.2)
175
Florin Coras56b39f62018-03-27 17:29:32 -0700176 self.env.update({'VCL_APP_NAMESPACE_ID': "2",
Dave Wallace42996c02018-02-26 14:40:13 -0500177 'VCL_APP_NAMESPACE_SECRET': "5678"})
Dave Wallace816833f2018-03-14 20:01:28 -0400178 worker_client = VCLAppWorker(self.build_dir, client_app, client_args,
Dave Wallace42996c02018-02-26 14:40:13 -0500179 self.logger, self.env)
Dave Wallacea67a03e2018-02-20 12:39:37 -0500180 worker_client.start()
Dave Wallace42996c02018-02-26 14:40:13 -0500181 worker_client.join(self.timeout)
182
Dave Wallacefef3f7b2018-03-09 12:04:10 -0500183 try:
184 self.validateResults(worker_client, worker_server, self.timeout)
Klement Sekerab9ef2732018-06-24 22:49:33 +0200185 except Exception as error:
Dave Wallacefef3f7b2018-03-09 12:04:10 -0500186 self.fail("Failed with %s" % error)
Dave Wallacea67a03e2018-02-20 12:39:37 -0500187
Dave Wallace9f11c012018-02-28 17:55:23 -0500188 def validateResults(self, worker_client, worker_server, timeout):
Dave Wallaced85075e2018-03-02 13:19:30 -0500189 if os.path.isdir('/proc/{}'.format(worker_server.process.pid)):
190 self.logger.info("Killing server worker process (pid %d)" %
191 worker_server.process.pid)
192 os.killpg(os.getpgid(worker_server.process.pid), signal.SIGTERM)
193 worker_server.join()
Dave Wallace9f11c012018-02-28 17:55:23 -0500194 self.logger.info("Client worker result is `%s'" % worker_client.result)
195 error = False
196 if worker_client.result is None:
197 try:
198 error = True
199 self.logger.error(
Dave Wallaced85075e2018-03-02 13:19:30 -0500200 "Timeout: %ss! Killing client worker process (pid %d)" %
201 (timeout, worker_client.process.pid))
Dave Wallace9f11c012018-02-28 17:55:23 -0500202 os.killpg(os.getpgid(worker_client.process.pid),
203 signal.SIGTERM)
204 worker_client.join()
205 except:
206 self.logger.debug(
207 "Couldn't kill client worker process")
208 raise
209 if error:
Dave Wallace9f11c012018-02-28 17:55:23 -0500210 raise Exception(
211 "Timeout! Client worker did not finish in %ss" % timeout)
212 self.assert_equal(worker_client.result, 0, "Binary test return code")
213
214
Dave Wallace816833f2018-03-14 20:01:28 -0400215class VCLCutThruTestCase(VCLTestCase):
Dave Wallace9f11c012018-02-28 17:55:23 -0500216 """ VCL Cut Thru Tests """
217
218 def setUp(self):
219 super(VCLCutThruTestCase, self).setUp()
220
221 self.cut_thru_setup()
Dave Wallacede910062018-03-20 09:22:13 -0400222 self.client_echo_test_args = ["-E", self.echo_phrase, "-X",
223 self.server_addr, self.server_port]
Dave Wallace816833f2018-03-14 20:01:28 -0400224 self.client_iperf3_timeout = 20
Florin Corasab2f6db2018-08-31 14:31:41 -0700225 self.client_iperf3_args = ["-V4d", "-t 5", "-c", self.server_addr]
Dave Wallace816833f2018-03-14 20:01:28 -0400226 self.server_iperf3_args = ["-V4d", "-s"]
Dave Wallaced85075e2018-03-02 13:19:30 -0500227 self.client_uni_dir_nsock_timeout = 60
Dave Wallacede910062018-03-20 09:22:13 -0400228 self.client_uni_dir_nsock_test_args = ["-I", "5", "-U", "-X",
229 self.server_addr,
230 self.server_port]
Dave Wallaced85075e2018-03-02 13:19:30 -0500231 self.client_bi_dir_nsock_timeout = 120
Dave Wallacede910062018-03-20 09:22:13 -0400232 self.client_bi_dir_nsock_test_args = ["-I", "2", "-B", "-X",
233 self.server_addr,
234 self.server_port]
Dave Wallace9f11c012018-02-28 17:55:23 -0500235
236 def tearDown(self):
237 self.cut_thru_tear_down()
238
239 super(VCLCutThruTestCase, self).tearDown()
240
241 def test_ldp_cut_thru_echo(self):
242 """ run LDP cut thru echo test """
243
Florin Corasab2f6db2018-08-31 14:31:41 -0700244 self.cut_thru_test("sock_test_server", self.server_args,
245 "sock_test_client", self.client_echo_test_args)
Dave Wallace816833f2018-03-14 20:01:28 -0400246
247 def test_ldp_cut_thru_iperf3(self):
248 """ run LDP cut thru iperf3 test """
249
250 try:
251 subprocess.check_output(['iperf3', '-v'])
252 except:
253 self.logger.error("WARNING: 'iperf3' is not installed,")
254 self.logger.error(" 'test_ldp_cut_thru_iperf3' not run!")
255 return
256
257 self.timeout = self.client_iperf3_timeout
258 self.cut_thru_test("iperf3", self.server_iperf3_args,
259 "iperf3", self.client_iperf3_args)
Dave Wallace9f11c012018-02-28 17:55:23 -0500260
Dave Wallaced85075e2018-03-02 13:19:30 -0500261 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
262 def test_ldp_cut_thru_uni_dir_nsock(self):
263 """ run LDP cut thru uni-directional (multiple sockets) test """
264
265 self.timeout = self.client_uni_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700266 self.cut_thru_test("sock_test_server", self.server_args,
267 "sock_test_client",
Dave Wallaced85075e2018-03-02 13:19:30 -0500268 self.client_uni_dir_nsock_test_args)
269
270 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
271 def test_ldp_cut_thru_bi_dir_nsock(self):
272 """ run LDP cut thru bi-directional (multiple sockets) test """
273
274 self.timeout = self.client_bi_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700275 self.cut_thru_test("sock_test_server", self.server_args,
276 "sock_test_client",
Dave Wallaced85075e2018-03-02 13:19:30 -0500277 self.client_bi_dir_nsock_test_args)
278
Dave Wallace9f11c012018-02-28 17:55:23 -0500279 def test_vcl_cut_thru_echo(self):
280 """ run VCL cut thru echo test """
281
Florin Corasab2f6db2018-08-31 14:31:41 -0700282 self.cut_thru_test("vcl_test_server", self.server_args,
283 "vcl_test_client", self.client_echo_test_args)
Dave Wallace9f11c012018-02-28 17:55:23 -0500284
Dave Wallaced85075e2018-03-02 13:19:30 -0500285 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
286 def test_vcl_cut_thru_uni_dir_nsock(self):
287 """ run VCL cut thru uni-directional (multiple sockets) test """
288
289 self.timeout = self.client_uni_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700290 self.cut_thru_test("vcl_test_server", self.server_args,
291 "vcl_test_client",
Dave Wallaced85075e2018-03-02 13:19:30 -0500292 self.client_uni_dir_nsock_test_args)
293
294 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
295 def test_vcl_cut_thru_bi_dir_nsock(self):
296 """ run VCL cut thru bi-directional (multiple sockets) test """
297
298 self.timeout = self.client_bi_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700299 self.cut_thru_test("vcl_test_server", self.server_args,
300 "vcl_test_client",
Dave Wallaced85075e2018-03-02 13:19:30 -0500301 self.client_bi_dir_nsock_test_args)
302
Dave Wallace9f11c012018-02-28 17:55:23 -0500303
Dave Wallace816833f2018-03-14 20:01:28 -0400304class VCLThruHostStackTestCase(VCLTestCase):
Dave Wallace9f11c012018-02-28 17:55:23 -0500305 """ VCL Thru Host Stack Tests """
306
307 def setUp(self):
308 super(VCLThruHostStackTestCase, self).setUp()
309
310 self.thru_host_stack_setup()
Dave Wallacede910062018-03-20 09:22:13 -0400311 self.client_echo_test_args = ["-E", self.echo_phrase, "-X",
312 self.loop0.local_ip4,
313 self.server_port]
Dave Wallace9f11c012018-02-28 17:55:23 -0500314
315 def tearDown(self):
316 self.thru_host_stack_tear_down()
317
318 super(VCLThruHostStackTestCase, self).tearDown()
319
320 def test_ldp_thru_host_stack_echo(self):
321 """ run LDP thru host stack echo test """
322
Florin Corasab2f6db2018-08-31 14:31:41 -0700323 self.thru_host_stack_test("sock_test_server", self.server_args,
324 "sock_test_client",
Dave Wallace9f11c012018-02-28 17:55:23 -0500325 self.client_echo_test_args)
Dave Wallaced85075e2018-03-02 13:19:30 -0500326 # TBD: Remove these when VPP thru host teardown config bug is fixed.
Florin Corasab2f6db2018-08-31 14:31:41 -0700327 self.thru_host_stack_test("vcl_test_server", self.server_args,
328 "vcl_test_client",
Dave Wallace9f11c012018-02-28 17:55:23 -0500329 self.client_echo_test_args)
330
331 def test_vcl_thru_host_stack_echo(self):
332 """ run VCL thru host stack echo test """
333
Dave Wallaced85075e2018-03-02 13:19:30 -0500334 # TBD: Enable this when VPP thru host teardown config bug is fixed.
Florin Corasab2f6db2018-08-31 14:31:41 -0700335 # self.thru_host_stack_test("vcl_test_server", self.server_args,
336 # "vcl_test_client",
Keith Burns (alagalah)410bcca2018-03-23 13:42:49 -0700337 # self.client_echo_test_args)
Dave Wallace9f11c012018-02-28 17:55:23 -0500338
Dave Wallaced85075e2018-03-02 13:19:30 -0500339 # TBD: Remove VCLThruHostStackExtended*TestCase classes and move
340 # tests here when VPP thru host teardown/setup config bug
341 # is fixed.
342
343
Dave Wallace816833f2018-03-14 20:01:28 -0400344class VCLThruHostStackExtendedATestCase(VCLTestCase):
Dave Wallaced85075e2018-03-02 13:19:30 -0500345 """ VCL Thru Host Stack Extended Tests """
346
347 def setUp(self):
348 super(VCLThruHostStackExtendedATestCase, self).setUp()
349
350 self.thru_host_stack_setup()
351 if self.vppDebug:
352 self.client_bi_dir_nsock_timeout = 120
Dave Wallacede910062018-03-20 09:22:13 -0400353 self.client_bi_dir_nsock_test_args = ["-B", "-X",
354 self.loop0.local_ip4,
355 self.server_port]
Dave Wallaced85075e2018-03-02 13:19:30 -0500356 else:
Dave Wallacede910062018-03-20 09:22:13 -0400357 self.client_bi_dir_nsock_timeout = 90
358 self.client_bi_dir_nsock_test_args = ["-I", "2", "-B", "-X",
359 self.loop0.local_ip4,
360 self.server_port]
Dave Wallaced85075e2018-03-02 13:19:30 -0500361
362 def tearDown(self):
363 self.thru_host_stack_tear_down()
364
365 super(VCLThruHostStackExtendedATestCase, self).tearDown()
366
367 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
368 def test_vcl_thru_host_stack_bi_dir_nsock(self):
369 """ run VCL thru host stack bi-directional (multiple sockets) test """
370
371 self.timeout = self.client_bi_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700372 self.thru_host_stack_test("vcl_test_server", self.server_args,
373 "vcl_test_client",
Dave Wallaced85075e2018-03-02 13:19:30 -0500374 self.client_bi_dir_nsock_test_args)
375
376
Dave Wallace816833f2018-03-14 20:01:28 -0400377class VCLThruHostStackExtendedBTestCase(VCLTestCase):
Dave Wallaced85075e2018-03-02 13:19:30 -0500378 """ VCL Thru Host Stack Extended Tests """
379
380 def setUp(self):
381 super(VCLThruHostStackExtendedBTestCase, self).setUp()
382
383 self.thru_host_stack_setup()
384 if self.vppDebug:
385 self.client_bi_dir_nsock_timeout = 120
Dave Wallacede910062018-03-20 09:22:13 -0400386 self.client_bi_dir_nsock_test_args = ["-B", "-X",
387 self.loop0.local_ip4,
388 self.server_port]
Dave Wallaced85075e2018-03-02 13:19:30 -0500389 else:
390 self.client_bi_dir_nsock_timeout = 60
Dave Wallacede910062018-03-20 09:22:13 -0400391 self.client_bi_dir_nsock_test_args = ["-I", "2", "-B", "-X",
392 self.loop0.local_ip4,
393 self.server_port]
Dave Wallaced85075e2018-03-02 13:19:30 -0500394
395 def tearDown(self):
396 self.thru_host_stack_tear_down()
397
398 super(VCLThruHostStackExtendedBTestCase, self).tearDown()
399
400 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
401 def test_ldp_thru_host_stack_bi_dir_nsock(self):
402 """ run LDP thru host stack bi-directional (multiple sockets) test """
403
404 self.timeout = self.client_bi_dir_nsock_timeout
Dave Wallace816833f2018-03-14 20:01:28 -0400405 self.thru_host_stack_test("sock_test_server", self.server_args,
406 "sock_test_client",
Dave Wallaced85075e2018-03-02 13:19:30 -0500407 self.client_bi_dir_nsock_test_args)
408
409
Dave Wallace816833f2018-03-14 20:01:28 -0400410class VCLThruHostStackExtendedCTestCase(VCLTestCase):
Dave Wallaced85075e2018-03-02 13:19:30 -0500411 """ VCL Thru Host Stack Extended Tests """
412
413 def setUp(self):
414 super(VCLThruHostStackExtendedCTestCase, self).setUp()
415
416 self.thru_host_stack_setup()
417 if self.vppDebug:
418 self.client_uni_dir_nsock_timeout = 120
419 self.numSockets = "2"
420 else:
421 self.client_uni_dir_nsock_timeout = 120
422 self.numSockets = "5"
423
Dave Wallacede910062018-03-20 09:22:13 -0400424 self.client_uni_dir_nsock_test_args = ["-I", self.numSockets,
425 "-U", "-X",
426 self.loop0.local_ip4,
427 self.server_port]
Dave Wallaced85075e2018-03-02 13:19:30 -0500428
429 def tearDown(self):
430 self.thru_host_stack_tear_down()
431
432 super(VCLThruHostStackExtendedCTestCase, self).tearDown()
433
434 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
435 def test_ldp_thru_host_stack_uni_dir_nsock(self):
436 """ run LDP thru host stack uni-directional (multiple sockets) test """
437
438 self.timeout = self.client_uni_dir_nsock_timeout
Dave Wallace816833f2018-03-14 20:01:28 -0400439 self.thru_host_stack_test("sock_test_server", self.server_args,
440 "sock_test_client",
Dave Wallaced85075e2018-03-02 13:19:30 -0500441 self.client_uni_dir_nsock_test_args)
442
443
Dave Wallace816833f2018-03-14 20:01:28 -0400444class VCLThruHostStackExtendedDTestCase(VCLTestCase):
Dave Wallaced85075e2018-03-02 13:19:30 -0500445 """ VCL Thru Host Stack Extended Tests """
446
447 def setUp(self):
448 super(VCLThruHostStackExtendedDTestCase, self).setUp()
449
450 self.thru_host_stack_setup()
451 if self.vppDebug:
452 self.client_uni_dir_nsock_timeout = 120
453 self.numSockets = "2"
454 else:
455 self.client_uni_dir_nsock_timeout = 120
456 self.numSockets = "5"
457
Dave Wallacede910062018-03-20 09:22:13 -0400458 self.client_uni_dir_nsock_test_args = ["-I", self.numSockets,
459 "-U", "-X",
460 self.loop0.local_ip4,
461 self.server_port]
Dave Wallaced85075e2018-03-02 13:19:30 -0500462
463 def tearDown(self):
464 self.thru_host_stack_tear_down()
465
466 super(VCLThruHostStackExtendedDTestCase, self).tearDown()
467
468 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
469 def test_vcl_thru_host_stack_uni_dir_nsock(self):
470 """ run VCL thru host stack uni-directional (multiple sockets) test """
471
472 self.timeout = self.client_uni_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700473 self.thru_host_stack_test("vcl_test_server", self.server_args,
474 "vcl_test_client",
Dave Wallaced85075e2018-03-02 13:19:30 -0500475 self.client_uni_dir_nsock_test_args)
476
477
Dave Wallace816833f2018-03-14 20:01:28 -0400478class VCLThruHostStackIperfTestCase(VCLTestCase):
479 """ VCL Thru Host Stack Iperf Tests """
480
481 def setUp(self):
482 super(VCLThruHostStackIperfTestCase, self).setUp()
483
484 self.thru_host_stack_setup()
485 self.client_iperf3_timeout = 20
Florin Corasab2f6db2018-08-31 14:31:41 -0700486 self.client_iperf3_args = ["-V4d", "-t 5", "-c", self.loop0.local_ip4]
Dave Wallace816833f2018-03-14 20:01:28 -0400487 self.server_iperf3_args = ["-V4d", "-s"]
488
489 def tearDown(self):
490 self.thru_host_stack_tear_down()
491
492 super(VCLThruHostStackIperfTestCase, self).tearDown()
493
494 def test_ldp_thru_host_stack_iperf3(self):
495 """ run LDP thru host stack iperf3 test """
496
497 try:
498 subprocess.check_output(['iperf3', '-v'])
499 except:
500 self.logger.error("WARNING: 'iperf3' is not installed,")
501 self.logger.error(
502 " 'test_ldp_thru_host_stack_iperf3' not run!")
503 return
504
505 self.timeout = self.client_iperf3_timeout
506 self.thru_host_stack_test("iperf3", self.server_iperf3_args,
507 "iperf3", self.client_iperf3_args)
508
509
Dave Wallacede910062018-03-20 09:22:13 -0400510class VCLIpv6CutThruTestCase(VCLTestCase):
511 """ VCL IPv6 Cut Thru Tests """
512
513 def setUp(self):
514 super(VCLIpv6CutThruTestCase, self).setUp()
515
516 self.cut_thru_setup()
517 self.client_iperf3_timeout = 20
518 self.client_uni_dir_nsock_timeout = 60
519 self.client_bi_dir_nsock_timeout = 120
520 self.client_ipv6_echo_test_args = ["-6", "-E", self.echo_phrase, "-X",
521 self.server_ipv6_addr,
522 self.server_port]
Florin Corasab2f6db2018-08-31 14:31:41 -0700523 self.client_ipv6_iperf3_args = ["-V6d", "-t 5", "-c",
524 self.server_ipv6_addr]
Dave Wallacede910062018-03-20 09:22:13 -0400525 self.server_ipv6_iperf3_args = ["-V6d", "-s"]
526 self.client_ipv6_uni_dir_nsock_test_args = ["-6", "-I", "5",
527 "-U", "-X",
528 self.server_ipv6_addr,
529 self.server_port]
530 self.client_ipv6_bi_dir_nsock_test_args = ["-6", "-I", "2",
531 "-B", "-X",
532 self.server_ipv6_addr,
533 self.server_port]
534
535 def tearDown(self):
536 self.cut_thru_tear_down()
537
538 super(VCLIpv6CutThruTestCase, self).tearDown()
539
540 def test_ldp_ipv6_cut_thru_echo(self):
541 """ run LDP IPv6 cut thru echo test """
542
Florin Corasab2f6db2018-08-31 14:31:41 -0700543 self.cut_thru_test("sock_test_server",
Dave Wallacede910062018-03-20 09:22:13 -0400544 self.server_ipv6_args,
Florin Corasab2f6db2018-08-31 14:31:41 -0700545 "sock_test_client",
Dave Wallacede910062018-03-20 09:22:13 -0400546 self.client_ipv6_echo_test_args)
547
548 def test_ldp_ipv6_cut_thru_iperf3(self):
549 """ run LDP IPv6 cut thru iperf3 test """
550
551 try:
552 subprocess.check_output(['iperf3', '-v'])
553 except:
554 self.logger.error("WARNING: 'iperf3' is not installed,")
555 self.logger.error(
556 " 'test_ldp_ipv6_cut_thru_iperf3' not run!")
557 return
558
559 self.timeout = self.client_iperf3_timeout
560 self.cut_thru_test("iperf3", self.server_ipv6_iperf3_args,
561 "iperf3", self.client_ipv6_iperf3_args)
562
563 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
564 def test_ldp_ipv6_cut_thru_uni_dir_nsock(self):
565 """ run LDP IPv6 cut thru uni-directional (multiple sockets) test """
566
567 self.timeout = self.client_uni_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700568 self.cut_thru_test("sock_test_server", self.server_ipv6_args,
569 "sock_test_client",
Dave Wallacede910062018-03-20 09:22:13 -0400570 self.client_ipv6_uni_dir_nsock_test_args)
571
572 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
573 def test_ldp_ipv6_cut_thru_bi_dir_nsock(self):
574 """ run LDP IPv6 cut thru bi-directional (multiple sockets) test """
575
576 self.timeout = self.client_bi_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700577 self.cut_thru_test("sock_test_server", self.server_ipv6_args,
578 "sock_test_client",
Dave Wallacede910062018-03-20 09:22:13 -0400579 self.client_ipv6_bi_dir_nsock_test_args)
580
581 def test_vcl_ipv6_cut_thru_echo(self):
582 """ run VCL IPv6 cut thru echo test """
583
Florin Corasab2f6db2018-08-31 14:31:41 -0700584 self.cut_thru_test("vcl_test_server",
Dave Wallacede910062018-03-20 09:22:13 -0400585 self.server_ipv6_args,
Florin Corasab2f6db2018-08-31 14:31:41 -0700586 "vcl_test_client",
Dave Wallacede910062018-03-20 09:22:13 -0400587 self.client_ipv6_echo_test_args)
588
589 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
590 def test_vcl_ipv6_cut_thru_uni_dir_nsock(self):
591 """ run VCL IPv6 cut thru uni-directional (multiple sockets) test """
592
593 self.timeout = self.client_uni_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700594 self.cut_thru_test("vcl_test_server", self.server_ipv6_args,
595 "vcl_test_client",
Dave Wallacede910062018-03-20 09:22:13 -0400596 self.client_ipv6_uni_dir_nsock_test_args)
597
598 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
599 def test_vcl_ipv6_cut_thru_bi_dir_nsock(self):
600 """ run VCL IPv6 cut thru bi-directional (multiple sockets) test """
601
602 self.timeout = self.client_bi_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700603 self.cut_thru_test("vcl_test_server", self.server_ipv6_args,
604 "vcl_test_client",
Dave Wallacede910062018-03-20 09:22:13 -0400605 self.client_ipv6_bi_dir_nsock_test_args)
606
607
608class VCLIpv6ThruHostStackTestCase(VCLTestCase):
609 """ VCL IPv6 Thru Host Stack Tests """
610
611 def setUp(self):
612 super(VCLIpv6ThruHostStackTestCase, self).setUp()
613
614 self.thru_host_stack_ipv6_setup()
615 self.client_ipv6_echo_test_args = ["-6", "-E", self.echo_phrase, "-X",
616 self.loop0.local_ip6,
617 self.server_port]
618
619 def tearDown(self):
620 self.thru_host_stack_ipv6_tear_down()
621
622 super(VCLIpv6ThruHostStackTestCase, self).tearDown()
623
624 def test_ldp_ipv6_thru_host_stack_echo(self):
625 """ run LDP IPv6 thru host stack echo test """
626
Florin Corasab2f6db2018-08-31 14:31:41 -0700627 self.thru_host_stack_test("sock_test_server",
Damjan Marion855e2682018-08-24 13:37:45 +0200628 self.server_ipv6_args,
Florin Corasab2f6db2018-08-31 14:31:41 -0700629 "sock_test_client",
Dave Wallacede910062018-03-20 09:22:13 -0400630 self.client_ipv6_echo_test_args)
631 # TBD: Remove these when VPP thru host teardown config bug is fixed.
Florin Corasab2f6db2018-08-31 14:31:41 -0700632 self.thru_host_stack_test("vcl_test_server",
Damjan Marion855e2682018-08-24 13:37:45 +0200633 self.server_ipv6_args,
Florin Corasab2f6db2018-08-31 14:31:41 -0700634 "vcl_test_client",
Dave Wallacede910062018-03-20 09:22:13 -0400635 self.client_ipv6_echo_test_args)
636
637 def test_vcl_ipv6_thru_host_stack_echo(self):
638 """ run VCL IPv6 thru host stack echo test """
639
Florin Corasab2f6db2018-08-31 14:31:41 -0700640# self.thru_host_stack_test("vcl_test_server",
Damjan Marion855e2682018-08-24 13:37:45 +0200641# self.server_ipv6_args,
Florin Corasab2f6db2018-08-31 14:31:41 -0700642# "vcl_test_client",
Keith Burns (alagalah)410bcca2018-03-23 13:42:49 -0700643# self.client_ipv6_echo_test_args)
Dave Wallacede910062018-03-20 09:22:13 -0400644
645 # TBD: Remove VCLIpv6ThruHostStackExtended*TestCase classes and move
646 # tests here when VPP thru host teardown/setup config bug
647 # is fixed.
648
649
650class VCLIpv6ThruHostStackExtendedATestCase(VCLTestCase):
651 """ VCL IPv6 Thru Host Stack Extended Tests """
652
653 def setUp(self):
654 super(VCLIpv6ThruHostStackExtendedATestCase, self).setUp()
655
656 self.thru_host_stack_ipv6_setup()
657 if self.vppDebug:
658 self.client_bi_dir_nsock_timeout = 120
659 self.client_ipv6_bi_dir_nsock_test_args = ["-6", "-B", "-X",
660 self.loop0.local_ip6,
661 self.server_port]
662 else:
663 self.client_bi_dir_nsock_timeout = 90
664 self.client_ipv6_bi_dir_nsock_test_args = ["-6", "-I",
665 "2", "-B", "-X",
666 self.loop0.local_ip6,
667 self.server_port]
668
669 def tearDown(self):
670 self.thru_host_stack_ipv6_tear_down()
671
672 super(VCLIpv6ThruHostStackExtendedATestCase, self).tearDown()
673
674 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
675 def test_vcl_thru_host_stack_bi_dir_nsock(self):
676 """ run VCL thru host stack bi-directional (multiple sockets) test """
677
678 self.timeout = self.client_bi_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700679 self.thru_host_stack_test("vcl_test_server", self.server_ipv6_args,
680 "vcl_test_client",
Dave Wallacede910062018-03-20 09:22:13 -0400681 self.client_ipv6_bi_dir_nsock_test_args)
682
683
684class VCLIpv6ThruHostStackExtendedBTestCase(VCLTestCase):
685 """ VCL IPv6 Thru Host Stack Extended Tests """
686
687 def setUp(self):
688 super(VCLIpv6ThruHostStackExtendedBTestCase, self).setUp()
689
690 self.thru_host_stack_ipv6_setup()
691 if self.vppDebug:
692 self.client_bi_dir_nsock_timeout = 120
693 self.client_ipv6_bi_dir_nsock_test_args = ["-6", "-B", "-X",
694 self.loop0.local_ip6,
695 self.server_port]
696 else:
697 self.client_bi_dir_nsock_timeout = 60
698 self.client_ipv6_bi_dir_nsock_test_args = ["-6", "-I", "2",
699 "-B", "-X",
700 self.loop0.local_ip6,
701 self.server_port]
702
703 def tearDown(self):
704 self.thru_host_stack_ipv6_tear_down()
705
706 super(VCLIpv6ThruHostStackExtendedBTestCase, self).tearDown()
707
708 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
709 def test_ldp_thru_host_stack_bi_dir_nsock(self):
710 """ run LDP thru host stack bi-directional (multiple sockets) test """
711
712 self.timeout = self.client_bi_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700713 self.thru_host_stack_test("sock_test_server",
Damjan Marion855e2682018-08-24 13:37:45 +0200714 self.server_ipv6_args,
Florin Corasab2f6db2018-08-31 14:31:41 -0700715 "sock_test_client",
Dave Wallacede910062018-03-20 09:22:13 -0400716 self.client_ipv6_bi_dir_nsock_test_args)
717
718
719class VCLIpv6ThruHostStackExtendedCTestCase(VCLTestCase):
720 """ VCL IPv6 Thru Host Stack Extended Tests """
721
722 def setUp(self):
723 super(VCLIpv6ThruHostStackExtendedCTestCase, self).setUp()
724
725 self.thru_host_stack_ipv6_setup()
726 if self.vppDebug:
727 self.client_uni_dir_nsock_timeout = 120
728 self.numSockets = "2"
729 else:
730 self.client_uni_dir_nsock_timeout = 120
731 self.numSockets = "5"
732
733 self.client_ipv6_uni_dir_nsock_test_args = ["-6",
734 "-I", self.numSockets,
735 "-U", "-X",
736 self.loop0.local_ip6,
737 self.server_port]
738
739 def tearDown(self):
740 self.thru_host_stack_ipv6_tear_down()
741
742 super(VCLIpv6ThruHostStackExtendedCTestCase, self).tearDown()
743
744 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
745 def test_ldp_thru_host_stack_uni_dir_nsock(self):
746 """ run LDP thru host stack uni-directional (multiple sockets) test """
747
748 self.timeout = self.client_uni_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700749 self.thru_host_stack_test("sock_test_server",
Damjan Marion855e2682018-08-24 13:37:45 +0200750 self.server_ipv6_args,
Florin Corasab2f6db2018-08-31 14:31:41 -0700751 "sock_test_client",
Dave Wallacede910062018-03-20 09:22:13 -0400752 self.client_ipv6_uni_dir_nsock_test_args)
753
754
755class VCLIpv6ThruHostStackExtendedDTestCase(VCLTestCase):
756 """ VCL IPv6 Thru Host Stack Extended Tests """
757
758 def setUp(self):
759 super(VCLIpv6ThruHostStackExtendedDTestCase, self).setUp()
760
761 self.thru_host_stack_ipv6_setup()
762 if self.vppDebug:
763 self.client_uni_dir_nsock_timeout = 120
764 self.numSockets = "2"
765 else:
766 self.client_uni_dir_nsock_timeout = 120
767 self.numSockets = "5"
768
769 self.client_ipv6_uni_dir_nsock_test_args = ["-6",
770 "-I", self.numSockets,
771 "-U", "-X",
772 self.loop0.local_ip6,
773 self.server_port]
774
775 def tearDown(self):
776 self.thru_host_stack_ipv6_tear_down()
777
778 super(VCLIpv6ThruHostStackExtendedDTestCase, self).tearDown()
779
780 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
781 def test_vcl_thru_host_stack_uni_dir_nsock(self):
782 """ run VCL thru host stack uni-directional (multiple sockets) test """
783
784 self.timeout = self.client_uni_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700785 self.thru_host_stack_test("vcl_test_server", self.server_ipv6_args,
786 "vcl_test_client",
Dave Wallacede910062018-03-20 09:22:13 -0400787 self.client_ipv6_uni_dir_nsock_test_args)
788
789
790class VCLIpv6ThruHostStackIperfTestCase(VCLTestCase):
791 """ VCL IPv6 Thru Host Stack Iperf Tests """
792
793 def setUp(self):
794 super(VCLIpv6ThruHostStackIperfTestCase, self).setUp()
795
796 self.thru_host_stack_ipv6_setup()
797 self.client_iperf3_timeout = 20
Florin Corasab2f6db2018-08-31 14:31:41 -0700798 self.client_ipv6_iperf3_args = ["-V6d", "-t 5", "-c",
799 self.loop0.local_ip6]
Dave Wallacede910062018-03-20 09:22:13 -0400800 self.server_ipv6_iperf3_args = ["-V6d", "-s"]
801
802 def tearDown(self):
803 self.thru_host_stack_ipv6_tear_down()
804
805 super(VCLIpv6ThruHostStackIperfTestCase, self).tearDown()
806
Florin Coras56b39f62018-03-27 17:29:32 -0700807 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
Dave Wallacede910062018-03-20 09:22:13 -0400808 def test_ldp_thru_host_stack_iperf3(self):
809 """ run LDP thru host stack iperf3 test """
810
811 try:
812 subprocess.check_output(['iperf3', '-v'])
813 except:
814 self.logger.error("WARNING: 'iperf3' is not installed,")
815 self.logger.error(
816 " 'test_ldp_thru_host_stack_iperf3' not run!")
817 return
818
819 self.timeout = self.client_iperf3_timeout
820 self.thru_host_stack_test("iperf3", self.server_ipv6_iperf3_args,
821 "iperf3", self.client_ipv6_iperf3_args)
822
823
Dave Wallacecfcf2f42018-02-16 18:31:56 -0500824if __name__ == '__main__':
825 unittest.main(testRunner=VppTestRunner)