blob: 34cf0e2a391dea809d828dcd1539abcd4baebd17 [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):
Klement Sekerab8c72a42018-11-08 11:21:39 +010036 var = "VPP_BUILD_DIR"
Dave Wallaced85075e2018-03-02 13:19:30 -050037 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 Corasdc2e2512018-12-03 17:47:26 -080046 self.timeout = 20
Dave Wallace9f11c012018-02-28 17:55:23 -050047 self.echo_phrase = "Hello, world! Jenny is a friend of mine."
Florin Corasdc2e2512018-12-03 17:47:26 -080048 self.pre_test_sleep = 0.3
49 self.post_test_sleep = 0.2
50
51 if os.path.isfile("/tmp/ldp_server_af_unix_socket"):
52 os.remove("/tmp/ldp_server_af_unix_socket")
Dave Wallace42996c02018-02-26 14:40:13 -050053
Dave Wallace816833f2018-03-14 20:01:28 -040054 super(VCLTestCase, self).__init__(methodName)
Dave Wallace42996c02018-02-26 14:40:13 -050055
Dave Wallace9f11c012018-02-28 17:55:23 -050056 def cut_thru_setup(self):
Dave Wallacea67a03e2018-02-20 12:39:37 -050057 self.vapi.session_enable_disable(is_enabled=1)
58
Dave Wallace9f11c012018-02-28 17:55:23 -050059 def cut_thru_tear_down(self):
Dave Wallacea67a03e2018-02-20 12:39:37 -050060 self.vapi.session_enable_disable(is_enabled=0)
61
Dave Wallace816833f2018-03-14 20:01:28 -040062 def cut_thru_test(self, server_app, server_args, client_app, client_args):
Dave Wallace42996c02018-02-26 14:40:13 -050063 self.env = {'VCL_API_PREFIX': self.shm_prefix,
64 'VCL_APP_SCOPE_LOCAL': "true"}
65
Dave Wallace816833f2018-03-14 20:01:28 -040066 worker_server = VCLAppWorker(self.build_dir, server_app, server_args,
Dave Wallace42996c02018-02-26 14:40:13 -050067 self.logger, self.env)
Dave Wallacecfcf2f42018-02-16 18:31:56 -050068 worker_server.start()
Florin Corasdc2e2512018-12-03 17:47:26 -080069 self.sleep(self.pre_test_sleep)
Dave Wallace816833f2018-03-14 20:01:28 -040070 worker_client = VCLAppWorker(self.build_dir, client_app, client_args,
Dave Wallace42996c02018-02-26 14:40:13 -050071 self.logger, self.env)
Dave Wallacecfcf2f42018-02-16 18:31:56 -050072 worker_client.start()
Dave Wallace42996c02018-02-26 14:40:13 -050073 worker_client.join(self.timeout)
Dave Wallacefef3f7b2018-03-09 12:04:10 -050074 try:
75 self.validateResults(worker_client, worker_server, self.timeout)
Klement Sekerab9ef2732018-06-24 22:49:33 +020076 except Exception as error:
Dave Wallacefef3f7b2018-03-09 12:04:10 -050077 self.fail("Failed with %s" % error)
Florin Corasdc2e2512018-12-03 17:47:26 -080078 self.sleep(self.post_test_sleep)
Dave Wallacecfcf2f42018-02-16 18:31:56 -050079
Dave Wallace9f11c012018-02-28 17:55:23 -050080 def thru_host_stack_setup(self):
Dave Wallacea67a03e2018-02-20 12:39:37 -050081 self.vapi.session_enable_disable(is_enabled=1)
Klement Sekerab9ef2732018-06-24 22:49:33 +020082 self.create_loopback_interfaces(2)
Dave Wallacea67a03e2018-02-20 12:39:37 -050083
Florin Coras56b39f62018-03-27 17:29:32 -070084 table_id = 1
Dave Wallacea67a03e2018-02-20 12:39:37 -050085
86 for i in self.lo_interfaces:
87 i.admin_up()
88
89 if table_id != 0:
90 tbl = VppIpTable(self, table_id)
91 tbl.add_vpp_config()
92
93 i.set_table_ip4(table_id)
94 i.config_ip4()
95 table_id += 1
96
97 # Configure namespaces
Florin Coras56b39f62018-03-27 17:29:32 -070098 self.vapi.app_namespace_add(namespace_id="1", secret=1234,
Dave Wallacea67a03e2018-02-20 12:39:37 -050099 sw_if_index=self.loop0.sw_if_index)
Florin Coras56b39f62018-03-27 17:29:32 -0700100 self.vapi.app_namespace_add(namespace_id="2", secret=5678,
Dave Wallacea67a03e2018-02-20 12:39:37 -0500101 sw_if_index=self.loop1.sw_if_index)
102
Dave Wallacea67a03e2018-02-20 12:39:37 -0500103 # Add inter-table routes
104 ip_t01 = VppIpRoute(self, self.loop1.local_ip4, 32,
105 [VppRoutePath("0.0.0.0",
106 0xffffffff,
Florin Coras56b39f62018-03-27 17:29:32 -0700107 nh_table_id=2)], table_id=1)
Dave Wallacea67a03e2018-02-20 12:39:37 -0500108 ip_t10 = VppIpRoute(self, self.loop0.local_ip4, 32,
109 [VppRoutePath("0.0.0.0",
110 0xffffffff,
Florin Coras56b39f62018-03-27 17:29:32 -0700111 nh_table_id=1)], table_id=2)
Dave Wallacea67a03e2018-02-20 12:39:37 -0500112 ip_t01.add_vpp_config()
113 ip_t10.add_vpp_config()
Florin Coras56b39f62018-03-27 17:29:32 -0700114 self.logger.debug(self.vapi.cli("show ip fib"))
Dave Wallacea67a03e2018-02-20 12:39:37 -0500115
Dave Wallace9f11c012018-02-28 17:55:23 -0500116 def thru_host_stack_tear_down(self):
117 for i in self.lo_interfaces:
118 i.unconfig_ip4()
119 i.set_table_ip4(0)
120 i.admin_down()
121
122 self.vapi.session_enable_disable(is_enabled=0)
123
Dave Wallacede910062018-03-20 09:22:13 -0400124 def thru_host_stack_ipv6_setup(self):
125 self.vapi.session_enable_disable(is_enabled=1)
Klement Sekerab9ef2732018-06-24 22:49:33 +0200126 self.create_loopback_interfaces(2)
Dave Wallacede910062018-03-20 09:22:13 -0400127
128 table_id = 1
129
130 for i in self.lo_interfaces:
131 i.admin_up()
132
133 tbl = VppIpTable(self, table_id, is_ip6=1)
134 tbl.add_vpp_config()
135
136 i.set_table_ip6(table_id)
137 i.config_ip6()
138 table_id += 1
139
140 # Configure namespaces
Florin Coras56b39f62018-03-27 17:29:32 -0700141 self.vapi.app_namespace_add(namespace_id="1", secret=1234,
Dave Wallacede910062018-03-20 09:22:13 -0400142 sw_if_index=self.loop0.sw_if_index)
Florin Coras56b39f62018-03-27 17:29:32 -0700143 self.vapi.app_namespace_add(namespace_id="2", secret=5678,
Dave Wallacede910062018-03-20 09:22:13 -0400144 sw_if_index=self.loop1.sw_if_index)
145
146 # Add inter-table routes
147 ip_t01 = VppIpRoute(self, self.loop1.local_ip6, 128,
Florin Coras56b39f62018-03-27 17:29:32 -0700148 [VppRoutePath("::0", 0xffffffff,
149 nh_table_id=2,
150 proto=DpoProto.DPO_PROTO_IP6)],
Dave Wallacede910062018-03-20 09:22:13 -0400151 table_id=1, is_ip6=1)
152 ip_t10 = VppIpRoute(self, self.loop0.local_ip6, 128,
Florin Coras56b39f62018-03-27 17:29:32 -0700153 [VppRoutePath("::0", 0xffffffff,
154 nh_table_id=1,
155 proto=DpoProto.DPO_PROTO_IP6)],
Dave Wallacede910062018-03-20 09:22:13 -0400156 table_id=2, is_ip6=1)
157 ip_t01.add_vpp_config()
158 ip_t10.add_vpp_config()
159 self.logger.debug(self.vapi.cli("show interface addr"))
160 self.logger.debug(self.vapi.cli("show ip6 fib"))
161
162 def thru_host_stack_ipv6_tear_down(self):
163 for i in self.lo_interfaces:
164 i.unconfig_ip6()
165 i.set_table_ip6(0)
166 i.admin_down()
167
168 self.vapi.session_enable_disable(is_enabled=0)
169
Dave Wallace816833f2018-03-14 20:01:28 -0400170 def thru_host_stack_test(self, server_app, server_args,
171 client_app, client_args):
Dave Wallace9f11c012018-02-28 17:55:23 -0500172 self.env = {'VCL_API_PREFIX': self.shm_prefix,
173 'VCL_APP_SCOPE_GLOBAL': "true",
Florin Coras56b39f62018-03-27 17:29:32 -0700174 'VCL_APP_NAMESPACE_ID': "1",
Dave Wallace9f11c012018-02-28 17:55:23 -0500175 'VCL_APP_NAMESPACE_SECRET': "1234"}
176
Dave Wallace816833f2018-03-14 20:01:28 -0400177 worker_server = VCLAppWorker(self.build_dir, server_app, server_args,
Dave Wallace42996c02018-02-26 14:40:13 -0500178 self.logger, self.env)
Dave Wallacea67a03e2018-02-20 12:39:37 -0500179 worker_server.start()
Florin Corasdc2e2512018-12-03 17:47:26 -0800180 self.sleep(self.pre_test_sleep)
Dave Wallace42996c02018-02-26 14:40:13 -0500181
Florin Coras56b39f62018-03-27 17:29:32 -0700182 self.env.update({'VCL_APP_NAMESPACE_ID': "2",
Dave Wallace42996c02018-02-26 14:40:13 -0500183 'VCL_APP_NAMESPACE_SECRET': "5678"})
Dave Wallace816833f2018-03-14 20:01:28 -0400184 worker_client = VCLAppWorker(self.build_dir, client_app, client_args,
Dave Wallace42996c02018-02-26 14:40:13 -0500185 self.logger, self.env)
Dave Wallacea67a03e2018-02-20 12:39:37 -0500186 worker_client.start()
Dave Wallace42996c02018-02-26 14:40:13 -0500187 worker_client.join(self.timeout)
188
Dave Wallacefef3f7b2018-03-09 12:04:10 -0500189 try:
190 self.validateResults(worker_client, worker_server, self.timeout)
Klement Sekerab9ef2732018-06-24 22:49:33 +0200191 except Exception as error:
Dave Wallacefef3f7b2018-03-09 12:04:10 -0500192 self.fail("Failed with %s" % error)
Florin Corasdc2e2512018-12-03 17:47:26 -0800193 self.sleep(self.post_test_sleep)
Dave Wallacea67a03e2018-02-20 12:39:37 -0500194
Dave Wallace9f11c012018-02-28 17:55:23 -0500195 def validateResults(self, worker_client, worker_server, timeout):
Dave Wallaced85075e2018-03-02 13:19:30 -0500196 if os.path.isdir('/proc/{}'.format(worker_server.process.pid)):
197 self.logger.info("Killing server worker process (pid %d)" %
198 worker_server.process.pid)
Florin Corasdc2e2512018-12-03 17:47:26 -0800199 os.killpg(os.getpgid(worker_server.process.pid), signal.SIGKILL)
Dave Wallaced85075e2018-03-02 13:19:30 -0500200 worker_server.join()
Dave Wallace9f11c012018-02-28 17:55:23 -0500201 self.logger.info("Client worker result is `%s'" % worker_client.result)
202 error = False
203 if worker_client.result is None:
204 try:
205 error = True
206 self.logger.error(
Dave Wallaced85075e2018-03-02 13:19:30 -0500207 "Timeout: %ss! Killing client worker process (pid %d)" %
208 (timeout, worker_client.process.pid))
Dave Wallace9f11c012018-02-28 17:55:23 -0500209 os.killpg(os.getpgid(worker_client.process.pid),
Florin Corasdc2e2512018-12-03 17:47:26 -0800210 signal.SIGKILL)
Dave Wallace9f11c012018-02-28 17:55:23 -0500211 worker_client.join()
212 except:
213 self.logger.debug(
214 "Couldn't kill client worker process")
215 raise
216 if error:
Dave Wallace9f11c012018-02-28 17:55:23 -0500217 raise Exception(
218 "Timeout! Client worker did not finish in %ss" % timeout)
219 self.assert_equal(worker_client.result, 0, "Binary test return code")
220
221
Florin Coras0ae445e2018-11-29 18:22:10 -0800222class LDPCutThruTestCase(VCLTestCase):
223 """ LDP Cut Thru Tests """
Dave Wallace9f11c012018-02-28 17:55:23 -0500224
225 def setUp(self):
Florin Coras0ae445e2018-11-29 18:22:10 -0800226 super(LDPCutThruTestCase, self).setUp()
Dave Wallace9f11c012018-02-28 17:55:23 -0500227
228 self.cut_thru_setup()
Dave Wallacede910062018-03-20 09:22:13 -0400229 self.client_echo_test_args = ["-E", self.echo_phrase, "-X",
230 self.server_addr, self.server_port]
Dave Wallace816833f2018-03-14 20:01:28 -0400231 self.client_iperf3_timeout = 20
Florin Corasdc2e2512018-12-03 17:47:26 -0800232 self.client_iperf3_args = ["-V4d", "-t 2", "-c", self.server_addr]
Dave Wallace816833f2018-03-14 20:01:28 -0400233 self.server_iperf3_args = ["-V4d", "-s"]
Florin Coras2eb42e72018-11-29 00:39:53 -0800234 self.client_uni_dir_nsock_timeout = 20
Dave Wallace45cd3a32018-06-26 01:14:04 -0400235 self.client_uni_dir_nsock_test_args = ["-N", "1000", "-U", "-X",
236 "-I", "2",
Dave Wallacede910062018-03-20 09:22:13 -0400237 self.server_addr,
238 self.server_port]
Florin Coras2eb42e72018-11-29 00:39:53 -0800239 self.client_bi_dir_nsock_timeout = 20
Dave Wallace45cd3a32018-06-26 01:14:04 -0400240 self.client_bi_dir_nsock_test_args = ["-N", "1000", "-B", "-X",
241 "-I", "2",
Dave Wallacede910062018-03-20 09:22:13 -0400242 self.server_addr,
243 self.server_port]
Dave Wallace9f11c012018-02-28 17:55:23 -0500244
245 def tearDown(self):
246 self.cut_thru_tear_down()
247
Florin Coras0ae445e2018-11-29 18:22:10 -0800248 super(LDPCutThruTestCase, self).tearDown()
Dave Wallace9f11c012018-02-28 17:55:23 -0500249
Paul Vinciguerradefde0f2018-12-06 07:46:13 -0800250 @unittest.skipUnless(running_extended_tests, "part of extended tests")
Dave Wallace9f11c012018-02-28 17:55:23 -0500251 def test_ldp_cut_thru_echo(self):
252 """ run LDP cut thru echo test """
253
Florin Corasab2f6db2018-08-31 14:31:41 -0700254 self.cut_thru_test("sock_test_server", self.server_args,
255 "sock_test_client", self.client_echo_test_args)
Dave Wallace816833f2018-03-14 20:01:28 -0400256
257 def test_ldp_cut_thru_iperf3(self):
258 """ run LDP cut thru iperf3 test """
259
260 try:
261 subprocess.check_output(['iperf3', '-v'])
Paul Vinciguerra61e63bf2018-11-24 21:19:38 -0800262 except subprocess.CalledProcessError:
Dave Wallace816833f2018-03-14 20:01:28 -0400263 self.logger.error("WARNING: 'iperf3' is not installed,")
264 self.logger.error(" 'test_ldp_cut_thru_iperf3' not run!")
265 return
266
267 self.timeout = self.client_iperf3_timeout
268 self.cut_thru_test("iperf3", self.server_iperf3_args,
269 "iperf3", self.client_iperf3_args)
Dave Wallace9f11c012018-02-28 17:55:23 -0500270
Paul Vinciguerradefde0f2018-12-06 07:46:13 -0800271 @unittest.skipUnless(running_extended_tests, "part of extended tests")
Dave Wallaced85075e2018-03-02 13:19:30 -0500272 def test_ldp_cut_thru_uni_dir_nsock(self):
273 """ run LDP cut thru uni-directional (multiple sockets) test """
274
275 self.timeout = self.client_uni_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700276 self.cut_thru_test("sock_test_server", self.server_args,
277 "sock_test_client",
Dave Wallaced85075e2018-03-02 13:19:30 -0500278 self.client_uni_dir_nsock_test_args)
279
Paul Vinciguerradefde0f2018-12-06 07:46:13 -0800280 @unittest.skipUnless(running_extended_tests, "part of extended tests")
Dave Wallaced85075e2018-03-02 13:19:30 -0500281 def test_ldp_cut_thru_bi_dir_nsock(self):
282 """ run LDP cut thru bi-directional (multiple sockets) test """
283
284 self.timeout = self.client_bi_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700285 self.cut_thru_test("sock_test_server", self.server_args,
286 "sock_test_client",
Dave Wallaced85075e2018-03-02 13:19:30 -0500287 self.client_bi_dir_nsock_test_args)
288
Florin Coras0ae445e2018-11-29 18:22:10 -0800289
290class VCLCutThruTestCase(VCLTestCase):
291 """ VCL Cut Thru Tests """
292
293 def setUp(self):
294 super(VCLCutThruTestCase, self).setUp()
295
296 self.cut_thru_setup()
297 self.client_echo_test_args = ["-E", self.echo_phrase, "-X",
298 self.server_addr, self.server_port]
299
300 self.client_uni_dir_nsock_timeout = 20
301 self.client_uni_dir_nsock_test_args = ["-N", "1000", "-U", "-X",
302 "-I", "2",
303 self.server_addr,
304 self.server_port]
305 self.client_bi_dir_nsock_timeout = 20
306 self.client_bi_dir_nsock_test_args = ["-N", "1000", "-B", "-X",
307 "-I", "2",
308 self.server_addr,
309 self.server_port]
310
311 def tearDown(self):
312 self.cut_thru_tear_down()
313
314 super(VCLCutThruTestCase, self).tearDown()
315
Dave Wallace9f11c012018-02-28 17:55:23 -0500316 def test_vcl_cut_thru_echo(self):
317 """ run VCL cut thru echo test """
318
Florin Corasab2f6db2018-08-31 14:31:41 -0700319 self.cut_thru_test("vcl_test_server", self.server_args,
320 "vcl_test_client", self.client_echo_test_args)
Dave Wallace9f11c012018-02-28 17:55:23 -0500321
Dave Wallaced85075e2018-03-02 13:19:30 -0500322 def test_vcl_cut_thru_uni_dir_nsock(self):
323 """ run VCL cut thru uni-directional (multiple sockets) test """
324
325 self.timeout = self.client_uni_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700326 self.cut_thru_test("vcl_test_server", self.server_args,
327 "vcl_test_client",
Dave Wallaced85075e2018-03-02 13:19:30 -0500328 self.client_uni_dir_nsock_test_args)
329
Dave Wallaced85075e2018-03-02 13:19:30 -0500330 def test_vcl_cut_thru_bi_dir_nsock(self):
331 """ run VCL cut thru bi-directional (multiple sockets) test """
332
333 self.timeout = self.client_bi_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700334 self.cut_thru_test("vcl_test_server", self.server_args,
335 "vcl_test_client",
Dave Wallaced85075e2018-03-02 13:19:30 -0500336 self.client_bi_dir_nsock_test_args)
337
Dave Wallace9f11c012018-02-28 17:55:23 -0500338
Florin Corasdc2e2512018-12-03 17:47:26 -0800339class LDPThruHostStackEcho(VCLTestCase):
340 """ LDP Thru Host Stack Echo """
Dave Wallace9f11c012018-02-28 17:55:23 -0500341
342 def setUp(self):
Florin Corasdc2e2512018-12-03 17:47:26 -0800343 super(LDPThruHostStackEcho, self).setUp()
Dave Wallace9f11c012018-02-28 17:55:23 -0500344
345 self.thru_host_stack_setup()
Dave Wallacede910062018-03-20 09:22:13 -0400346 self.client_echo_test_args = ["-E", self.echo_phrase, "-X",
347 self.loop0.local_ip4,
348 self.server_port]
Dave Wallace9f11c012018-02-28 17:55:23 -0500349
350 def tearDown(self):
351 self.thru_host_stack_tear_down()
Florin Corasdc2e2512018-12-03 17:47:26 -0800352 super(LDPThruHostStackEcho, self).tearDown()
Dave Wallace9f11c012018-02-28 17:55:23 -0500353
354 def test_ldp_thru_host_stack_echo(self):
355 """ run LDP thru host stack echo test """
356
Florin Corasab2f6db2018-08-31 14:31:41 -0700357 self.thru_host_stack_test("sock_test_server", self.server_args,
358 "sock_test_client",
Dave Wallace9f11c012018-02-28 17:55:23 -0500359 self.client_echo_test_args)
Dave Wallaced85075e2018-03-02 13:19:30 -0500360
361
Florin Corasdc2e2512018-12-03 17:47:26 -0800362class VCLThruHostStackEcho(VCLTestCase):
363 """ VCL Thru Host Stack Echo """
Dave Wallaced85075e2018-03-02 13:19:30 -0500364
365 def setUp(self):
Florin Corasdc2e2512018-12-03 17:47:26 -0800366 super(VCLThruHostStackEcho, self).setUp()
Dave Wallaced85075e2018-03-02 13:19:30 -0500367
368 self.thru_host_stack_setup()
Florin Corasdc2e2512018-12-03 17:47:26 -0800369 self.client_bi_dir_nsock_timeout = 20
370 self.client_bi_dir_nsock_test_args = ["-N", "1000", "-B", "-X",
371 "-I", "2",
372 self.loop0.local_ip4,
373 self.server_port]
374 self.client_echo_test_args = ["-E", self.echo_phrase, "-X",
375 self.loop0.local_ip4,
376 self.server_port]
377
378 def tearDown(self):
379 self.logger.debug(self.vapi.cli("show app server"))
380 self.logger.debug(self.vapi.cli("show session verbose"))
381 self.thru_host_stack_tear_down()
382 super(VCLThruHostStackEcho, self).tearDown()
383
384
385class VCLThruHostStackBidirNsock(VCLTestCase):
386 """ VCL Thru Host Stack Bidir Nsock """
387
388 def setUp(self):
389 super(VCLThruHostStackBidirNsock, self).setUp()
390
391 self.thru_host_stack_setup()
392 self.client_bi_dir_nsock_timeout = 20
393 self.client_bi_dir_nsock_test_args = ["-N", "1000", "-B", "-X",
394 "-I", "2",
395 self.loop0.local_ip4,
396 self.server_port]
397 self.client_echo_test_args = ["-E", self.echo_phrase, "-X",
398 self.loop0.local_ip4,
399 self.server_port]
Dave Wallaced85075e2018-03-02 13:19:30 -0500400
401 def tearDown(self):
402 self.thru_host_stack_tear_down()
Florin Corasdc2e2512018-12-03 17:47:26 -0800403 super(VCLThruHostStackBidirNsock, self).tearDown()
Dave Wallaced85075e2018-03-02 13:19:30 -0500404
Dave Wallaced85075e2018-03-02 13:19:30 -0500405 def test_vcl_thru_host_stack_bi_dir_nsock(self):
406 """ run VCL thru host stack bi-directional (multiple sockets) test """
407
408 self.timeout = self.client_bi_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700409 self.thru_host_stack_test("vcl_test_server", self.server_args,
410 "vcl_test_client",
Dave Wallaced85075e2018-03-02 13:19:30 -0500411 self.client_bi_dir_nsock_test_args)
412
413
Florin Corasdc2e2512018-12-03 17:47:26 -0800414class LDPThruHostStackBidirNsock(VCLTestCase):
415 """ LDP Thru Host Stack Bidir Nsock """
Dave Wallaced85075e2018-03-02 13:19:30 -0500416
417 def setUp(self):
Florin Corasdc2e2512018-12-03 17:47:26 -0800418 super(LDPThruHostStackBidirNsock, self).setUp()
Dave Wallaced85075e2018-03-02 13:19:30 -0500419
420 self.thru_host_stack_setup()
421 if self.vppDebug:
Florin Coras2eb42e72018-11-29 00:39:53 -0800422 self.client_bi_dir_nsock_timeout = 20
Dave Wallace45cd3a32018-06-26 01:14:04 -0400423 self.client_bi_dir_nsock_test_args = ["-N", "1000", "-B", "-X",
424 # OUCH! Host Stack Bug?
425 # "-I", "2",
Dave Wallacede910062018-03-20 09:22:13 -0400426 self.loop0.local_ip4,
427 self.server_port]
Dave Wallaced85075e2018-03-02 13:19:30 -0500428 else:
Florin Coras2eb42e72018-11-29 00:39:53 -0800429 self.client_bi_dir_nsock_timeout = 20
Dave Wallace45cd3a32018-06-26 01:14:04 -0400430 self.client_bi_dir_nsock_test_args = ["-N", "1000", "-B", "-X",
431 # OUCH! Host Stack Bug?
432 # "-I", "2",
Dave Wallacede910062018-03-20 09:22:13 -0400433 self.loop0.local_ip4,
434 self.server_port]
Dave Wallaced85075e2018-03-02 13:19:30 -0500435
436 def tearDown(self):
437 self.thru_host_stack_tear_down()
Florin Corasdc2e2512018-12-03 17:47:26 -0800438 super(LDPThruHostStackBidirNsock, self).tearDown()
Dave Wallaced85075e2018-03-02 13:19:30 -0500439
Dave Wallaced85075e2018-03-02 13:19:30 -0500440 def test_ldp_thru_host_stack_bi_dir_nsock(self):
441 """ run LDP thru host stack bi-directional (multiple sockets) test """
442
443 self.timeout = self.client_bi_dir_nsock_timeout
Dave Wallace816833f2018-03-14 20:01:28 -0400444 self.thru_host_stack_test("sock_test_server", self.server_args,
445 "sock_test_client",
Dave Wallaced85075e2018-03-02 13:19:30 -0500446 self.client_bi_dir_nsock_test_args)
447
448
Florin Corasdc2e2512018-12-03 17:47:26 -0800449class LDPThruHostStackNsock(VCLTestCase):
450 """ LDP Thru Host Stack Nsock """
Dave Wallaced85075e2018-03-02 13:19:30 -0500451
452 def setUp(self):
Florin Corasdc2e2512018-12-03 17:47:26 -0800453 super(LDPThruHostStackNsock, self).setUp()
Dave Wallaced85075e2018-03-02 13:19:30 -0500454
455 self.thru_host_stack_setup()
456 if self.vppDebug:
Florin Coras2eb42e72018-11-29 00:39:53 -0800457 self.client_uni_dir_nsock_timeout = 20
Dave Wallaced85075e2018-03-02 13:19:30 -0500458 self.numSockets = "2"
459 else:
Florin Coras2eb42e72018-11-29 00:39:53 -0800460 self.client_uni_dir_nsock_timeout = 20
Dave Wallaced85075e2018-03-02 13:19:30 -0500461 self.numSockets = "5"
462
Dave Wallace45cd3a32018-06-26 01:14:04 -0400463 self.client_uni_dir_nsock_test_args = ["-N", "1000", "-U", "-X",
464 "-I", self.numSockets,
Dave Wallacede910062018-03-20 09:22:13 -0400465 self.loop0.local_ip4,
466 self.server_port]
Dave Wallaced85075e2018-03-02 13:19:30 -0500467
468 def tearDown(self):
469 self.thru_host_stack_tear_down()
Florin Corasdc2e2512018-12-03 17:47:26 -0800470 super(LDPThruHostStackNsock, self).tearDown()
Dave Wallaced85075e2018-03-02 13:19:30 -0500471
Dave Wallaced85075e2018-03-02 13:19:30 -0500472 def test_ldp_thru_host_stack_uni_dir_nsock(self):
473 """ run LDP thru host stack uni-directional (multiple sockets) test """
474
475 self.timeout = self.client_uni_dir_nsock_timeout
Dave Wallace816833f2018-03-14 20:01:28 -0400476 self.thru_host_stack_test("sock_test_server", self.server_args,
477 "sock_test_client",
Dave Wallaced85075e2018-03-02 13:19:30 -0500478 self.client_uni_dir_nsock_test_args)
479
480
Florin Corasdc2e2512018-12-03 17:47:26 -0800481class VCLThruHostStackNsock(VCLTestCase):
482 """ VCL Thru Host Stack Nsock """
Dave Wallaced85075e2018-03-02 13:19:30 -0500483
484 def setUp(self):
Florin Corasdc2e2512018-12-03 17:47:26 -0800485 super(VCLThruHostStackNsock, self).setUp()
Dave Wallaced85075e2018-03-02 13:19:30 -0500486
487 self.thru_host_stack_setup()
488 if self.vppDebug:
Florin Coras2eb42e72018-11-29 00:39:53 -0800489 self.client_uni_dir_nsock_timeout = 20
Dave Wallaced85075e2018-03-02 13:19:30 -0500490 self.numSockets = "2"
491 else:
Florin Coras2eb42e72018-11-29 00:39:53 -0800492 self.client_uni_dir_nsock_timeout = 20
Dave Wallaced85075e2018-03-02 13:19:30 -0500493 self.numSockets = "5"
494
Dave Wallace45cd3a32018-06-26 01:14:04 -0400495 self.client_uni_dir_nsock_test_args = ["-N", "1000", "-U", "-X",
496 "-I", self.numSockets,
Dave Wallacede910062018-03-20 09:22:13 -0400497 self.loop0.local_ip4,
498 self.server_port]
Dave Wallaced85075e2018-03-02 13:19:30 -0500499
500 def tearDown(self):
501 self.thru_host_stack_tear_down()
Florin Corasdc2e2512018-12-03 17:47:26 -0800502 super(VCLThruHostStackNsock, self).tearDown()
Dave Wallaced85075e2018-03-02 13:19:30 -0500503
Dave Wallaced85075e2018-03-02 13:19:30 -0500504 def test_vcl_thru_host_stack_uni_dir_nsock(self):
505 """ run VCL thru host stack uni-directional (multiple sockets) test """
506
507 self.timeout = self.client_uni_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700508 self.thru_host_stack_test("vcl_test_server", self.server_args,
509 "vcl_test_client",
Dave Wallaced85075e2018-03-02 13:19:30 -0500510 self.client_uni_dir_nsock_test_args)
511
512
Florin Corasdc2e2512018-12-03 17:47:26 -0800513class LDPThruHostStackIperf(VCLTestCase):
514 """ LDP Thru Host Stack Iperf """
Dave Wallace816833f2018-03-14 20:01:28 -0400515
516 def setUp(self):
Florin Corasdc2e2512018-12-03 17:47:26 -0800517 super(LDPThruHostStackIperf, self).setUp()
Dave Wallace816833f2018-03-14 20:01:28 -0400518
519 self.thru_host_stack_setup()
520 self.client_iperf3_timeout = 20
Florin Corasdc2e2512018-12-03 17:47:26 -0800521 self.client_iperf3_args = ["-V4d", "-t 2", "-c", self.loop0.local_ip4]
Dave Wallace816833f2018-03-14 20:01:28 -0400522 self.server_iperf3_args = ["-V4d", "-s"]
523
524 def tearDown(self):
525 self.thru_host_stack_tear_down()
Florin Corasdc2e2512018-12-03 17:47:26 -0800526 super(LDPThruHostStackIperf, self).tearDown()
Dave Wallace816833f2018-03-14 20:01:28 -0400527
528 def test_ldp_thru_host_stack_iperf3(self):
529 """ run LDP thru host stack iperf3 test """
530
531 try:
532 subprocess.check_output(['iperf3', '-v'])
Paul Vinciguerra61e63bf2018-11-24 21:19:38 -0800533 except subprocess.CalledProcessError:
Dave Wallace816833f2018-03-14 20:01:28 -0400534 self.logger.error("WARNING: 'iperf3' is not installed,")
535 self.logger.error(
536 " 'test_ldp_thru_host_stack_iperf3' not run!")
537 return
538
539 self.timeout = self.client_iperf3_timeout
540 self.thru_host_stack_test("iperf3", self.server_iperf3_args,
541 "iperf3", self.client_iperf3_args)
542
543
Florin Coras0ae445e2018-11-29 18:22:10 -0800544class LDPIpv6CutThruTestCase(VCLTestCase):
545 """ LDP IPv6 Cut Thru Tests """
Dave Wallacede910062018-03-20 09:22:13 -0400546
547 def setUp(self):
Florin Coras0ae445e2018-11-29 18:22:10 -0800548 super(LDPIpv6CutThruTestCase, self).setUp()
Dave Wallacede910062018-03-20 09:22:13 -0400549
550 self.cut_thru_setup()
551 self.client_iperf3_timeout = 20
Florin Coras2eb42e72018-11-29 00:39:53 -0800552 self.client_uni_dir_nsock_timeout = 20
553 self.client_bi_dir_nsock_timeout = 20
Dave Wallacede910062018-03-20 09:22:13 -0400554 self.client_ipv6_echo_test_args = ["-6", "-E", self.echo_phrase, "-X",
555 self.server_ipv6_addr,
556 self.server_port]
Florin Corasdc2e2512018-12-03 17:47:26 -0800557 self.client_ipv6_iperf3_args = ["-V6d", "-t 2", "-c",
Florin Corasab2f6db2018-08-31 14:31:41 -0700558 self.server_ipv6_addr]
Dave Wallacede910062018-03-20 09:22:13 -0400559 self.server_ipv6_iperf3_args = ["-V6d", "-s"]
Dave Wallace45cd3a32018-06-26 01:14:04 -0400560 self.client_ipv6_uni_dir_nsock_test_args = ["-N", "1000", "-U", "-X",
561 "-6",
562 "-I", "2",
Dave Wallacede910062018-03-20 09:22:13 -0400563 self.server_ipv6_addr,
564 self.server_port]
Dave Wallace45cd3a32018-06-26 01:14:04 -0400565 self.client_ipv6_bi_dir_nsock_test_args = ["-N", "1000", "-B", "-X",
566 "-6",
567 "-I", "2",
Dave Wallacede910062018-03-20 09:22:13 -0400568 self.server_ipv6_addr,
569 self.server_port]
570
571 def tearDown(self):
572 self.cut_thru_tear_down()
573
Florin Coras0ae445e2018-11-29 18:22:10 -0800574 super(LDPIpv6CutThruTestCase, self).tearDown()
Dave Wallacede910062018-03-20 09:22:13 -0400575
576 def test_ldp_ipv6_cut_thru_echo(self):
577 """ run LDP IPv6 cut thru echo test """
578
Florin Corasab2f6db2018-08-31 14:31:41 -0700579 self.cut_thru_test("sock_test_server",
Dave Wallacede910062018-03-20 09:22:13 -0400580 self.server_ipv6_args,
Florin Corasab2f6db2018-08-31 14:31:41 -0700581 "sock_test_client",
Dave Wallacede910062018-03-20 09:22:13 -0400582 self.client_ipv6_echo_test_args)
583
Paul Vinciguerradefde0f2018-12-06 07:46:13 -0800584 @unittest.skipUnless(running_extended_tests, "part of extended tests")
Dave Wallacede910062018-03-20 09:22:13 -0400585 def test_ldp_ipv6_cut_thru_iperf3(self):
586 """ run LDP IPv6 cut thru iperf3 test """
587
588 try:
589 subprocess.check_output(['iperf3', '-v'])
590 except:
591 self.logger.error("WARNING: 'iperf3' is not installed,")
592 self.logger.error(
593 " 'test_ldp_ipv6_cut_thru_iperf3' not run!")
594 return
595
596 self.timeout = self.client_iperf3_timeout
597 self.cut_thru_test("iperf3", self.server_ipv6_iperf3_args,
598 "iperf3", self.client_ipv6_iperf3_args)
599
Paul Vinciguerradefde0f2018-12-06 07:46:13 -0800600 @unittest.skipUnless(running_extended_tests, "part of extended tests")
Dave Wallacede910062018-03-20 09:22:13 -0400601 def test_ldp_ipv6_cut_thru_uni_dir_nsock(self):
602 """ run LDP IPv6 cut thru uni-directional (multiple sockets) test """
603
604 self.timeout = self.client_uni_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700605 self.cut_thru_test("sock_test_server", self.server_ipv6_args,
606 "sock_test_client",
Dave Wallacede910062018-03-20 09:22:13 -0400607 self.client_ipv6_uni_dir_nsock_test_args)
608
Paul Vinciguerradefde0f2018-12-06 07:46:13 -0800609 @unittest.skipUnless(running_extended_tests, "part of extended tests")
Dave Wallacede910062018-03-20 09:22:13 -0400610 def test_ldp_ipv6_cut_thru_bi_dir_nsock(self):
611 """ run LDP IPv6 cut thru bi-directional (multiple sockets) test """
612
613 self.timeout = self.client_bi_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700614 self.cut_thru_test("sock_test_server", self.server_ipv6_args,
615 "sock_test_client",
Dave Wallacede910062018-03-20 09:22:13 -0400616 self.client_ipv6_bi_dir_nsock_test_args)
617
Florin Coras0ae445e2018-11-29 18:22:10 -0800618
619class VCLIpv6CutThruTestCase(VCLTestCase):
620 """ VCL IPv6 Cut Thru Tests """
621
622 def setUp(self):
623 super(VCLIpv6CutThruTestCase, self).setUp()
624
625 self.cut_thru_setup()
626 self.client_uni_dir_nsock_timeout = 20
627 self.client_bi_dir_nsock_timeout = 20
628 self.client_ipv6_echo_test_args = ["-6", "-E", self.echo_phrase, "-X",
629 self.server_ipv6_addr,
630 self.server_port]
631 self.client_ipv6_uni_dir_nsock_test_args = ["-N", "1000", "-U", "-X",
632 "-6",
633 "-I", "2",
634 self.server_ipv6_addr,
635 self.server_port]
636 self.client_ipv6_bi_dir_nsock_test_args = ["-N", "1000", "-B", "-X",
637 "-6",
638 "-I", "2",
639 self.server_ipv6_addr,
640 self.server_port]
641
642 def tearDown(self):
643 self.cut_thru_tear_down()
644
645 super(VCLIpv6CutThruTestCase, self).tearDown()
646
Dave Wallacede910062018-03-20 09:22:13 -0400647 def test_vcl_ipv6_cut_thru_echo(self):
648 """ run VCL IPv6 cut thru echo test """
649
Florin Corasab2f6db2018-08-31 14:31:41 -0700650 self.cut_thru_test("vcl_test_server",
Dave Wallacede910062018-03-20 09:22:13 -0400651 self.server_ipv6_args,
Florin Corasab2f6db2018-08-31 14:31:41 -0700652 "vcl_test_client",
Dave Wallacede910062018-03-20 09:22:13 -0400653 self.client_ipv6_echo_test_args)
654
Paul Vinciguerradefde0f2018-12-06 07:46:13 -0800655 @unittest.skipUnless(running_extended_tests, "part of extended tests")
Dave Wallacede910062018-03-20 09:22:13 -0400656 def test_vcl_ipv6_cut_thru_uni_dir_nsock(self):
657 """ run VCL IPv6 cut thru uni-directional (multiple sockets) test """
658
659 self.timeout = self.client_uni_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700660 self.cut_thru_test("vcl_test_server", self.server_ipv6_args,
661 "vcl_test_client",
Dave Wallacede910062018-03-20 09:22:13 -0400662 self.client_ipv6_uni_dir_nsock_test_args)
663
Paul Vinciguerradefde0f2018-12-06 07:46:13 -0800664 @unittest.skipUnless(running_extended_tests, "part of extended tests")
Dave Wallacede910062018-03-20 09:22:13 -0400665 def test_vcl_ipv6_cut_thru_bi_dir_nsock(self):
666 """ run VCL IPv6 cut thru bi-directional (multiple sockets) test """
667
668 self.timeout = self.client_bi_dir_nsock_timeout
Florin Corasab2f6db2018-08-31 14:31:41 -0700669 self.cut_thru_test("vcl_test_server", self.server_ipv6_args,
670 "vcl_test_client",
Dave Wallacede910062018-03-20 09:22:13 -0400671 self.client_ipv6_bi_dir_nsock_test_args)
672
673
Florin Corasdc2e2512018-12-03 17:47:26 -0800674class VCLIpv6ThruHostStackEcho(VCLTestCase):
675 """ VCL IPv6 Thru Host Stack Echo """
Dave Wallacede910062018-03-20 09:22:13 -0400676
677 def setUp(self):
Florin Corasdc2e2512018-12-03 17:47:26 -0800678 super(VCLIpv6ThruHostStackEcho, self).setUp()
Dave Wallacede910062018-03-20 09:22:13 -0400679
680 self.thru_host_stack_ipv6_setup()
681 self.client_ipv6_echo_test_args = ["-6", "-E", self.echo_phrase, "-X",
682 self.loop0.local_ip6,
683 self.server_port]
684
685 def tearDown(self):
686 self.thru_host_stack_ipv6_tear_down()
Florin Corasdc2e2512018-12-03 17:47:26 -0800687 super(VCLIpv6ThruHostStackEcho, self).tearDown()
Dave Wallacede910062018-03-20 09:22:13 -0400688
689 def test_vcl_ipv6_thru_host_stack_echo(self):
690 """ run VCL IPv6 thru host stack echo test """
691
Florin Corasdc2e2512018-12-03 17:47:26 -0800692 self.thru_host_stack_test("vcl_test_server",
Damjan Marion855e2682018-08-24 13:37:45 +0200693 self.server_ipv6_args,
Florin Corasab2f6db2018-08-31 14:31:41 -0700694 "vcl_test_client",
Florin Corasdc2e2512018-12-03 17:47:26 -0800695 self.client_ipv6_echo_test_args)
Dave Wallacede910062018-03-20 09:22:13 -0400696
697
Dave Wallacecfcf2f42018-02-16 18:31:56 -0500698if __name__ == '__main__':
699 unittest.main(testRunner=VppTestRunner)