a574f7ff6f47a1eb3ebd3f1925ddaa0c71105d46
[vpp.git] / test / test_vcl.py
1 #!/usr/bin/env python3
2 """ Vpp VCL tests """
3
4 import unittest
5 import os
6 import subprocess
7 import signal
8 from framework import VppTestCase, VppTestRunner, running_extended_tests, \
9     Worker, is_platform_aarch64
10 from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath, FibPathProto
11
12 iperf3 = '/usr/bin/iperf3'
13
14
15 def have_app(app):
16     try:
17         subprocess.check_output([app, '-v'])
18     except (subprocess.CalledProcessError, OSError):
19         return False
20     return True
21
22
23 _have_iperf3 = have_app(iperf3)
24
25
26 class VCLAppWorker(Worker):
27     """ VCL Test Application Worker """
28
29     def __init__(self, build_dir, appname, executable_args, logger, env=None,
30                  role=None, *args, **kwargs):
31         self.role = role
32         if env is None:
33             env = {}
34         vcl_lib_dir = "%s/vpp/lib" % build_dir
35         if "iperf" in appname:
36             app = appname
37             env.update({'LD_PRELOAD':
38                         "%s/libvcl_ldpreload.so" % vcl_lib_dir})
39         elif "sock" in appname:
40             app = "%s/vpp/bin/%s" % (build_dir, appname)
41             env.update({'LD_PRELOAD':
42                         "%s/libvcl_ldpreload.so" % vcl_lib_dir})
43         else:
44             app = "%s/vpp/bin/%s" % (build_dir, appname)
45         self.args = [app] + executable_args
46         super(VCLAppWorker, self).__init__(self.args, logger, env,
47                                            *args, **kwargs)
48
49
50 class VCLTestCase(VppTestCase):
51     """ VCL Test Class """
52     extra_vpp_punt_config = ["session", "{", "poll-main", "}"]
53
54     @classmethod
55     def setUpClass(cls):
56         super(VCLTestCase, cls).setUpClass()
57
58     @classmethod
59     def tearDownClass(cls):
60         super(VCLTestCase, cls).tearDownClass()
61
62     def setUp(self):
63         var = "VPP_BUILD_DIR"
64         self.build_dir = os.getenv(var, None)
65         if self.build_dir is None:
66             raise EnvironmentError("Environment variable `%s' not set" % var)
67         self.vppDebug = 'vpp_debug' in self.build_dir
68         self.server_addr = "127.0.0.1"
69         self.server_port = "22000"
70         self.server_args = [self.server_port]
71         self.server_ipv6_addr = "::1"
72         self.server_ipv6_args = ["-6", self.server_port]
73         self.timeout = 20
74         self.echo_phrase = "Hello, world! Jenny is a friend of mine."
75         self.pre_test_sleep = 0.3
76         self.post_test_sleep = 0.2
77
78         if os.path.isfile("/tmp/ldp_server_af_unix_socket"):
79             os.remove("/tmp/ldp_server_af_unix_socket")
80
81         super(VCLTestCase, self).setUp()
82
83     def cut_thru_setup(self):
84         self.vapi.session_enable_disable(is_enable=1)
85
86     def cut_thru_tear_down(self):
87         self.vapi.session_enable_disable(is_enable=0)
88
89     def cut_thru_test(self, server_app, server_args, client_app, client_args):
90         self.env = {'VCL_VPP_API_SOCKET': self.get_api_sock_path(),
91                     'VCL_APP_SCOPE_LOCAL': "true"}
92         worker_server = VCLAppWorker(self.build_dir, server_app, server_args,
93                                      self.logger, self.env, "server")
94         worker_server.start()
95         self.sleep(self.pre_test_sleep)
96         worker_client = VCLAppWorker(self.build_dir, client_app, client_args,
97                                      self.logger, self.env, "client")
98         worker_client.start()
99         worker_client.join(self.timeout)
100         try:
101             self.validateResults(worker_client, worker_server, self.timeout)
102         except Exception as error:
103             self.fail("Failed with %s" % error)
104         self.sleep(self.post_test_sleep)
105
106     def thru_host_stack_setup(self):
107         self.vapi.session_enable_disable(is_enable=1)
108         self.create_loopback_interfaces(2)
109
110         table_id = 1
111
112         for i in self.lo_interfaces:
113             i.admin_up()
114
115             if table_id != 0:
116                 tbl = VppIpTable(self, table_id)
117                 tbl.add_vpp_config()
118
119             i.set_table_ip4(table_id)
120             i.config_ip4()
121             table_id += 1
122
123         # Configure namespaces
124         self.vapi.app_namespace_add_del(namespace_id="1", secret=1234,
125                                         sw_if_index=self.loop0.sw_if_index)
126         self.vapi.app_namespace_add_del(namespace_id="2", secret=5678,
127                                         sw_if_index=self.loop1.sw_if_index)
128
129         # Add inter-table routes
130         ip_t01 = VppIpRoute(self, self.loop1.local_ip4, 32,
131                             [VppRoutePath("0.0.0.0",
132                                           0xffffffff,
133                                           nh_table_id=2)], table_id=1)
134         ip_t10 = VppIpRoute(self, self.loop0.local_ip4, 32,
135                             [VppRoutePath("0.0.0.0",
136                                           0xffffffff,
137                                           nh_table_id=1)], table_id=2)
138         ip_t01.add_vpp_config()
139         ip_t10.add_vpp_config()
140         self.logger.debug(self.vapi.cli("show ip fib"))
141
142     def thru_host_stack_tear_down(self):
143         for i in self.lo_interfaces:
144             i.unconfig_ip4()
145             i.set_table_ip4(0)
146             i.admin_down()
147
148     def thru_host_stack_ipv6_setup(self):
149         self.vapi.session_enable_disable(is_enable=1)
150         self.create_loopback_interfaces(2)
151
152         table_id = 1
153
154         for i in self.lo_interfaces:
155             i.admin_up()
156
157             tbl = VppIpTable(self, table_id, is_ip6=1)
158             tbl.add_vpp_config()
159
160             i.set_table_ip6(table_id)
161             i.config_ip6()
162             table_id += 1
163
164         # Configure namespaces
165         self.vapi.app_namespace_add_del(namespace_id="1", secret=1234,
166                                         sw_if_index=self.loop0.sw_if_index)
167         self.vapi.app_namespace_add_del(namespace_id="2", secret=5678,
168                                         sw_if_index=self.loop1.sw_if_index)
169
170         # Add inter-table routes
171         ip_t01 = VppIpRoute(self, self.loop1.local_ip6, 128,
172                             [VppRoutePath("::0", 0xffffffff,
173                                           nh_table_id=2)],
174                             table_id=1)
175         ip_t10 = VppIpRoute(self, self.loop0.local_ip6, 128,
176                             [VppRoutePath("::0", 0xffffffff,
177                                           nh_table_id=1)],
178                             table_id=2)
179         ip_t01.add_vpp_config()
180         ip_t10.add_vpp_config()
181         self.logger.debug(self.vapi.cli("show interface addr"))
182         self.logger.debug(self.vapi.cli("show ip6 fib"))
183
184     def thru_host_stack_ipv6_tear_down(self):
185         for i in self.lo_interfaces:
186             i.unconfig_ip6()
187             i.set_table_ip6(0)
188             i.admin_down()
189
190         self.vapi.session_enable_disable(is_enable=0)
191
192     @unittest.skipUnless(_have_iperf3, "'%s' not found, Skipping.")
193     def thru_host_stack_test(self, server_app, server_args,
194                              client_app, client_args):
195         self.env = {'VCL_VPP_API_SOCKET': self.get_api_sock_path(),
196                     'VCL_APP_SCOPE_GLOBAL': "true",
197                     'VCL_APP_NAMESPACE_ID': "1",
198                     'VCL_APP_NAMESPACE_SECRET': "1234"}
199
200         worker_server = VCLAppWorker(self.build_dir, server_app, server_args,
201                                      self.logger, self.env, "server")
202         worker_server.start()
203         self.sleep(self.pre_test_sleep)
204
205         self.env.update({'VCL_APP_NAMESPACE_ID': "2",
206                          'VCL_APP_NAMESPACE_SECRET': "5678"})
207         worker_client = VCLAppWorker(self.build_dir, client_app, client_args,
208                                      self.logger, self.env, "client")
209         worker_client.start()
210         worker_client.join(self.timeout)
211
212         try:
213             self.validateResults(worker_client, worker_server, self.timeout)
214         except Exception as error:
215             self.fail("Failed with %s" % error)
216         self.sleep(self.post_test_sleep)
217
218     def validateResults(self, worker_client, worker_server, timeout):
219         if worker_server.process is None:
220             raise RuntimeError('worker_server is not running.')
221         if os.path.isdir('/proc/{}'.format(worker_server.process.pid)):
222             self.logger.info("Killing server worker process (pid %d)" %
223                              worker_server.process.pid)
224             os.killpg(os.getpgid(worker_server.process.pid), signal.SIGTERM)
225             worker_server.join()
226         self.logger.info("Client worker result is `%s'" % worker_client.result)
227         error = False
228         if worker_client.result is None:
229             try:
230                 error = True
231                 self.logger.error(
232                     "Timeout: %ss! Killing client worker process (pid %d)" %
233                     (timeout, worker_client.process.pid))
234                 os.killpg(os.getpgid(worker_client.process.pid),
235                           signal.SIGKILL)
236                 worker_client.join()
237             except OSError:
238                 self.logger.debug(
239                     "Couldn't kill client worker process")
240                 raise
241         if error:
242             raise RuntimeError(
243                 "Timeout! Client worker did not finish in %ss" % timeout)
244         self.assert_equal(worker_client.result, 0, "Binary test return code")
245
246
247 class LDPCutThruTestCase(VCLTestCase):
248     """ LDP Cut Thru Tests """
249
250     @classmethod
251     def setUpClass(cls):
252         super(LDPCutThruTestCase, cls).setUpClass()
253
254     @classmethod
255     def tearDownClass(cls):
256         super(LDPCutThruTestCase, cls).tearDownClass()
257
258     def setUp(self):
259         super(LDPCutThruTestCase, self).setUp()
260
261         self.cut_thru_setup()
262         self.client_echo_test_args = ["-E", self.echo_phrase, "-X",
263                                       self.server_addr, self.server_port]
264         self.client_iperf3_timeout = 20
265         self.client_iperf3_args = ["-4", "-t 2", "-c", self.server_addr]
266         self.server_iperf3_args = ["-4", "-s"]
267         self.client_uni_dir_nsock_timeout = 20
268         self.client_uni_dir_nsock_test_args = ["-N", "1000", "-U", "-X",
269                                                "-I", "2",
270                                                self.server_addr,
271                                                self.server_port]
272         self.client_bi_dir_nsock_timeout = 20
273         self.client_bi_dir_nsock_test_args = ["-N", "1000", "-B", "-X",
274                                               "-I", "2",
275                                               self.server_addr,
276                                               self.server_port]
277
278     def tearDown(self):
279         super(LDPCutThruTestCase, self).tearDown()
280         self.cut_thru_tear_down()
281
282     def show_commands_at_teardown(self):
283         self.logger.debug(self.vapi.cli("show session verbose 2"))
284         self.logger.debug(self.vapi.cli("show app mq"))
285
286     @unittest.skipUnless(running_extended_tests, "part of extended tests")
287     def test_ldp_cut_thru_echo(self):
288         """ run LDP cut thru echo test """
289
290         self.cut_thru_test("sock_test_server", self.server_args,
291                            "sock_test_client", self.client_echo_test_args)
292
293     @unittest.skipUnless(_have_iperf3, "'%s' not found, Skipping.")
294     @unittest.skipIf(is_platform_aarch64,
295                      "intermittently fails on AARCH64 CI jobs")
296     def test_ldp_cut_thru_iperf3(self):
297         """ run LDP cut thru iperf3 test """
298
299         self.timeout = self.client_iperf3_timeout
300         self.cut_thru_test(iperf3, self.server_iperf3_args,
301                            iperf3, self.client_iperf3_args)
302
303     @unittest.skipUnless(running_extended_tests, "part of extended tests")
304     def test_ldp_cut_thru_uni_dir_nsock(self):
305         """ run LDP cut thru uni-directional (multiple sockets) test """
306
307         self.timeout = self.client_uni_dir_nsock_timeout
308         self.cut_thru_test("sock_test_server", self.server_args,
309                            "sock_test_client",
310                            self.client_uni_dir_nsock_test_args)
311
312     @unittest.skipUnless(running_extended_tests, "part of extended tests")
313     @unittest.skip("sock test apps need to be improved")
314     def test_ldp_cut_thru_bi_dir_nsock(self):
315         """ run LDP cut thru bi-directional (multiple sockets) test """
316
317         self.timeout = self.client_bi_dir_nsock_timeout
318         self.cut_thru_test("sock_test_server", self.server_args,
319                            "sock_test_client",
320                            self.client_bi_dir_nsock_test_args)
321
322
323 class VCLCutThruTestCase(VCLTestCase):
324     """ VCL Cut Thru Tests """
325
326     @classmethod
327     def setUpClass(cls):
328         super(VCLCutThruTestCase, cls).setUpClass()
329
330     @classmethod
331     def tearDownClass(cls):
332         super(VCLCutThruTestCase, cls).tearDownClass()
333
334     def setUp(self):
335         super(VCLCutThruTestCase, self).setUp()
336
337         self.cut_thru_setup()
338         self.client_echo_test_args = ["-E", self.echo_phrase, "-X",
339                                       self.server_addr, self.server_port]
340
341         self.client_uni_dir_nsock_timeout = 20
342         self.client_uni_dir_nsock_test_args = ["-N", "1000", "-U", "-X",
343                                                "-I", "2",
344                                                self.server_addr,
345                                                self.server_port]
346         self.client_bi_dir_nsock_timeout = 20
347         self.client_bi_dir_nsock_test_args = ["-N", "1000", "-B", "-X",
348                                               "-I", "2",
349                                               self.server_addr,
350                                               self.server_port]
351
352     def tearDown(self):
353         super(VCLCutThruTestCase, self).tearDown()
354
355     def show_commands_at_teardown(self):
356         self.logger.debug(self.vapi.cli("show session verbose 2"))
357         self.logger.debug(self.vapi.cli("show app mq"))
358
359     def test_vcl_cut_thru_echo(self):
360         """ run VCL cut thru echo test """
361
362         self.cut_thru_test("vcl_test_server", self.server_args,
363                            "vcl_test_client", self.client_echo_test_args)
364
365     def test_vcl_cut_thru_uni_dir_nsock(self):
366         """ run VCL cut thru uni-directional (multiple sockets) test """
367
368         self.timeout = self.client_uni_dir_nsock_timeout
369         self.cut_thru_test("vcl_test_server", self.server_args,
370                            "vcl_test_client",
371                            self.client_uni_dir_nsock_test_args)
372
373     def test_vcl_cut_thru_bi_dir_nsock(self):
374         """ run VCL cut thru bi-directional (multiple sockets) test """
375
376         self.timeout = self.client_bi_dir_nsock_timeout
377         self.cut_thru_test("vcl_test_server", self.server_args,
378                            "vcl_test_client",
379                            self.client_bi_dir_nsock_test_args)
380
381
382 class VCLThruHostStackEcho(VCLTestCase):
383     """ VCL Thru Host Stack Echo """
384
385     @classmethod
386     def setUpClass(cls):
387         super(VCLThruHostStackEcho, cls).setUpClass()
388
389     @classmethod
390     def tearDownClass(cls):
391         super(VCLThruHostStackEcho, cls).tearDownClass()
392
393     def setUp(self):
394         super(VCLThruHostStackEcho, self).setUp()
395
396         self.thru_host_stack_setup()
397         self.client_bi_dir_nsock_timeout = 20
398         self.client_bi_dir_nsock_test_args = ["-N", "1000", "-B", "-X",
399                                               "-I", "2",
400                                               self.loop0.local_ip4,
401                                               self.server_port]
402         self.client_echo_test_args = ["-E", self.echo_phrase, "-X",
403                                       self.loop0.local_ip4,
404                                       self.server_port]
405
406     def tearDown(self):
407         self.thru_host_stack_tear_down()
408         super(VCLThruHostStackEcho, self).tearDown()
409
410     def show_commands_at_teardown(self):
411         self.logger.debug(self.vapi.cli("show app server"))
412         self.logger.debug(self.vapi.cli("show session verbose"))
413         self.logger.debug(self.vapi.cli("show app mq"))
414
415
416 class VCLThruHostStackTLS(VCLTestCase):
417     """ VCL Thru Host Stack TLS """
418
419     @classmethod
420     def setUpClass(cls):
421         super(VCLThruHostStackTLS, cls).setUpClass()
422
423     @classmethod
424     def tearDownClass(cls):
425         super(VCLThruHostStackTLS, cls).tearDownClass()
426
427     def setUp(self):
428         super(VCLThruHostStackTLS, self).setUp()
429
430         self.thru_host_stack_setup()
431         self.client_uni_dir_tls_timeout = 20
432         self.server_tls_args = ["-L", self.server_port]
433         self.client_uni_dir_tls_test_args = ["-N", "1000", "-U", "-X", "-L",
434                                              self.loop0.local_ip4,
435                                              self.server_port]
436
437     def test_vcl_thru_host_stack_tls_uni_dir(self):
438         """ run VCL thru host stack uni-directional TLS test """
439
440         self.timeout = self.client_uni_dir_tls_timeout
441         self.thru_host_stack_test("vcl_test_server", self.server_tls_args,
442                                   "vcl_test_client",
443                                   self.client_uni_dir_tls_test_args)
444
445     def tearDown(self):
446         self.thru_host_stack_tear_down()
447         super(VCLThruHostStackTLS, self).tearDown()
448
449     def show_commands_at_teardown(self):
450         self.logger.debug(self.vapi.cli("show app server"))
451         self.logger.debug(self.vapi.cli("show session verbose 2"))
452         self.logger.debug(self.vapi.cli("show app mq"))
453
454
455 class VCLThruHostStackDTLS(VCLTestCase):
456     """ VCL Thru Host Stack DTLS """
457
458     @classmethod
459     def setUpClass(cls):
460         super(VCLThruHostStackDTLS, cls).setUpClass()
461
462     @classmethod
463     def tearDownClass(cls):
464         super(VCLThruHostStackDTLS, cls).tearDownClass()
465
466     def setUp(self):
467         super(VCLThruHostStackDTLS, self).setUp()
468
469         self.thru_host_stack_setup()
470         self.client_uni_dir_dtls_timeout = 20
471         self.server_dtls_args = ["-p", "dtls", self.server_port]
472         self.client_uni_dir_dtls_test_args = ["-N", "1000", "-U", "-X",
473                                               "-p", "dtls", "-T 1400",
474                                               self.loop0.local_ip4,
475                                               self.server_port]
476
477     def test_vcl_thru_host_stack_dtls_uni_dir(self):
478         """ run VCL thru host stack uni-directional DTLS test """
479
480         self.timeout = self.client_uni_dir_dtls_timeout
481         self.thru_host_stack_test("vcl_test_server", self.server_dtls_args,
482                                   "vcl_test_client",
483                                   self.client_uni_dir_dtls_test_args)
484
485     def tearDown(self):
486         self.thru_host_stack_tear_down()
487         super(VCLThruHostStackDTLS, self).tearDown()
488
489     def show_commands_at_teardown(self):
490         self.logger.debug(self.vapi.cli("show app server"))
491         self.logger.debug(self.vapi.cli("show session verbose 2"))
492         self.logger.debug(self.vapi.cli("show app mq"))
493
494
495 class VCLThruHostStackQUIC(VCLTestCase):
496     """ VCL Thru Host Stack QUIC """
497
498     @classmethod
499     def setUpClass(cls):
500         cls.extra_vpp_plugin_config.append("plugin quic_plugin.so { enable }")
501         super(VCLThruHostStackQUIC, cls).setUpClass()
502
503     @classmethod
504     def tearDownClass(cls):
505         super(VCLThruHostStackQUIC, cls).tearDownClass()
506
507     def setUp(self):
508         super(VCLThruHostStackQUIC, self).setUp()
509
510         self.thru_host_stack_setup()
511         self.client_uni_dir_quic_timeout = 20
512         self.server_quic_args = ["-p", "quic", self.server_port]
513         self.client_uni_dir_quic_test_args = ["-N", "1000", "-U", "-X",
514                                               "-p", "quic",
515                                               self.loop0.local_ip4,
516                                               self.server_port]
517
518     @unittest.skipUnless(running_extended_tests, "part of extended tests")
519     def test_vcl_thru_host_stack_quic_uni_dir(self):
520         """ run VCL thru host stack uni-directional QUIC test """
521
522         self.timeout = self.client_uni_dir_quic_timeout
523         self.thru_host_stack_test("vcl_test_server", self.server_quic_args,
524                                   "vcl_test_client",
525                                   self.client_uni_dir_quic_test_args)
526
527     def tearDown(self):
528         self.thru_host_stack_tear_down()
529         super(VCLThruHostStackQUIC, self).tearDown()
530
531     def show_commands_at_teardown(self):
532         self.logger.debug(self.vapi.cli("show app server"))
533         self.logger.debug(self.vapi.cli("show session verbose 2"))
534         self.logger.debug(self.vapi.cli("show app mq"))
535
536
537 class VCLThruHostStackBidirNsock(VCLTestCase):
538     """ VCL Thru Host Stack Bidir Nsock """
539
540     @classmethod
541     def setUpClass(cls):
542         super(VCLThruHostStackBidirNsock, cls).setUpClass()
543
544     @classmethod
545     def tearDownClass(cls):
546         super(VCLThruHostStackBidirNsock, cls).tearDownClass()
547
548     def setUp(self):
549         super(VCLThruHostStackBidirNsock, self).setUp()
550
551         self.thru_host_stack_setup()
552         self.client_bi_dir_nsock_timeout = 20
553         self.client_bi_dir_nsock_test_args = ["-N", "1000", "-B", "-X",
554                                               "-I", "2",
555                                               self.loop0.local_ip4,
556                                               self.server_port]
557         self.client_echo_test_args = ["-E", self.echo_phrase, "-X",
558                                       self.loop0.local_ip4,
559                                       self.server_port]
560
561     def tearDown(self):
562         self.thru_host_stack_tear_down()
563         super(VCLThruHostStackBidirNsock, self).tearDown()
564
565     def show_commands_at_teardown(self):
566         self.logger.debug(self.vapi.cli("show session verbose 2"))
567         self.logger.debug(self.vapi.cli("show app mq"))
568
569     def test_vcl_thru_host_stack_bi_dir_nsock(self):
570         """ run VCL thru host stack bi-directional (multiple sockets) test """
571
572         self.timeout = self.client_bi_dir_nsock_timeout
573         self.thru_host_stack_test("vcl_test_server", self.server_args,
574                                   "vcl_test_client",
575                                   self.client_bi_dir_nsock_test_args)
576
577
578 class LDPThruHostStackBidirNsock(VCLTestCase):
579     """ LDP Thru Host Stack Bidir Nsock """
580
581     @classmethod
582     def setUpClass(cls):
583         super(LDPThruHostStackBidirNsock, cls).setUpClass()
584
585     @classmethod
586     def tearDownClass(cls):
587         super(LDPThruHostStackBidirNsock, cls).tearDownClass()
588
589     def setUp(self):
590         super(LDPThruHostStackBidirNsock, self).setUp()
591
592         self.thru_host_stack_setup()
593         self.client_bi_dir_nsock_timeout = 20
594         self.client_bi_dir_nsock_test_args = ["-N", "1000", "-B", "-X",
595                                               # OUCH! Host Stack Bug?
596                                               # Only fails when running
597                                               # 'make test TEST_JOBS=auto'
598                                               # or TEST_JOBS > 1
599                                               # "-I", "2",
600                                               self.loop0.local_ip4,
601                                               self.server_port]
602
603     def tearDown(self):
604         self.thru_host_stack_tear_down()
605         super(LDPThruHostStackBidirNsock, self).tearDown()
606
607     def show_commands_at_teardown(self):
608         self.logger.debug(self.vapi.cli("show session verbose 2"))
609         self.logger.debug(self.vapi.cli("show app mq"))
610
611     def test_ldp_thru_host_stack_bi_dir_nsock(self):
612         """ run LDP thru host stack bi-directional (multiple sockets) test """
613
614         self.timeout = self.client_bi_dir_nsock_timeout
615         self.thru_host_stack_test("sock_test_server", self.server_args,
616                                   "sock_test_client",
617                                   self.client_bi_dir_nsock_test_args)
618
619
620 class LDPThruHostStackNsock(VCLTestCase):
621     """ LDP Thru Host Stack Nsock """
622
623     @classmethod
624     def setUpClass(cls):
625         super(LDPThruHostStackNsock, cls).setUpClass()
626
627     @classmethod
628     def tearDownClass(cls):
629         super(LDPThruHostStackNsock, cls).tearDownClass()
630
631     def setUp(self):
632         super(LDPThruHostStackNsock, self).setUp()
633
634         self.thru_host_stack_setup()
635         if self.vppDebug:
636             self.client_uni_dir_nsock_timeout = 20
637             self.numSockets = "2"
638         else:
639             self.client_uni_dir_nsock_timeout = 20
640             self.numSockets = "5"
641
642         self.client_uni_dir_nsock_test_args = ["-N", "1000", "-U", "-X",
643                                                "-I", self.numSockets,
644                                                self.loop0.local_ip4,
645                                                self.server_port]
646
647     def tearDown(self):
648         self.thru_host_stack_tear_down()
649         super(LDPThruHostStackNsock, self).tearDown()
650
651     def test_ldp_thru_host_stack_uni_dir_nsock(self):
652         """ run LDP thru host stack uni-directional (multiple sockets) test """
653
654         self.timeout = self.client_uni_dir_nsock_timeout
655         self.thru_host_stack_test("sock_test_server", self.server_args,
656                                   "sock_test_client",
657                                   self.client_uni_dir_nsock_test_args)
658
659
660 class VCLThruHostStackNsock(VCLTestCase):
661     """ VCL Thru Host Stack Nsock """
662
663     @classmethod
664     def setUpClass(cls):
665         super(VCLThruHostStackNsock, cls).setUpClass()
666
667     @classmethod
668     def tearDownClass(cls):
669         super(VCLThruHostStackNsock, cls).tearDownClass()
670
671     def setUp(self):
672         super(VCLThruHostStackNsock, self).setUp()
673
674         self.thru_host_stack_setup()
675         if self.vppDebug:
676             self.client_uni_dir_nsock_timeout = 20
677             self.numSockets = "2"
678         else:
679             self.client_uni_dir_nsock_timeout = 20
680             self.numSockets = "5"
681
682         self.client_uni_dir_nsock_test_args = ["-N", "1000", "-U", "-X",
683                                                "-I", self.numSockets,
684                                                self.loop0.local_ip4,
685                                                self.server_port]
686
687     def tearDown(self):
688         self.thru_host_stack_tear_down()
689         super(VCLThruHostStackNsock, self).tearDown()
690
691     def test_vcl_thru_host_stack_uni_dir_nsock(self):
692         """ run VCL thru host stack uni-directional (multiple sockets) test """
693
694         self.timeout = self.client_uni_dir_nsock_timeout
695         self.thru_host_stack_test("vcl_test_server", self.server_args,
696                                   "vcl_test_client",
697                                   self.client_uni_dir_nsock_test_args)
698
699
700 class LDPThruHostStackIperf(VCLTestCase):
701     """ LDP Thru Host Stack Iperf  """
702
703     @classmethod
704     def setUpClass(cls):
705         super(LDPThruHostStackIperf, cls).setUpClass()
706
707     @classmethod
708     def tearDownClass(cls):
709         super(LDPThruHostStackIperf, cls).tearDownClass()
710
711     def setUp(self):
712         super(LDPThruHostStackIperf, self).setUp()
713
714         self.thru_host_stack_setup()
715         self.client_iperf3_timeout = 20
716         self.client_iperf3_args = ["-4", "-t 2", "-c", self.loop0.local_ip4]
717         self.server_iperf3_args = ["-4", "-s"]
718
719     def tearDown(self):
720         self.thru_host_stack_tear_down()
721         super(LDPThruHostStackIperf, self).tearDown()
722
723     def show_commands_at_teardown(self):
724         self.logger.debug(self.vapi.cli("show session verbose 2"))
725         self.logger.debug(self.vapi.cli("show app mq"))
726
727     @unittest.skipUnless(_have_iperf3, "'%s' not found, Skipping.")
728     def test_ldp_thru_host_stack_iperf3(self):
729         """ run LDP thru host stack iperf3 test """
730
731         self.timeout = self.client_iperf3_timeout
732         self.thru_host_stack_test(iperf3, self.server_iperf3_args,
733                                   iperf3, self.client_iperf3_args)
734
735
736 class LDPThruHostStackIperfUdp(VCLTestCase):
737     """ LDP Thru Host Stack Iperf UDP """
738
739     @classmethod
740     def setUpClass(cls):
741         super(LDPThruHostStackIperfUdp, cls).setUpClass()
742
743     @classmethod
744     def tearDownClass(cls):
745         super(LDPThruHostStackIperfUdp, cls).tearDownClass()
746
747     def setUp(self):
748         super(LDPThruHostStackIperfUdp, self).setUp()
749
750         self.thru_host_stack_setup()
751         self.client_iperf3_timeout = 20
752         self.client_iperf3_args = ["-4", "-t 2", "-u", "-l 1400",
753                                    "-c", self.loop0.local_ip4]
754         self.server_iperf3_args = ["-4", "-s"]
755
756     def tearDown(self):
757         self.thru_host_stack_tear_down()
758         super(LDPThruHostStackIperfUdp, self).tearDown()
759
760     def show_commands_at_teardown(self):
761         self.logger.debug(self.vapi.cli("show session verbose 2"))
762         self.logger.debug(self.vapi.cli("show app mq"))
763
764     @unittest.skipUnless(_have_iperf3, "'%s' not found, Skipping.")
765     def test_ldp_thru_host_stack_iperf3_udp(self):
766         """ run LDP thru host stack iperf3 UDP test """
767
768         self.timeout = self.client_iperf3_timeout
769         self.thru_host_stack_test(iperf3, self.server_iperf3_args,
770                                   iperf3, self.client_iperf3_args)
771
772
773 class LDPIpv6CutThruTestCase(VCLTestCase):
774     """ LDP IPv6 Cut Thru Tests """
775
776     @classmethod
777     def setUpClass(cls):
778         super(LDPIpv6CutThruTestCase, cls).setUpClass()
779
780     @classmethod
781     def tearDownClass(cls):
782         super(LDPIpv6CutThruTestCase, cls).tearDownClass()
783
784     def show_commands_at_teardown(self):
785         self.logger.debug(self.vapi.cli("show session verbose 2"))
786         self.logger.debug(self.vapi.cli("show app mq"))
787
788     def setUp(self):
789         super(LDPIpv6CutThruTestCase, self).setUp()
790
791         self.cut_thru_setup()
792         self.client_iperf3_timeout = 20
793         self.client_uni_dir_nsock_timeout = 20
794         self.client_bi_dir_nsock_timeout = 20
795         self.client_ipv6_echo_test_args = ["-6", "-E", self.echo_phrase, "-X",
796                                            self.server_ipv6_addr,
797                                            self.server_port]
798         self.client_ipv6_iperf3_args = ["-6", "-t 2", "-c",
799                                         self.server_ipv6_addr]
800         self.server_ipv6_iperf3_args = ["-6", "-s"]
801         self.client_ipv6_uni_dir_nsock_test_args = ["-N", "1000", "-U", "-X",
802                                                     "-6",
803                                                     "-I", "2",
804                                                     self.server_ipv6_addr,
805                                                     self.server_port]
806         self.client_ipv6_bi_dir_nsock_test_args = ["-N", "1000", "-B", "-X",
807                                                    "-6",
808                                                    "-I", "2",
809                                                    self.server_ipv6_addr,
810                                                    self.server_port]
811
812     def tearDown(self):
813         super(LDPIpv6CutThruTestCase, self).tearDown()
814         self.cut_thru_tear_down()
815
816     def test_ldp_ipv6_cut_thru_echo(self):
817         """ run LDP IPv6 cut thru echo test """
818
819         self.cut_thru_test("sock_test_server",
820                            self.server_ipv6_args,
821                            "sock_test_client",
822                            self.client_ipv6_echo_test_args)
823
824     @unittest.skipUnless(_have_iperf3, "'%s' not found, Skipping.")
825     @unittest.skipUnless(running_extended_tests, "part of extended tests")
826     def test_ldp_ipv6_cut_thru_iperf3(self):
827         """ run LDP IPv6 cut thru iperf3 test """
828
829         self.timeout = self.client_iperf3_timeout
830         self.cut_thru_test(iperf3, self.server_ipv6_iperf3_args,
831                            iperf3, self.client_ipv6_iperf3_args)
832
833     @unittest.skipUnless(running_extended_tests, "part of extended tests")
834     def test_ldp_ipv6_cut_thru_uni_dir_nsock(self):
835         """ run LDP IPv6 cut thru uni-directional (multiple sockets) test """
836
837         self.timeout = self.client_uni_dir_nsock_timeout
838         self.cut_thru_test("sock_test_server", self.server_ipv6_args,
839                            "sock_test_client",
840                            self.client_ipv6_uni_dir_nsock_test_args)
841
842     @unittest.skipUnless(running_extended_tests, "part of extended tests")
843     @unittest.skip("sock test apps need to be improved")
844     def test_ldp_ipv6_cut_thru_bi_dir_nsock(self):
845         """ run LDP IPv6 cut thru bi-directional (multiple sockets) test """
846
847         self.timeout = self.client_bi_dir_nsock_timeout
848         self.cut_thru_test("sock_test_server", self.server_ipv6_args,
849                            "sock_test_client",
850                            self.client_ipv6_bi_dir_nsock_test_args)
851
852
853 class VCLIpv6CutThruTestCase(VCLTestCase):
854     """ VCL IPv6 Cut Thru Tests """
855
856     @classmethod
857     def setUpClass(cls):
858         super(VCLIpv6CutThruTestCase, cls).setUpClass()
859
860     @classmethod
861     def tearDownClass(cls):
862         super(VCLIpv6CutThruTestCase, cls).tearDownClass()
863
864     def show_commands_at_teardown(self):
865         self.logger.debug(self.vapi.cli("show session verbose 2"))
866         self.logger.debug(self.vapi.cli("show app mq"))
867
868     def setUp(self):
869         super(VCLIpv6CutThruTestCase, self).setUp()
870
871         self.cut_thru_setup()
872         self.client_uni_dir_nsock_timeout = 20
873         self.client_bi_dir_nsock_timeout = 20
874         self.client_ipv6_echo_test_args = ["-6", "-E", self.echo_phrase, "-X",
875                                            self.server_ipv6_addr,
876                                            self.server_port]
877         self.client_ipv6_uni_dir_nsock_test_args = ["-N", "1000", "-U", "-X",
878                                                     "-6",
879                                                     "-I", "2",
880                                                     self.server_ipv6_addr,
881                                                     self.server_port]
882         self.client_ipv6_bi_dir_nsock_test_args = ["-N", "1000", "-B", "-X",
883                                                    "-6",
884                                                    "-I", "2",
885                                                    self.server_ipv6_addr,
886                                                    self.server_port]
887
888     def tearDown(self):
889         super(VCLIpv6CutThruTestCase, self).tearDown()
890         self.cut_thru_tear_down()
891
892     def show_commands_at_teardown(self):
893         self.logger.debug(self.vapi.cli("show session verbose 2"))
894         self.logger.debug(self.vapi.cli("show app mq"))
895
896     def test_vcl_ipv6_cut_thru_echo(self):
897         """ run VCL IPv6 cut thru echo test """
898
899         self.cut_thru_test("vcl_test_server",
900                            self.server_ipv6_args,
901                            "vcl_test_client",
902                            self.client_ipv6_echo_test_args)
903
904     @unittest.skipUnless(running_extended_tests, "part of extended tests")
905     def test_vcl_ipv6_cut_thru_uni_dir_nsock(self):
906         """ run VCL IPv6 cut thru uni-directional (multiple sockets) test """
907
908         self.timeout = self.client_uni_dir_nsock_timeout
909         self.cut_thru_test("vcl_test_server", self.server_ipv6_args,
910                            "vcl_test_client",
911                            self.client_ipv6_uni_dir_nsock_test_args)
912
913     @unittest.skipUnless(running_extended_tests, "part of extended tests")
914     def test_vcl_ipv6_cut_thru_bi_dir_nsock(self):
915         """ run VCL IPv6 cut thru bi-directional (multiple sockets) test """
916
917         self.timeout = self.client_bi_dir_nsock_timeout
918         self.cut_thru_test("vcl_test_server", self.server_ipv6_args,
919                            "vcl_test_client",
920                            self.client_ipv6_bi_dir_nsock_test_args)
921
922
923 class VCLIpv6ThruHostStackEcho(VCLTestCase):
924     """ VCL IPv6 Thru Host Stack Echo """
925
926     @classmethod
927     def setUpClass(cls):
928         super(VCLIpv6ThruHostStackEcho, cls).setUpClass()
929
930     @classmethod
931     def tearDownClass(cls):
932         super(VCLIpv6ThruHostStackEcho, cls).tearDownClass()
933
934     def setUp(self):
935         super(VCLIpv6ThruHostStackEcho, self).setUp()
936
937         self.thru_host_stack_ipv6_setup()
938         self.client_ipv6_echo_test_args = ["-6", "-E", self.echo_phrase, "-X",
939                                            self.loop0.local_ip6,
940                                            self.server_port]
941
942     def tearDown(self):
943         self.thru_host_stack_ipv6_tear_down()
944         super(VCLIpv6ThruHostStackEcho, self).tearDown()
945
946     def test_vcl_ipv6_thru_host_stack_echo(self):
947         """ run VCL IPv6 thru host stack echo test """
948
949         self.thru_host_stack_test("vcl_test_server",
950                                   self.server_ipv6_args,
951                                   "vcl_test_client",
952                                   self.client_ipv6_echo_test_args)
953
954
955 if __name__ == '__main__':
956     unittest.main(testRunner=VppTestRunner)