blob: b427c94538324b17a3588042ae62c42746493464 [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
Dave Wallacea67a03e2018-02-20 12:39:37 -050010from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath
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={}):
Dave Wallace9f11c012018-02-28 17:55:23 -050017 vcl_lib_dir = "%s/vpp/.libs" % 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':
21 "%s/libvcl_ldpreload.so.0.0.0" % vcl_lib_dir})
Dave Wallace816833f2018-03-14 20:01:28 -040022 else:
23 app = "%s/%s" % (vcl_lib_dir, appname)
24 if not os.path.isfile(app):
25 app = "%s/vpp/%s" % (build_dir, appname)
26 env.update({'LD_PRELOAD':
27 "%s/libvcl_ldpreload.so.0.0.0" % vcl_lib_dir})
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]
Dave Wallace9f11c012018-02-28 17:55:23 -050046 self.timeout = 3
47 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)
71 except Exception, error:
72 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)
76 self.create_loopback_interfaces(range(2))
77
78 table_id = 0
79
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
Dave Wallace42996c02018-02-26 14:40:13 -050092 self.vapi.app_namespace_add(namespace_id="0", secret=1234,
Dave Wallacea67a03e2018-02-20 12:39:37 -050093 sw_if_index=self.loop0.sw_if_index)
Dave Wallace42996c02018-02-26 14:40:13 -050094 self.vapi.app_namespace_add(namespace_id="1", 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,
101 nh_table_id=1)])
102 ip_t10 = VppIpRoute(self, self.loop0.local_ip4, 32,
103 [VppRoutePath("0.0.0.0",
104 0xffffffff,
105 nh_table_id=0)], table_id=1)
106 ip_t01.add_vpp_config()
107 ip_t10.add_vpp_config()
108
Dave Wallace9f11c012018-02-28 17:55:23 -0500109 def thru_host_stack_tear_down(self):
110 for i in self.lo_interfaces:
111 i.unconfig_ip4()
112 i.set_table_ip4(0)
113 i.admin_down()
114
115 self.vapi.session_enable_disable(is_enabled=0)
116
Dave Wallacede910062018-03-20 09:22:13 -0400117 def thru_host_stack_ipv6_setup(self):
118 self.vapi.session_enable_disable(is_enabled=1)
119 self.create_loopback_interfaces(range(2))
120
121 table_id = 1
122
123 for i in self.lo_interfaces:
124 i.admin_up()
125
126 tbl = VppIpTable(self, table_id, is_ip6=1)
127 tbl.add_vpp_config()
128
129 i.set_table_ip6(table_id)
130 i.config_ip6()
131 table_id += 1
132
133 # Configure namespaces
134 self.vapi.app_namespace_add(namespace_id="0", secret=1234,
135 sw_if_index=self.loop0.sw_if_index)
136 self.vapi.app_namespace_add(namespace_id="1", secret=5678,
137 sw_if_index=self.loop1.sw_if_index)
138
139 # Add inter-table routes
140 ip_t01 = VppIpRoute(self, self.loop1.local_ip6, 128,
141 [VppRoutePath("0.0.0.0", 0xffffffff,
142 nh_table_id=2)],
143 table_id=1, is_ip6=1)
144 ip_t10 = VppIpRoute(self, self.loop0.local_ip6, 128,
145 [VppRoutePath("0.0.0.0", 0xffffffff,
146 nh_table_id=1)],
147 table_id=2, is_ip6=1)
148 ip_t01.add_vpp_config()
149 ip_t10.add_vpp_config()
150 self.logger.debug(self.vapi.cli("show interface addr"))
151 self.logger.debug(self.vapi.cli("show ip6 fib"))
152
153 def thru_host_stack_ipv6_tear_down(self):
154 for i in self.lo_interfaces:
155 i.unconfig_ip6()
156 i.set_table_ip6(0)
157 i.admin_down()
158
159 self.vapi.session_enable_disable(is_enabled=0)
160
Dave Wallace816833f2018-03-14 20:01:28 -0400161 def thru_host_stack_test(self, server_app, server_args,
162 client_app, client_args):
Dave Wallace9f11c012018-02-28 17:55:23 -0500163 self.env = {'VCL_API_PREFIX': self.shm_prefix,
164 'VCL_APP_SCOPE_GLOBAL': "true",
165 'VCL_APP_NAMESPACE_ID': "0",
166 'VCL_APP_NAMESPACE_SECRET': "1234"}
167
Dave Wallace816833f2018-03-14 20:01:28 -0400168 worker_server = VCLAppWorker(self.build_dir, server_app, server_args,
Dave Wallace42996c02018-02-26 14:40:13 -0500169 self.logger, self.env)
Dave Wallacea67a03e2018-02-20 12:39:37 -0500170 worker_server.start()
Dave Wallace42996c02018-02-26 14:40:13 -0500171 self.sleep(0.2)
172
173 self.env.update({'VCL_APP_NAMESPACE_ID': "1",
174 'VCL_APP_NAMESPACE_SECRET': "5678"})
Dave Wallace816833f2018-03-14 20:01:28 -0400175 worker_client = VCLAppWorker(self.build_dir, client_app, client_args,
Dave Wallace42996c02018-02-26 14:40:13 -0500176 self.logger, self.env)
Dave Wallacea67a03e2018-02-20 12:39:37 -0500177 worker_client.start()
Dave Wallace42996c02018-02-26 14:40:13 -0500178 worker_client.join(self.timeout)
179
Dave Wallacefef3f7b2018-03-09 12:04:10 -0500180 try:
181 self.validateResults(worker_client, worker_server, self.timeout)
182 except Exception, error:
183 self.fail("Failed with %s" % error)
Dave Wallacea67a03e2018-02-20 12:39:37 -0500184
Dave Wallace9f11c012018-02-28 17:55:23 -0500185 def validateResults(self, worker_client, worker_server, timeout):
Dave Wallaced85075e2018-03-02 13:19:30 -0500186 if os.path.isdir('/proc/{}'.format(worker_server.process.pid)):
187 self.logger.info("Killing server worker process (pid %d)" %
188 worker_server.process.pid)
189 os.killpg(os.getpgid(worker_server.process.pid), signal.SIGTERM)
190 worker_server.join()
Dave Wallace9f11c012018-02-28 17:55:23 -0500191 self.logger.info("Client worker result is `%s'" % worker_client.result)
192 error = False
193 if worker_client.result is None:
194 try:
195 error = True
196 self.logger.error(
Dave Wallaced85075e2018-03-02 13:19:30 -0500197 "Timeout: %ss! Killing client worker process (pid %d)" %
198 (timeout, worker_client.process.pid))
Dave Wallace9f11c012018-02-28 17:55:23 -0500199 os.killpg(os.getpgid(worker_client.process.pid),
200 signal.SIGTERM)
201 worker_client.join()
202 except:
203 self.logger.debug(
204 "Couldn't kill client worker process")
205 raise
206 if error:
Dave Wallace9f11c012018-02-28 17:55:23 -0500207 raise Exception(
208 "Timeout! Client worker did not finish in %ss" % timeout)
209 self.assert_equal(worker_client.result, 0, "Binary test return code")
210
211
Dave Wallace816833f2018-03-14 20:01:28 -0400212class VCLCutThruTestCase(VCLTestCase):
Dave Wallace9f11c012018-02-28 17:55:23 -0500213 """ VCL Cut Thru Tests """
214
215 def setUp(self):
216 super(VCLCutThruTestCase, self).setUp()
217
218 self.cut_thru_setup()
Dave Wallacede910062018-03-20 09:22:13 -0400219 self.client_echo_test_args = ["-E", self.echo_phrase, "-X",
220 self.server_addr, self.server_port]
Dave Wallace816833f2018-03-14 20:01:28 -0400221 self.client_iperf3_timeout = 20
222 self.client_iperf3_args = ["-V4d", "-c", self.server_addr]
223 self.server_iperf3_args = ["-V4d", "-s"]
Dave Wallaced85075e2018-03-02 13:19:30 -0500224 self.client_uni_dir_nsock_timeout = 60
Dave Wallacede910062018-03-20 09:22:13 -0400225 self.client_uni_dir_nsock_test_args = ["-I", "5", "-U", "-X",
226 self.server_addr,
227 self.server_port]
Dave Wallaced85075e2018-03-02 13:19:30 -0500228 self.client_bi_dir_nsock_timeout = 120
Dave Wallacede910062018-03-20 09:22:13 -0400229 self.client_bi_dir_nsock_test_args = ["-I", "2", "-B", "-X",
230 self.server_addr,
231 self.server_port]
Dave Wallace9f11c012018-02-28 17:55:23 -0500232
233 def tearDown(self):
234 self.cut_thru_tear_down()
235
236 super(VCLCutThruTestCase, self).tearDown()
237
238 def test_ldp_cut_thru_echo(self):
239 """ run LDP cut thru echo test """
240
Dave Wallace816833f2018-03-14 20:01:28 -0400241 self.cut_thru_test("sock_test_server", self.server_args,
242 "sock_test_client", self.client_echo_test_args)
243
244 def test_ldp_cut_thru_iperf3(self):
245 """ run LDP cut thru iperf3 test """
246
247 try:
248 subprocess.check_output(['iperf3', '-v'])
249 except:
250 self.logger.error("WARNING: 'iperf3' is not installed,")
251 self.logger.error(" 'test_ldp_cut_thru_iperf3' not run!")
252 return
253
254 self.timeout = self.client_iperf3_timeout
255 self.cut_thru_test("iperf3", self.server_iperf3_args,
256 "iperf3", self.client_iperf3_args)
Dave Wallace9f11c012018-02-28 17:55:23 -0500257
Dave Wallaced85075e2018-03-02 13:19:30 -0500258 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
259 def test_ldp_cut_thru_uni_dir_nsock(self):
260 """ run LDP cut thru uni-directional (multiple sockets) test """
261
262 self.timeout = self.client_uni_dir_nsock_timeout
Dave Wallace816833f2018-03-14 20:01:28 -0400263 self.cut_thru_test("sock_test_server", self.server_args,
264 "sock_test_client",
Dave Wallaced85075e2018-03-02 13:19:30 -0500265 self.client_uni_dir_nsock_test_args)
266
267 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
268 def test_ldp_cut_thru_bi_dir_nsock(self):
269 """ run LDP cut thru bi-directional (multiple sockets) test """
270
271 self.timeout = self.client_bi_dir_nsock_timeout
Dave Wallace816833f2018-03-14 20:01:28 -0400272 self.cut_thru_test("sock_test_server", self.server_args,
273 "sock_test_client",
Dave Wallaced85075e2018-03-02 13:19:30 -0500274 self.client_bi_dir_nsock_test_args)
275
Dave Wallace9f11c012018-02-28 17:55:23 -0500276 def test_vcl_cut_thru_echo(self):
277 """ run VCL cut thru echo test """
278
Dave Wallace816833f2018-03-14 20:01:28 -0400279 self.cut_thru_test("vcl_test_server", self.server_args,
280 "vcl_test_client", self.client_echo_test_args)
Dave Wallace9f11c012018-02-28 17:55:23 -0500281
Dave Wallaced85075e2018-03-02 13:19:30 -0500282 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
283 def test_vcl_cut_thru_uni_dir_nsock(self):
284 """ run VCL cut thru uni-directional (multiple sockets) test """
285
286 self.timeout = self.client_uni_dir_nsock_timeout
Dave Wallace816833f2018-03-14 20:01:28 -0400287 self.cut_thru_test("vcl_test_server", self.server_args,
288 "vcl_test_client",
Dave Wallaced85075e2018-03-02 13:19:30 -0500289 self.client_uni_dir_nsock_test_args)
290
291 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
292 def test_vcl_cut_thru_bi_dir_nsock(self):
293 """ run VCL cut thru bi-directional (multiple sockets) test """
294
295 self.timeout = self.client_bi_dir_nsock_timeout
Dave Wallace816833f2018-03-14 20:01:28 -0400296 self.cut_thru_test("vcl_test_server", self.server_args,
297 "vcl_test_client",
Dave Wallaced85075e2018-03-02 13:19:30 -0500298 self.client_bi_dir_nsock_test_args)
299
Dave Wallace9f11c012018-02-28 17:55:23 -0500300
Dave Wallace816833f2018-03-14 20:01:28 -0400301class VCLThruHostStackTestCase(VCLTestCase):
Dave Wallace9f11c012018-02-28 17:55:23 -0500302 """ VCL Thru Host Stack Tests """
303
304 def setUp(self):
305 super(VCLThruHostStackTestCase, self).setUp()
306
307 self.thru_host_stack_setup()
Dave Wallacede910062018-03-20 09:22:13 -0400308 self.client_echo_test_args = ["-E", self.echo_phrase, "-X",
309 self.loop0.local_ip4,
310 self.server_port]
Dave Wallace9f11c012018-02-28 17:55:23 -0500311
312 def tearDown(self):
313 self.thru_host_stack_tear_down()
314
315 super(VCLThruHostStackTestCase, self).tearDown()
316
317 def test_ldp_thru_host_stack_echo(self):
318 """ run LDP thru host stack echo test """
319
Dave Wallace816833f2018-03-14 20:01:28 -0400320 self.thru_host_stack_test("sock_test_server", self.server_args,
321 "sock_test_client",
Dave Wallace9f11c012018-02-28 17:55:23 -0500322 self.client_echo_test_args)
Dave Wallaced85075e2018-03-02 13:19:30 -0500323 # TBD: Remove these when VPP thru host teardown config bug is fixed.
Dave Wallace816833f2018-03-14 20:01:28 -0400324 self.thru_host_stack_test("vcl_test_server", self.server_args,
325 "vcl_test_client",
Dave Wallace9f11c012018-02-28 17:55:23 -0500326 self.client_echo_test_args)
327
328 def test_vcl_thru_host_stack_echo(self):
329 """ run VCL thru host stack echo test """
330
Dave Wallaced85075e2018-03-02 13:19:30 -0500331 # TBD: Enable this when VPP thru host teardown config bug is fixed.
Dave Wallace816833f2018-03-14 20:01:28 -0400332 # self.thru_host_stack_test("vcl_test_server", self.server_args,
333 # "vcl_test_client",
Dave Wallace9f11c012018-02-28 17:55:23 -0500334 # self.client_echo_test_args)
335
Dave Wallaced85075e2018-03-02 13:19:30 -0500336 # TBD: Remove VCLThruHostStackExtended*TestCase classes and move
337 # tests here when VPP thru host teardown/setup config bug
338 # is fixed.
339
340
Dave Wallace816833f2018-03-14 20:01:28 -0400341class VCLThruHostStackExtendedATestCase(VCLTestCase):
Dave Wallaced85075e2018-03-02 13:19:30 -0500342 """ VCL Thru Host Stack Extended Tests """
343
344 def setUp(self):
345 super(VCLThruHostStackExtendedATestCase, self).setUp()
346
347 self.thru_host_stack_setup()
348 if self.vppDebug:
349 self.client_bi_dir_nsock_timeout = 120
Dave Wallacede910062018-03-20 09:22:13 -0400350 self.client_bi_dir_nsock_test_args = ["-B", "-X",
351 self.loop0.local_ip4,
352 self.server_port]
Dave Wallaced85075e2018-03-02 13:19:30 -0500353 else:
Dave Wallacede910062018-03-20 09:22:13 -0400354 self.client_bi_dir_nsock_timeout = 90
355 self.client_bi_dir_nsock_test_args = ["-I", "2", "-B", "-X",
356 self.loop0.local_ip4,
357 self.server_port]
Dave Wallaced85075e2018-03-02 13:19:30 -0500358
359 def tearDown(self):
360 self.thru_host_stack_tear_down()
361
362 super(VCLThruHostStackExtendedATestCase, self).tearDown()
363
364 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
365 def test_vcl_thru_host_stack_bi_dir_nsock(self):
366 """ run VCL thru host stack bi-directional (multiple sockets) test """
367
368 self.timeout = self.client_bi_dir_nsock_timeout
Dave Wallace816833f2018-03-14 20:01:28 -0400369 self.thru_host_stack_test("vcl_test_server", self.server_args,
370 "vcl_test_client",
Dave Wallaced85075e2018-03-02 13:19:30 -0500371 self.client_bi_dir_nsock_test_args)
372
373
Dave Wallace816833f2018-03-14 20:01:28 -0400374class VCLThruHostStackExtendedBTestCase(VCLTestCase):
Dave Wallaced85075e2018-03-02 13:19:30 -0500375 """ VCL Thru Host Stack Extended Tests """
376
377 def setUp(self):
378 super(VCLThruHostStackExtendedBTestCase, self).setUp()
379
380 self.thru_host_stack_setup()
381 if self.vppDebug:
382 self.client_bi_dir_nsock_timeout = 120
Dave Wallacede910062018-03-20 09:22:13 -0400383 self.client_bi_dir_nsock_test_args = ["-B", "-X",
384 self.loop0.local_ip4,
385 self.server_port]
Dave Wallaced85075e2018-03-02 13:19:30 -0500386 else:
387 self.client_bi_dir_nsock_timeout = 60
Dave Wallacede910062018-03-20 09:22:13 -0400388 self.client_bi_dir_nsock_test_args = ["-I", "2", "-B", "-X",
389 self.loop0.local_ip4,
390 self.server_port]
Dave Wallaced85075e2018-03-02 13:19:30 -0500391
392 def tearDown(self):
393 self.thru_host_stack_tear_down()
394
395 super(VCLThruHostStackExtendedBTestCase, self).tearDown()
396
397 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
398 def test_ldp_thru_host_stack_bi_dir_nsock(self):
399 """ run LDP thru host stack bi-directional (multiple sockets) test """
400
401 self.timeout = self.client_bi_dir_nsock_timeout
Dave Wallace816833f2018-03-14 20:01:28 -0400402 self.thru_host_stack_test("sock_test_server", self.server_args,
403 "sock_test_client",
Dave Wallaced85075e2018-03-02 13:19:30 -0500404 self.client_bi_dir_nsock_test_args)
405
406
Dave Wallace816833f2018-03-14 20:01:28 -0400407class VCLThruHostStackExtendedCTestCase(VCLTestCase):
Dave Wallaced85075e2018-03-02 13:19:30 -0500408 """ VCL Thru Host Stack Extended Tests """
409
410 def setUp(self):
411 super(VCLThruHostStackExtendedCTestCase, self).setUp()
412
413 self.thru_host_stack_setup()
414 if self.vppDebug:
415 self.client_uni_dir_nsock_timeout = 120
416 self.numSockets = "2"
417 else:
418 self.client_uni_dir_nsock_timeout = 120
419 self.numSockets = "5"
420
Dave Wallacede910062018-03-20 09:22:13 -0400421 self.client_uni_dir_nsock_test_args = ["-I", self.numSockets,
422 "-U", "-X",
423 self.loop0.local_ip4,
424 self.server_port]
Dave Wallaced85075e2018-03-02 13:19:30 -0500425
426 def tearDown(self):
427 self.thru_host_stack_tear_down()
428
429 super(VCLThruHostStackExtendedCTestCase, self).tearDown()
430
431 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
432 def test_ldp_thru_host_stack_uni_dir_nsock(self):
433 """ run LDP thru host stack uni-directional (multiple sockets) test """
434
435 self.timeout = self.client_uni_dir_nsock_timeout
Dave Wallace816833f2018-03-14 20:01:28 -0400436 self.thru_host_stack_test("sock_test_server", self.server_args,
437 "sock_test_client",
Dave Wallaced85075e2018-03-02 13:19:30 -0500438 self.client_uni_dir_nsock_test_args)
439
440
Dave Wallace816833f2018-03-14 20:01:28 -0400441class VCLThruHostStackExtendedDTestCase(VCLTestCase):
Dave Wallaced85075e2018-03-02 13:19:30 -0500442 """ VCL Thru Host Stack Extended Tests """
443
444 def setUp(self):
445 super(VCLThruHostStackExtendedDTestCase, self).setUp()
446
447 self.thru_host_stack_setup()
448 if self.vppDebug:
449 self.client_uni_dir_nsock_timeout = 120
450 self.numSockets = "2"
451 else:
452 self.client_uni_dir_nsock_timeout = 120
453 self.numSockets = "5"
454
Dave Wallacede910062018-03-20 09:22:13 -0400455 self.client_uni_dir_nsock_test_args = ["-I", self.numSockets,
456 "-U", "-X",
457 self.loop0.local_ip4,
458 self.server_port]
Dave Wallaced85075e2018-03-02 13:19:30 -0500459
460 def tearDown(self):
461 self.thru_host_stack_tear_down()
462
463 super(VCLThruHostStackExtendedDTestCase, self).tearDown()
464
465 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
466 def test_vcl_thru_host_stack_uni_dir_nsock(self):
467 """ run VCL thru host stack uni-directional (multiple sockets) test """
468
469 self.timeout = self.client_uni_dir_nsock_timeout
Dave Wallace816833f2018-03-14 20:01:28 -0400470 self.thru_host_stack_test("vcl_test_server", self.server_args,
471 "vcl_test_client",
Dave Wallaced85075e2018-03-02 13:19:30 -0500472 self.client_uni_dir_nsock_test_args)
473
474
Dave Wallace816833f2018-03-14 20:01:28 -0400475class VCLThruHostStackIperfTestCase(VCLTestCase):
476 """ VCL Thru Host Stack Iperf Tests """
477
478 def setUp(self):
479 super(VCLThruHostStackIperfTestCase, self).setUp()
480
481 self.thru_host_stack_setup()
482 self.client_iperf3_timeout = 20
483 self.client_iperf3_args = ["-V4d", "-c", self.loop0.local_ip4]
484 self.server_iperf3_args = ["-V4d", "-s"]
485
486 def tearDown(self):
487 self.thru_host_stack_tear_down()
488
489 super(VCLThruHostStackIperfTestCase, self).tearDown()
490
491 def test_ldp_thru_host_stack_iperf3(self):
492 """ run LDP thru host stack iperf3 test """
493
494 try:
495 subprocess.check_output(['iperf3', '-v'])
496 except:
497 self.logger.error("WARNING: 'iperf3' is not installed,")
498 self.logger.error(
499 " 'test_ldp_thru_host_stack_iperf3' not run!")
500 return
501
502 self.timeout = self.client_iperf3_timeout
503 self.thru_host_stack_test("iperf3", self.server_iperf3_args,
504 "iperf3", self.client_iperf3_args)
505
506
Dave Wallacede910062018-03-20 09:22:13 -0400507class VCLIpv6CutThruTestCase(VCLTestCase):
508 """ VCL IPv6 Cut Thru Tests """
509
510 def setUp(self):
511 super(VCLIpv6CutThruTestCase, self).setUp()
512
513 self.cut_thru_setup()
514 self.client_iperf3_timeout = 20
515 self.client_uni_dir_nsock_timeout = 60
516 self.client_bi_dir_nsock_timeout = 120
517 self.client_ipv6_echo_test_args = ["-6", "-E", self.echo_phrase, "-X",
518 self.server_ipv6_addr,
519 self.server_port]
520 self.client_ipv6_iperf3_args = ["-V6d", "-c", self.server_ipv6_addr]
521 self.server_ipv6_iperf3_args = ["-V6d", "-s"]
522 self.client_ipv6_uni_dir_nsock_test_args = ["-6", "-I", "5",
523 "-U", "-X",
524 self.server_ipv6_addr,
525 self.server_port]
526 self.client_ipv6_bi_dir_nsock_test_args = ["-6", "-I", "2",
527 "-B", "-X",
528 self.server_ipv6_addr,
529 self.server_port]
530
531 def tearDown(self):
532 self.cut_thru_tear_down()
533
534 super(VCLIpv6CutThruTestCase, self).tearDown()
535
536 def test_ldp_ipv6_cut_thru_echo(self):
537 """ run LDP IPv6 cut thru echo test """
538
539 self.cut_thru_test("sock_test_server",
540 self.server_ipv6_args,
541 "sock_test_client",
542 self.client_ipv6_echo_test_args)
543
544 def test_ldp_ipv6_cut_thru_iperf3(self):
545 """ run LDP IPv6 cut thru iperf3 test """
546
547 try:
548 subprocess.check_output(['iperf3', '-v'])
549 except:
550 self.logger.error("WARNING: 'iperf3' is not installed,")
551 self.logger.error(
552 " 'test_ldp_ipv6_cut_thru_iperf3' not run!")
553 return
554
555 self.timeout = self.client_iperf3_timeout
556 self.cut_thru_test("iperf3", self.server_ipv6_iperf3_args,
557 "iperf3", self.client_ipv6_iperf3_args)
558
559 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
560 def test_ldp_ipv6_cut_thru_uni_dir_nsock(self):
561 """ run LDP IPv6 cut thru uni-directional (multiple sockets) test """
562
563 self.timeout = self.client_uni_dir_nsock_timeout
564 self.cut_thru_test("sock_test_server", self.server_ipv6_args,
565 "sock_test_client",
566 self.client_ipv6_uni_dir_nsock_test_args)
567
568 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
569 def test_ldp_ipv6_cut_thru_bi_dir_nsock(self):
570 """ run LDP IPv6 cut thru bi-directional (multiple sockets) test """
571
572 self.timeout = self.client_bi_dir_nsock_timeout
573 self.cut_thru_test("sock_test_server", self.server_ipv6_args,
574 "sock_test_client",
575 self.client_ipv6_bi_dir_nsock_test_args)
576
577 def test_vcl_ipv6_cut_thru_echo(self):
578 """ run VCL IPv6 cut thru echo test """
579
580 self.cut_thru_test("vcl_test_server",
581 self.server_ipv6_args,
582 "vcl_test_client",
583 self.client_ipv6_echo_test_args)
584
585 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
586 def test_vcl_ipv6_cut_thru_uni_dir_nsock(self):
587 """ run VCL IPv6 cut thru uni-directional (multiple sockets) test """
588
589 self.timeout = self.client_uni_dir_nsock_timeout
590 self.cut_thru_test("vcl_test_server", self.server_ipv6_args,
591 "vcl_test_client",
592 self.client_ipv6_uni_dir_nsock_test_args)
593
594 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
595 def test_vcl_ipv6_cut_thru_bi_dir_nsock(self):
596 """ run VCL IPv6 cut thru bi-directional (multiple sockets) test """
597
598 self.timeout = self.client_bi_dir_nsock_timeout
599 self.cut_thru_test("vcl_test_server", self.server_ipv6_args,
600 "vcl_test_client",
601 self.client_ipv6_bi_dir_nsock_test_args)
602
603
604class VCLIpv6ThruHostStackTestCase(VCLTestCase):
605 """ VCL IPv6 Thru Host Stack Tests """
606
607 def setUp(self):
608 super(VCLIpv6ThruHostStackTestCase, self).setUp()
609
610 self.thru_host_stack_ipv6_setup()
611 self.client_ipv6_echo_test_args = ["-6", "-E", self.echo_phrase, "-X",
612 self.loop0.local_ip6,
613 self.server_port]
614
615 def tearDown(self):
616 self.thru_host_stack_ipv6_tear_down()
617
618 super(VCLIpv6ThruHostStackTestCase, self).tearDown()
619
620 def test_ldp_ipv6_thru_host_stack_echo(self):
621 """ run LDP IPv6 thru host stack echo test """
622
623 self.thru_host_stack_test("sock_test_server", self.server_ipv6_args,
624 "sock_test_client",
625 self.client_ipv6_echo_test_args)
626 # TBD: Remove these when VPP thru host teardown config bug is fixed.
627 self.thru_host_stack_test("vcl_test_server", self.server_ipv6_args,
628 "vcl_test_client",
629 self.client_ipv6_echo_test_args)
630
631 def test_vcl_ipv6_thru_host_stack_echo(self):
632 """ run VCL IPv6 thru host stack echo test """
633
634 # TBD: Enable this when VPP IPv6 thru host teardown
635 # config bug is fixed.
636 # self.thru_host_stack_test("vcl_test_server", self.server_ipv6_args,
637 # "vcl_test_client",
638 # self.client_ipv6_echo_test_args)
639
640 # TBD: Remove VCLIpv6ThruHostStackExtended*TestCase classes and move
641 # tests here when VPP thru host teardown/setup config bug
642 # is fixed.
643
644
645class VCLIpv6ThruHostStackExtendedATestCase(VCLTestCase):
646 """ VCL IPv6 Thru Host Stack Extended Tests """
647
648 def setUp(self):
649 super(VCLIpv6ThruHostStackExtendedATestCase, self).setUp()
650
651 self.thru_host_stack_ipv6_setup()
652 if self.vppDebug:
653 self.client_bi_dir_nsock_timeout = 120
654 self.client_ipv6_bi_dir_nsock_test_args = ["-6", "-B", "-X",
655 self.loop0.local_ip6,
656 self.server_port]
657 else:
658 self.client_bi_dir_nsock_timeout = 90
659 self.client_ipv6_bi_dir_nsock_test_args = ["-6", "-I",
660 "2", "-B", "-X",
661 self.loop0.local_ip6,
662 self.server_port]
663
664 def tearDown(self):
665 self.thru_host_stack_ipv6_tear_down()
666
667 super(VCLIpv6ThruHostStackExtendedATestCase, self).tearDown()
668
669 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
670 def test_vcl_thru_host_stack_bi_dir_nsock(self):
671 """ run VCL thru host stack bi-directional (multiple sockets) test """
672
673 self.timeout = self.client_bi_dir_nsock_timeout
674 self.thru_host_stack_test("vcl_test_server", self.server_ipv6_args,
675 "vcl_test_client",
676 self.client_ipv6_bi_dir_nsock_test_args)
677
678
679class VCLIpv6ThruHostStackExtendedBTestCase(VCLTestCase):
680 """ VCL IPv6 Thru Host Stack Extended Tests """
681
682 def setUp(self):
683 super(VCLIpv6ThruHostStackExtendedBTestCase, self).setUp()
684
685 self.thru_host_stack_ipv6_setup()
686 if self.vppDebug:
687 self.client_bi_dir_nsock_timeout = 120
688 self.client_ipv6_bi_dir_nsock_test_args = ["-6", "-B", "-X",
689 self.loop0.local_ip6,
690 self.server_port]
691 else:
692 self.client_bi_dir_nsock_timeout = 60
693 self.client_ipv6_bi_dir_nsock_test_args = ["-6", "-I", "2",
694 "-B", "-X",
695 self.loop0.local_ip6,
696 self.server_port]
697
698 def tearDown(self):
699 self.thru_host_stack_ipv6_tear_down()
700
701 super(VCLIpv6ThruHostStackExtendedBTestCase, self).tearDown()
702
703 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
704 def test_ldp_thru_host_stack_bi_dir_nsock(self):
705 """ run LDP thru host stack bi-directional (multiple sockets) test """
706
707 self.timeout = self.client_bi_dir_nsock_timeout
708 self.thru_host_stack_test("sock_test_server", self.server_ipv6_args,
709 "sock_test_client",
710 self.client_ipv6_bi_dir_nsock_test_args)
711
712
713class VCLIpv6ThruHostStackExtendedCTestCase(VCLTestCase):
714 """ VCL IPv6 Thru Host Stack Extended Tests """
715
716 def setUp(self):
717 super(VCLIpv6ThruHostStackExtendedCTestCase, self).setUp()
718
719 self.thru_host_stack_ipv6_setup()
720 if self.vppDebug:
721 self.client_uni_dir_nsock_timeout = 120
722 self.numSockets = "2"
723 else:
724 self.client_uni_dir_nsock_timeout = 120
725 self.numSockets = "5"
726
727 self.client_ipv6_uni_dir_nsock_test_args = ["-6",
728 "-I", self.numSockets,
729 "-U", "-X",
730 self.loop0.local_ip6,
731 self.server_port]
732
733 def tearDown(self):
734 self.thru_host_stack_ipv6_tear_down()
735
736 super(VCLIpv6ThruHostStackExtendedCTestCase, self).tearDown()
737
738 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
739 def test_ldp_thru_host_stack_uni_dir_nsock(self):
740 """ run LDP thru host stack uni-directional (multiple sockets) test """
741
742 self.timeout = self.client_uni_dir_nsock_timeout
743 self.thru_host_stack_test("sock_test_server", self.server_ipv6_args,
744 "sock_test_client",
745 self.client_ipv6_uni_dir_nsock_test_args)
746
747
748class VCLIpv6ThruHostStackExtendedDTestCase(VCLTestCase):
749 """ VCL IPv6 Thru Host Stack Extended Tests """
750
751 def setUp(self):
752 super(VCLIpv6ThruHostStackExtendedDTestCase, self).setUp()
753
754 self.thru_host_stack_ipv6_setup()
755 if self.vppDebug:
756 self.client_uni_dir_nsock_timeout = 120
757 self.numSockets = "2"
758 else:
759 self.client_uni_dir_nsock_timeout = 120
760 self.numSockets = "5"
761
762 self.client_ipv6_uni_dir_nsock_test_args = ["-6",
763 "-I", self.numSockets,
764 "-U", "-X",
765 self.loop0.local_ip6,
766 self.server_port]
767
768 def tearDown(self):
769 self.thru_host_stack_ipv6_tear_down()
770
771 super(VCLIpv6ThruHostStackExtendedDTestCase, self).tearDown()
772
773 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
774 def test_vcl_thru_host_stack_uni_dir_nsock(self):
775 """ run VCL thru host stack uni-directional (multiple sockets) test """
776
777 self.timeout = self.client_uni_dir_nsock_timeout
778 self.thru_host_stack_test("vcl_test_server", self.server_ipv6_args,
779 "vcl_test_client",
780 self.client_ipv6_uni_dir_nsock_test_args)
781
782
783class VCLIpv6ThruHostStackIperfTestCase(VCLTestCase):
784 """ VCL IPv6 Thru Host Stack Iperf Tests """
785
786 def setUp(self):
787 super(VCLIpv6ThruHostStackIperfTestCase, self).setUp()
788
789 self.thru_host_stack_ipv6_setup()
790 self.client_iperf3_timeout = 20
791 self.client_ipv6_iperf3_args = ["-V6d", "-c", self.loop0.local_ip6]
792 self.server_ipv6_iperf3_args = ["-V6d", "-s"]
793
794 def tearDown(self):
795 self.thru_host_stack_ipv6_tear_down()
796
797 super(VCLIpv6ThruHostStackIperfTestCase, self).tearDown()
798
799 def test_ldp_thru_host_stack_iperf3(self):
800 """ run LDP thru host stack iperf3 test """
801
802 try:
803 subprocess.check_output(['iperf3', '-v'])
804 except:
805 self.logger.error("WARNING: 'iperf3' is not installed,")
806 self.logger.error(
807 " 'test_ldp_thru_host_stack_iperf3' not run!")
808 return
809
810 self.timeout = self.client_iperf3_timeout
811 self.thru_host_stack_test("iperf3", self.server_ipv6_iperf3_args,
812 "iperf3", self.client_ipv6_iperf3_args)
813
814
Dave Wallacecfcf2f42018-02-16 18:31:56 -0500815if __name__ == '__main__':
816 unittest.main(testRunner=VppTestRunner)