blob: 8e8cc401888fc6d56b64fea14928ab62a21412da [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
Florin Coras0e88e852018-09-17 22:09:02 -0700344class VCLThruHostStackNSessionBidirTestCase(VCLTestCase):
345 """ VCL Thru Host Stack NSession Bidir Tests """
Dave Wallaced85075e2018-03-02 13:19:30 -0500346
347 def setUp(self):
Florin Coras0e88e852018-09-17 22:09:02 -0700348 super(VCLThruHostStackNSessionBidirTestCase, self).setUp()
Dave Wallaced85075e2018-03-02 13:19:30 -0500349
350 self.thru_host_stack_setup()
351 if self.vppDebug:
352 self.client_bi_dir_nsock_timeout = 120
Florin Coras0e88e852018-09-17 22:09:02 -0700353 self.client_bi_dir_nsock_test_args = ["-B", "-X", "-N 10000",
Dave Wallacede910062018-03-20 09:22:13 -0400354 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",
Florin Coras0e88e852018-09-17 22:09:02 -0700359 "-N 1000",
Dave Wallacede910062018-03-20 09:22:13 -0400360 self.loop0.local_ip4,
361 self.server_port]
Dave Wallaced85075e2018-03-02 13:19:30 -0500362
363 def tearDown(self):
364 self.thru_host_stack_tear_down()
365
Florin Coras0e88e852018-09-17 22:09:02 -0700366 super(VCLThruHostStackNSessionBidirTestCase, self).tearDown()
Dave Wallaced85075e2018-03-02 13:19:30 -0500367
368 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
369 def test_vcl_thru_host_stack_bi_dir_nsock(self):
370 """ run VCL thru host stack bi-directional (multiple sockets) test """
371
372 self.timeout = self.client_bi_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700373 self.thru_host_stack_test("vcl_test_server", self.server_args,
374 "vcl_test_client",
Dave Wallaced85075e2018-03-02 13:19:30 -0500375 self.client_bi_dir_nsock_test_args)
376
377
Dave Wallace816833f2018-03-14 20:01:28 -0400378class VCLThruHostStackExtendedBTestCase(VCLTestCase):
Florin Coras0e88e852018-09-17 22:09:02 -0700379 """ VCL Thru Host Stack Extended B Tests """
Dave Wallaced85075e2018-03-02 13:19:30 -0500380
381 def setUp(self):
382 super(VCLThruHostStackExtendedBTestCase, self).setUp()
383
384 self.thru_host_stack_setup()
385 if self.vppDebug:
386 self.client_bi_dir_nsock_timeout = 120
Florin Coras0e88e852018-09-17 22:09:02 -0700387 self.client_bi_dir_nsock_test_args = ["-B", "-X", "-N 1000",
Dave Wallacede910062018-03-20 09:22:13 -0400388 self.loop0.local_ip4,
389 self.server_port]
Dave Wallaced85075e2018-03-02 13:19:30 -0500390 else:
391 self.client_bi_dir_nsock_timeout = 60
Dave Wallacede910062018-03-20 09:22:13 -0400392 self.client_bi_dir_nsock_test_args = ["-I", "2", "-B", "-X",
Florin Coras0e88e852018-09-17 22:09:02 -0700393 "-N 1000",
Dave Wallacede910062018-03-20 09:22:13 -0400394 self.loop0.local_ip4,
395 self.server_port]
Dave Wallaced85075e2018-03-02 13:19:30 -0500396
397 def tearDown(self):
398 self.thru_host_stack_tear_down()
399
400 super(VCLThruHostStackExtendedBTestCase, self).tearDown()
401
402 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
403 def test_ldp_thru_host_stack_bi_dir_nsock(self):
404 """ run LDP thru host stack bi-directional (multiple sockets) test """
405
406 self.timeout = self.client_bi_dir_nsock_timeout
Dave Wallace816833f2018-03-14 20:01:28 -0400407 self.thru_host_stack_test("sock_test_server", self.server_args,
408 "sock_test_client",
Dave Wallaced85075e2018-03-02 13:19:30 -0500409 self.client_bi_dir_nsock_test_args)
410
411
Dave Wallace816833f2018-03-14 20:01:28 -0400412class VCLThruHostStackExtendedCTestCase(VCLTestCase):
Florin Coras0e88e852018-09-17 22:09:02 -0700413 """ VCL Thru Host Stack Extended C Tests """
Dave Wallaced85075e2018-03-02 13:19:30 -0500414
415 def setUp(self):
416 super(VCLThruHostStackExtendedCTestCase, self).setUp()
417
418 self.thru_host_stack_setup()
419 if self.vppDebug:
420 self.client_uni_dir_nsock_timeout = 120
421 self.numSockets = "2"
422 else:
423 self.client_uni_dir_nsock_timeout = 120
424 self.numSockets = "5"
425
Dave Wallacede910062018-03-20 09:22:13 -0400426 self.client_uni_dir_nsock_test_args = ["-I", self.numSockets,
Florin Coras0e88e852018-09-17 22:09:02 -0700427 "-U", "-X", "-N 1000",
Dave Wallacede910062018-03-20 09:22:13 -0400428 self.loop0.local_ip4,
429 self.server_port]
Dave Wallaced85075e2018-03-02 13:19:30 -0500430
431 def tearDown(self):
432 self.thru_host_stack_tear_down()
433
434 super(VCLThruHostStackExtendedCTestCase, self).tearDown()
435
436 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
437 def test_ldp_thru_host_stack_uni_dir_nsock(self):
438 """ run LDP thru host stack uni-directional (multiple sockets) test """
439
440 self.timeout = self.client_uni_dir_nsock_timeout
Dave Wallace816833f2018-03-14 20:01:28 -0400441 self.thru_host_stack_test("sock_test_server", self.server_args,
442 "sock_test_client",
Dave Wallaced85075e2018-03-02 13:19:30 -0500443 self.client_uni_dir_nsock_test_args)
444
445
Dave Wallace816833f2018-03-14 20:01:28 -0400446class VCLThruHostStackExtendedDTestCase(VCLTestCase):
Florin Coras0e88e852018-09-17 22:09:02 -0700447 """ VCL Thru Host Stack Extended D Tests """
Dave Wallaced85075e2018-03-02 13:19:30 -0500448
449 def setUp(self):
450 super(VCLThruHostStackExtendedDTestCase, self).setUp()
451
452 self.thru_host_stack_setup()
453 if self.vppDebug:
454 self.client_uni_dir_nsock_timeout = 120
455 self.numSockets = "2"
456 else:
457 self.client_uni_dir_nsock_timeout = 120
458 self.numSockets = "5"
459
Dave Wallacede910062018-03-20 09:22:13 -0400460 self.client_uni_dir_nsock_test_args = ["-I", self.numSockets,
Florin Coras0e88e852018-09-17 22:09:02 -0700461 "-U", "-X", "-N 1000",
Dave Wallacede910062018-03-20 09:22:13 -0400462 self.loop0.local_ip4,
463 self.server_port]
Dave Wallaced85075e2018-03-02 13:19:30 -0500464
465 def tearDown(self):
466 self.thru_host_stack_tear_down()
467
468 super(VCLThruHostStackExtendedDTestCase, self).tearDown()
469
470 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
471 def test_vcl_thru_host_stack_uni_dir_nsock(self):
472 """ run VCL thru host stack uni-directional (multiple sockets) test """
473
474 self.timeout = self.client_uni_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700475 self.thru_host_stack_test("vcl_test_server", self.server_args,
476 "vcl_test_client",
Dave Wallaced85075e2018-03-02 13:19:30 -0500477 self.client_uni_dir_nsock_test_args)
478
479
Dave Wallace816833f2018-03-14 20:01:28 -0400480class VCLThruHostStackIperfTestCase(VCLTestCase):
481 """ VCL Thru Host Stack Iperf Tests """
482
483 def setUp(self):
484 super(VCLThruHostStackIperfTestCase, self).setUp()
485
486 self.thru_host_stack_setup()
487 self.client_iperf3_timeout = 20
Florin Corasab2f6db2018-08-31 14:31:41 -0700488 self.client_iperf3_args = ["-V4d", "-t 5", "-c", self.loop0.local_ip4]
Dave Wallace816833f2018-03-14 20:01:28 -0400489 self.server_iperf3_args = ["-V4d", "-s"]
490
491 def tearDown(self):
492 self.thru_host_stack_tear_down()
493
494 super(VCLThruHostStackIperfTestCase, self).tearDown()
495
496 def test_ldp_thru_host_stack_iperf3(self):
497 """ run LDP thru host stack iperf3 test """
498
499 try:
500 subprocess.check_output(['iperf3', '-v'])
501 except:
502 self.logger.error("WARNING: 'iperf3' is not installed,")
503 self.logger.error(
504 " 'test_ldp_thru_host_stack_iperf3' not run!")
505 return
506
507 self.timeout = self.client_iperf3_timeout
508 self.thru_host_stack_test("iperf3", self.server_iperf3_args,
509 "iperf3", self.client_iperf3_args)
510
511
Dave Wallacede910062018-03-20 09:22:13 -0400512class VCLIpv6CutThruTestCase(VCLTestCase):
513 """ VCL IPv6 Cut Thru Tests """
514
515 def setUp(self):
516 super(VCLIpv6CutThruTestCase, self).setUp()
517
518 self.cut_thru_setup()
519 self.client_iperf3_timeout = 20
520 self.client_uni_dir_nsock_timeout = 60
521 self.client_bi_dir_nsock_timeout = 120
522 self.client_ipv6_echo_test_args = ["-6", "-E", self.echo_phrase, "-X",
523 self.server_ipv6_addr,
524 self.server_port]
Florin Corasab2f6db2018-08-31 14:31:41 -0700525 self.client_ipv6_iperf3_args = ["-V6d", "-t 5", "-c",
526 self.server_ipv6_addr]
Dave Wallacede910062018-03-20 09:22:13 -0400527 self.server_ipv6_iperf3_args = ["-V6d", "-s"]
528 self.client_ipv6_uni_dir_nsock_test_args = ["-6", "-I", "5",
529 "-U", "-X",
530 self.server_ipv6_addr,
531 self.server_port]
532 self.client_ipv6_bi_dir_nsock_test_args = ["-6", "-I", "2",
533 "-B", "-X",
534 self.server_ipv6_addr,
535 self.server_port]
536
537 def tearDown(self):
538 self.cut_thru_tear_down()
539
540 super(VCLIpv6CutThruTestCase, self).tearDown()
541
542 def test_ldp_ipv6_cut_thru_echo(self):
543 """ run LDP IPv6 cut thru echo test """
544
Florin Corasab2f6db2018-08-31 14:31:41 -0700545 self.cut_thru_test("sock_test_server",
Dave Wallacede910062018-03-20 09:22:13 -0400546 self.server_ipv6_args,
Florin Corasab2f6db2018-08-31 14:31:41 -0700547 "sock_test_client",
Dave Wallacede910062018-03-20 09:22:13 -0400548 self.client_ipv6_echo_test_args)
549
550 def test_ldp_ipv6_cut_thru_iperf3(self):
551 """ run LDP IPv6 cut thru iperf3 test """
552
553 try:
554 subprocess.check_output(['iperf3', '-v'])
555 except:
556 self.logger.error("WARNING: 'iperf3' is not installed,")
557 self.logger.error(
558 " 'test_ldp_ipv6_cut_thru_iperf3' not run!")
559 return
560
561 self.timeout = self.client_iperf3_timeout
562 self.cut_thru_test("iperf3", self.server_ipv6_iperf3_args,
563 "iperf3", self.client_ipv6_iperf3_args)
564
565 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
566 def test_ldp_ipv6_cut_thru_uni_dir_nsock(self):
567 """ run LDP IPv6 cut thru uni-directional (multiple sockets) test """
568
569 self.timeout = self.client_uni_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700570 self.cut_thru_test("sock_test_server", self.server_ipv6_args,
571 "sock_test_client",
Dave Wallacede910062018-03-20 09:22:13 -0400572 self.client_ipv6_uni_dir_nsock_test_args)
573
574 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
575 def test_ldp_ipv6_cut_thru_bi_dir_nsock(self):
576 """ run LDP IPv6 cut thru bi-directional (multiple sockets) test """
577
578 self.timeout = self.client_bi_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700579 self.cut_thru_test("sock_test_server", self.server_ipv6_args,
580 "sock_test_client",
Dave Wallacede910062018-03-20 09:22:13 -0400581 self.client_ipv6_bi_dir_nsock_test_args)
582
583 def test_vcl_ipv6_cut_thru_echo(self):
584 """ run VCL IPv6 cut thru echo test """
585
Florin Corasab2f6db2018-08-31 14:31:41 -0700586 self.cut_thru_test("vcl_test_server",
Dave Wallacede910062018-03-20 09:22:13 -0400587 self.server_ipv6_args,
Florin Corasab2f6db2018-08-31 14:31:41 -0700588 "vcl_test_client",
Dave Wallacede910062018-03-20 09:22:13 -0400589 self.client_ipv6_echo_test_args)
590
591 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
592 def test_vcl_ipv6_cut_thru_uni_dir_nsock(self):
593 """ run VCL IPv6 cut thru uni-directional (multiple sockets) test """
594
595 self.timeout = self.client_uni_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700596 self.cut_thru_test("vcl_test_server", self.server_ipv6_args,
597 "vcl_test_client",
Dave Wallacede910062018-03-20 09:22:13 -0400598 self.client_ipv6_uni_dir_nsock_test_args)
599
600 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
601 def test_vcl_ipv6_cut_thru_bi_dir_nsock(self):
602 """ run VCL IPv6 cut thru bi-directional (multiple sockets) test """
603
604 self.timeout = self.client_bi_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700605 self.cut_thru_test("vcl_test_server", self.server_ipv6_args,
606 "vcl_test_client",
Dave Wallacede910062018-03-20 09:22:13 -0400607 self.client_ipv6_bi_dir_nsock_test_args)
608
609
610class VCLIpv6ThruHostStackTestCase(VCLTestCase):
611 """ VCL IPv6 Thru Host Stack Tests """
612
613 def setUp(self):
614 super(VCLIpv6ThruHostStackTestCase, self).setUp()
615
616 self.thru_host_stack_ipv6_setup()
617 self.client_ipv6_echo_test_args = ["-6", "-E", self.echo_phrase, "-X",
618 self.loop0.local_ip6,
619 self.server_port]
620
621 def tearDown(self):
622 self.thru_host_stack_ipv6_tear_down()
623
624 super(VCLIpv6ThruHostStackTestCase, self).tearDown()
625
626 def test_ldp_ipv6_thru_host_stack_echo(self):
627 """ run LDP IPv6 thru host stack echo test """
628
Florin Corasab2f6db2018-08-31 14:31:41 -0700629 self.thru_host_stack_test("sock_test_server",
Damjan Marion855e2682018-08-24 13:37:45 +0200630 self.server_ipv6_args,
Florin Corasab2f6db2018-08-31 14:31:41 -0700631 "sock_test_client",
Dave Wallacede910062018-03-20 09:22:13 -0400632 self.client_ipv6_echo_test_args)
633 # TBD: Remove these when VPP thru host teardown config bug is fixed.
Florin Corasab2f6db2018-08-31 14:31:41 -0700634 self.thru_host_stack_test("vcl_test_server",
Damjan Marion855e2682018-08-24 13:37:45 +0200635 self.server_ipv6_args,
Florin Corasab2f6db2018-08-31 14:31:41 -0700636 "vcl_test_client",
Dave Wallacede910062018-03-20 09:22:13 -0400637 self.client_ipv6_echo_test_args)
638
639 def test_vcl_ipv6_thru_host_stack_echo(self):
640 """ run VCL IPv6 thru host stack echo test """
641
Florin Corasab2f6db2018-08-31 14:31:41 -0700642# self.thru_host_stack_test("vcl_test_server",
Damjan Marion855e2682018-08-24 13:37:45 +0200643# self.server_ipv6_args,
Florin Corasab2f6db2018-08-31 14:31:41 -0700644# "vcl_test_client",
Keith Burns (alagalah)410bcca2018-03-23 13:42:49 -0700645# self.client_ipv6_echo_test_args)
Dave Wallacede910062018-03-20 09:22:13 -0400646
647 # TBD: Remove VCLIpv6ThruHostStackExtended*TestCase classes and move
648 # tests here when VPP thru host teardown/setup config bug
649 # is fixed.
650
651
652class VCLIpv6ThruHostStackExtendedATestCase(VCLTestCase):
Florin Coras0e88e852018-09-17 22:09:02 -0700653 """ VCL IPv6 Thru Host Stack Extended A Tests """
Dave Wallacede910062018-03-20 09:22:13 -0400654
655 def setUp(self):
656 super(VCLIpv6ThruHostStackExtendedATestCase, self).setUp()
657
658 self.thru_host_stack_ipv6_setup()
659 if self.vppDebug:
660 self.client_bi_dir_nsock_timeout = 120
661 self.client_ipv6_bi_dir_nsock_test_args = ["-6", "-B", "-X",
662 self.loop0.local_ip6,
663 self.server_port]
664 else:
665 self.client_bi_dir_nsock_timeout = 90
666 self.client_ipv6_bi_dir_nsock_test_args = ["-6", "-I",
667 "2", "-B", "-X",
668 self.loop0.local_ip6,
669 self.server_port]
670
671 def tearDown(self):
672 self.thru_host_stack_ipv6_tear_down()
673
674 super(VCLIpv6ThruHostStackExtendedATestCase, self).tearDown()
675
676 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
677 def test_vcl_thru_host_stack_bi_dir_nsock(self):
678 """ run VCL thru host stack bi-directional (multiple sockets) test """
679
680 self.timeout = self.client_bi_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700681 self.thru_host_stack_test("vcl_test_server", self.server_ipv6_args,
682 "vcl_test_client",
Dave Wallacede910062018-03-20 09:22:13 -0400683 self.client_ipv6_bi_dir_nsock_test_args)
684
685
686class VCLIpv6ThruHostStackExtendedBTestCase(VCLTestCase):
Florin Coras0e88e852018-09-17 22:09:02 -0700687 """ VCL IPv6 Thru Host Stack Extended B Tests """
Dave Wallacede910062018-03-20 09:22:13 -0400688
689 def setUp(self):
690 super(VCLIpv6ThruHostStackExtendedBTestCase, self).setUp()
691
692 self.thru_host_stack_ipv6_setup()
693 if self.vppDebug:
694 self.client_bi_dir_nsock_timeout = 120
695 self.client_ipv6_bi_dir_nsock_test_args = ["-6", "-B", "-X",
696 self.loop0.local_ip6,
697 self.server_port]
698 else:
699 self.client_bi_dir_nsock_timeout = 60
700 self.client_ipv6_bi_dir_nsock_test_args = ["-6", "-I", "2",
701 "-B", "-X",
702 self.loop0.local_ip6,
703 self.server_port]
704
705 def tearDown(self):
706 self.thru_host_stack_ipv6_tear_down()
707
708 super(VCLIpv6ThruHostStackExtendedBTestCase, self).tearDown()
709
710 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
711 def test_ldp_thru_host_stack_bi_dir_nsock(self):
712 """ run LDP thru host stack bi-directional (multiple sockets) test """
713
714 self.timeout = self.client_bi_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700715 self.thru_host_stack_test("sock_test_server",
Damjan Marion855e2682018-08-24 13:37:45 +0200716 self.server_ipv6_args,
Florin Corasab2f6db2018-08-31 14:31:41 -0700717 "sock_test_client",
Dave Wallacede910062018-03-20 09:22:13 -0400718 self.client_ipv6_bi_dir_nsock_test_args)
719
720
721class VCLIpv6ThruHostStackExtendedCTestCase(VCLTestCase):
Florin Coras0e88e852018-09-17 22:09:02 -0700722 """ VCL IPv6 Thru Host Stack Extended C Tests """
Dave Wallacede910062018-03-20 09:22:13 -0400723
724 def setUp(self):
725 super(VCLIpv6ThruHostStackExtendedCTestCase, self).setUp()
726
727 self.thru_host_stack_ipv6_setup()
728 if self.vppDebug:
729 self.client_uni_dir_nsock_timeout = 120
730 self.numSockets = "2"
731 else:
732 self.client_uni_dir_nsock_timeout = 120
733 self.numSockets = "5"
734
735 self.client_ipv6_uni_dir_nsock_test_args = ["-6",
736 "-I", self.numSockets,
737 "-U", "-X",
738 self.loop0.local_ip6,
739 self.server_port]
740
741 def tearDown(self):
742 self.thru_host_stack_ipv6_tear_down()
743
744 super(VCLIpv6ThruHostStackExtendedCTestCase, self).tearDown()
745
746 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
747 def test_ldp_thru_host_stack_uni_dir_nsock(self):
748 """ run LDP thru host stack uni-directional (multiple sockets) test """
749
750 self.timeout = self.client_uni_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700751 self.thru_host_stack_test("sock_test_server",
Damjan Marion855e2682018-08-24 13:37:45 +0200752 self.server_ipv6_args,
Florin Corasab2f6db2018-08-31 14:31:41 -0700753 "sock_test_client",
Dave Wallacede910062018-03-20 09:22:13 -0400754 self.client_ipv6_uni_dir_nsock_test_args)
755
756
757class VCLIpv6ThruHostStackExtendedDTestCase(VCLTestCase):
Florin Coras0e88e852018-09-17 22:09:02 -0700758 """ VCL IPv6 Thru Host Stack Extended D Tests """
Dave Wallacede910062018-03-20 09:22:13 -0400759
760 def setUp(self):
761 super(VCLIpv6ThruHostStackExtendedDTestCase, self).setUp()
762
763 self.thru_host_stack_ipv6_setup()
764 if self.vppDebug:
765 self.client_uni_dir_nsock_timeout = 120
766 self.numSockets = "2"
767 else:
768 self.client_uni_dir_nsock_timeout = 120
769 self.numSockets = "5"
770
771 self.client_ipv6_uni_dir_nsock_test_args = ["-6",
772 "-I", self.numSockets,
773 "-U", "-X",
774 self.loop0.local_ip6,
775 self.server_port]
776
777 def tearDown(self):
778 self.thru_host_stack_ipv6_tear_down()
779
780 super(VCLIpv6ThruHostStackExtendedDTestCase, self).tearDown()
781
782 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
783 def test_vcl_thru_host_stack_uni_dir_nsock(self):
784 """ run VCL thru host stack uni-directional (multiple sockets) test """
785
786 self.timeout = self.client_uni_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700787 self.thru_host_stack_test("vcl_test_server", self.server_ipv6_args,
788 "vcl_test_client",
Dave Wallacede910062018-03-20 09:22:13 -0400789 self.client_ipv6_uni_dir_nsock_test_args)
790
791
792class VCLIpv6ThruHostStackIperfTestCase(VCLTestCase):
793 """ VCL IPv6 Thru Host Stack Iperf Tests """
794
795 def setUp(self):
796 super(VCLIpv6ThruHostStackIperfTestCase, self).setUp()
797
798 self.thru_host_stack_ipv6_setup()
799 self.client_iperf3_timeout = 20
Florin Corasab2f6db2018-08-31 14:31:41 -0700800 self.client_ipv6_iperf3_args = ["-V6d", "-t 5", "-c",
801 self.loop0.local_ip6]
Dave Wallacede910062018-03-20 09:22:13 -0400802 self.server_ipv6_iperf3_args = ["-V6d", "-s"]
803
804 def tearDown(self):
805 self.thru_host_stack_ipv6_tear_down()
806
807 super(VCLIpv6ThruHostStackIperfTestCase, self).tearDown()
808
Florin Coras56b39f62018-03-27 17:29:32 -0700809 @unittest.skipUnless(running_extended_tests(), "part of extended tests")
Dave Wallacede910062018-03-20 09:22:13 -0400810 def test_ldp_thru_host_stack_iperf3(self):
811 """ run LDP thru host stack iperf3 test """
812
813 try:
814 subprocess.check_output(['iperf3', '-v'])
815 except:
816 self.logger.error("WARNING: 'iperf3' is not installed,")
817 self.logger.error(
818 " 'test_ldp_thru_host_stack_iperf3' not run!")
819 return
820
821 self.timeout = self.client_iperf3_timeout
822 self.thru_host_stack_test("iperf3", self.server_ipv6_iperf3_args,
823 "iperf3", self.client_ipv6_iperf3_args)
824
825
Dave Wallacecfcf2f42018-02-16 18:31:56 -0500826if __name__ == '__main__':
827 unittest.main(testRunner=VppTestRunner)