8950470e8fc0dde598a25a24a23ff3956c1d3087
[vpp.git] / src / vcl / 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
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                  *args, **kwargs):
31
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)
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)
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)
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)
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 = ["-4d", "-t 2", "-c", self.server_addr]
266         self.server_iperf3_args = ["-4d", "-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     def test_ldp_cut_thru_iperf3(self):
295         """ run LDP cut thru iperf3 test """
296
297         self.timeout = self.client_iperf3_timeout
298         self.cut_thru_test(iperf3, self.server_iperf3_args,
299                            iperf3, self.client_iperf3_args)
300
301     @unittest.skipUnless(running_extended_tests, "part of extended tests")
302     def test_ldp_cut_thru_uni_dir_nsock(self):
303         """ run LDP cut thru uni-directional (multiple sockets) test """
304
305         self.timeout = self.client_uni_dir_nsock_timeout
306         self.cut_thru_test("sock_test_server", self.server_args,
307                            "sock_test_client",
308                            self.client_uni_dir_nsock_test_args)
309
310     @unittest.skipUnless(running_extended_tests, "part of extended tests")
311     @unittest.skip("sock test apps need to be improved")
312     def test_ldp_cut_thru_bi_dir_nsock(self):
313         """ run LDP cut thru bi-directional (multiple sockets) test """
314
315         self.timeout = self.client_bi_dir_nsock_timeout
316         self.cut_thru_test("sock_test_server", self.server_args,
317                            "sock_test_client",
318                            self.client_bi_dir_nsock_test_args)
319
320
321 class VCLCutThruTestCase(VCLTestCase):
322     """ VCL Cut Thru Tests """
323
324     @classmethod
325     def setUpClass(cls):
326         super(VCLCutThruTestCase, cls).setUpClass()
327
328     @classmethod
329     def tearDownClass(cls):
330         super(VCLCutThruTestCase, cls).tearDownClass()
331
332     def setUp(self):
333         super(VCLCutThruTestCase, self).setUp()
334
335         self.cut_thru_setup()
336         self.client_echo_test_args = ["-E", self.echo_phrase, "-X",
337                                       self.server_addr, self.server_port]
338
339         self.client_uni_dir_nsock_timeout = 20
340         self.client_uni_dir_nsock_test_args = ["-N", "1000", "-U", "-X",
341                                                "-I", "2",
342                                                self.server_addr,
343                                                self.server_port]
344         self.client_bi_dir_nsock_timeout = 20
345         self.client_bi_dir_nsock_test_args = ["-N", "1000", "-B", "-X",
346                                               "-I", "2",
347                                               self.server_addr,
348                                               self.server_port]
349
350     def tearDown(self):
351         super(VCLCutThruTestCase, self).tearDown()
352
353     def show_commands_at_teardown(self):
354         self.logger.debug(self.vapi.cli("show session verbose 2"))
355         self.logger.debug(self.vapi.cli("show app mq"))
356
357     def test_vcl_cut_thru_echo(self):
358         """ run VCL cut thru echo test """
359
360         self.cut_thru_test("vcl_test_server", self.server_args,
361                            "vcl_test_client", self.client_echo_test_args)
362
363     def test_vcl_cut_thru_uni_dir_nsock(self):
364         """ run VCL cut thru uni-directional (multiple sockets) test """
365
366         self.timeout = self.client_uni_dir_nsock_timeout
367         self.cut_thru_test("vcl_test_server", self.server_args,
368                            "vcl_test_client",
369                            self.client_uni_dir_nsock_test_args)
370
371     def test_vcl_cut_thru_bi_dir_nsock(self):
372         """ run VCL cut thru bi-directional (multiple sockets) test """
373
374         self.timeout = self.client_bi_dir_nsock_timeout
375         self.cut_thru_test("vcl_test_server", self.server_args,
376                            "vcl_test_client",
377                            self.client_bi_dir_nsock_test_args)
378
379
380 class VCLThruHostStackEcho(VCLTestCase):
381     """ VCL Thru Host Stack Echo """
382
383     @classmethod
384     def setUpClass(cls):
385         super(VCLThruHostStackEcho, cls).setUpClass()
386
387     @classmethod
388     def tearDownClass(cls):
389         super(VCLThruHostStackEcho, cls).tearDownClass()
390
391     def setUp(self):
392         super(VCLThruHostStackEcho, self).setUp()
393
394         self.thru_host_stack_setup()
395         self.client_bi_dir_nsock_timeout = 20
396         self.client_bi_dir_nsock_test_args = ["-N", "1000", "-B", "-X",
397                                               "-I", "2",
398                                               self.loop0.local_ip4,
399                                               self.server_port]
400         self.client_echo_test_args = ["-E", self.echo_phrase, "-X",
401                                       self.loop0.local_ip4,
402                                       self.server_port]
403
404     def tearDown(self):
405         self.thru_host_stack_tear_down()
406         super(VCLThruHostStackEcho, self).tearDown()
407
408     def show_commands_at_teardown(self):
409         self.logger.debug(self.vapi.cli("show app server"))
410         self.logger.debug(self.vapi.cli("show session verbose"))
411         self.logger.debug(self.vapi.cli("show app mq"))
412
413
414 class VCLThruHostStackTLS(VCLTestCase):
415     """ VCL Thru Host Stack TLS """
416
417     @classmethod
418     def setUpClass(cls):
419         super(VCLThruHostStackTLS, cls).setUpClass()
420
421     @classmethod
422     def tearDownClass(cls):
423         super(VCLThruHostStackTLS, cls).tearDownClass()
424
425     def setUp(self):
426         super(VCLThruHostStackTLS, self).setUp()
427
428         self.thru_host_stack_setup()
429         self.client_uni_dir_tls_timeout = 20
430         self.server_tls_args = ["-L", self.server_port]
431         self.client_uni_dir_tls_test_args = ["-N", "1000", "-U", "-X", "-L",
432                                              self.loop0.local_ip4,
433                                              self.server_port]
434
435     def test_vcl_thru_host_stack_tls_uni_dir(self):
436         """ run VCL thru host stack uni-directional TLS test """
437
438         self.timeout = self.client_uni_dir_tls_timeout
439         self.thru_host_stack_test("vcl_test_server", self.server_tls_args,
440                                   "vcl_test_client",
441                                   self.client_uni_dir_tls_test_args)
442
443     def tearDown(self):
444         self.thru_host_stack_tear_down()
445         super(VCLThruHostStackTLS, self).tearDown()
446
447     def show_commands_at_teardown(self):
448         self.logger.debug(self.vapi.cli("show app server"))
449         self.logger.debug(self.vapi.cli("show session verbose 2"))
450         self.logger.debug(self.vapi.cli("show app mq"))
451
452
453 class VCLThruHostStackBidirNsock(VCLTestCase):
454     """ VCL Thru Host Stack Bidir Nsock """
455
456     @classmethod
457     def setUpClass(cls):
458         super(VCLThruHostStackBidirNsock, cls).setUpClass()
459
460     @classmethod
461     def tearDownClass(cls):
462         super(VCLThruHostStackBidirNsock, cls).tearDownClass()
463
464     def setUp(self):
465         super(VCLThruHostStackBidirNsock, self).setUp()
466
467         self.thru_host_stack_setup()
468         self.client_bi_dir_nsock_timeout = 20
469         self.client_bi_dir_nsock_test_args = ["-N", "1000", "-B", "-X",
470                                               "-I", "2",
471                                               self.loop0.local_ip4,
472                                               self.server_port]
473         self.client_echo_test_args = ["-E", self.echo_phrase, "-X",
474                                       self.loop0.local_ip4,
475                                       self.server_port]
476
477     def tearDown(self):
478         self.thru_host_stack_tear_down()
479         super(VCLThruHostStackBidirNsock, self).tearDown()
480
481     def show_commands_at_teardown(self):
482         self.logger.debug(self.vapi.cli("show session verbose 2"))
483         self.logger.debug(self.vapi.cli("show app mq"))
484
485     def test_vcl_thru_host_stack_bi_dir_nsock(self):
486         """ run VCL thru host stack bi-directional (multiple sockets) test """
487
488         self.timeout = self.client_bi_dir_nsock_timeout
489         self.thru_host_stack_test("vcl_test_server", self.server_args,
490                                   "vcl_test_client",
491                                   self.client_bi_dir_nsock_test_args)
492
493
494 class LDPThruHostStackBidirNsock(VCLTestCase):
495     """ LDP Thru Host Stack Bidir Nsock """
496
497     @classmethod
498     def setUpClass(cls):
499         super(LDPThruHostStackBidirNsock, cls).setUpClass()
500
501     @classmethod
502     def tearDownClass(cls):
503         super(LDPThruHostStackBidirNsock, cls).tearDownClass()
504
505     def setUp(self):
506         super(LDPThruHostStackBidirNsock, self).setUp()
507
508         self.thru_host_stack_setup()
509         self.client_bi_dir_nsock_timeout = 20
510         self.client_bi_dir_nsock_test_args = ["-N", "1000", "-B", "-X",
511                                               # OUCH! Host Stack Bug?
512                                               # Only fails when running
513                                               # 'make test TEST_JOBS=auto'
514                                               # or TEST_JOBS > 1
515                                               # "-I", "2",
516                                               self.loop0.local_ip4,
517                                               self.server_port]
518
519     def tearDown(self):
520         self.thru_host_stack_tear_down()
521         super(LDPThruHostStackBidirNsock, self).tearDown()
522
523     def show_commands_at_teardown(self):
524         self.logger.debug(self.vapi.cli("show session verbose 2"))
525         self.logger.debug(self.vapi.cli("show app mq"))
526
527     def test_ldp_thru_host_stack_bi_dir_nsock(self):
528         """ run LDP thru host stack bi-directional (multiple sockets) test """
529
530         self.timeout = self.client_bi_dir_nsock_timeout
531         self.thru_host_stack_test("sock_test_server", self.server_args,
532                                   "sock_test_client",
533                                   self.client_bi_dir_nsock_test_args)
534
535
536 class LDPThruHostStackNsock(VCLTestCase):
537     """ LDP Thru Host Stack Nsock """
538
539     @classmethod
540     def setUpClass(cls):
541         super(LDPThruHostStackNsock, cls).setUpClass()
542
543     @classmethod
544     def tearDownClass(cls):
545         super(LDPThruHostStackNsock, cls).tearDownClass()
546
547     def setUp(self):
548         super(LDPThruHostStackNsock, self).setUp()
549
550         self.thru_host_stack_setup()
551         if self.vppDebug:
552             self.client_uni_dir_nsock_timeout = 20
553             self.numSockets = "2"
554         else:
555             self.client_uni_dir_nsock_timeout = 20
556             self.numSockets = "5"
557
558         self.client_uni_dir_nsock_test_args = ["-N", "1000", "-U", "-X",
559                                                "-I", self.numSockets,
560                                                self.loop0.local_ip4,
561                                                self.server_port]
562
563     def tearDown(self):
564         self.thru_host_stack_tear_down()
565         super(LDPThruHostStackNsock, self).tearDown()
566
567     def test_ldp_thru_host_stack_uni_dir_nsock(self):
568         """ run LDP thru host stack uni-directional (multiple sockets) test """
569
570         self.timeout = self.client_uni_dir_nsock_timeout
571         self.thru_host_stack_test("sock_test_server", self.server_args,
572                                   "sock_test_client",
573                                   self.client_uni_dir_nsock_test_args)
574
575
576 class VCLThruHostStackNsock(VCLTestCase):
577     """ VCL Thru Host Stack Nsock """
578
579     @classmethod
580     def setUpClass(cls):
581         super(VCLThruHostStackNsock, cls).setUpClass()
582
583     @classmethod
584     def tearDownClass(cls):
585         super(VCLThruHostStackNsock, cls).tearDownClass()
586
587     def setUp(self):
588         super(VCLThruHostStackNsock, self).setUp()
589
590         self.thru_host_stack_setup()
591         if self.vppDebug:
592             self.client_uni_dir_nsock_timeout = 20
593             self.numSockets = "2"
594         else:
595             self.client_uni_dir_nsock_timeout = 20
596             self.numSockets = "5"
597
598         self.client_uni_dir_nsock_test_args = ["-N", "1000", "-U", "-X",
599                                                "-I", self.numSockets,
600                                                self.loop0.local_ip4,
601                                                self.server_port]
602
603     def tearDown(self):
604         self.thru_host_stack_tear_down()
605         super(VCLThruHostStackNsock, self).tearDown()
606
607     def test_vcl_thru_host_stack_uni_dir_nsock(self):
608         """ run VCL thru host stack uni-directional (multiple sockets) test """
609
610         self.timeout = self.client_uni_dir_nsock_timeout
611         self.thru_host_stack_test("vcl_test_server", self.server_args,
612                                   "vcl_test_client",
613                                   self.client_uni_dir_nsock_test_args)
614
615
616 class LDPThruHostStackIperf(VCLTestCase):
617     """ LDP Thru Host Stack Iperf  """
618
619     @classmethod
620     def setUpClass(cls):
621         super(LDPThruHostStackIperf, cls).setUpClass()
622
623     @classmethod
624     def tearDownClass(cls):
625         super(LDPThruHostStackIperf, cls).tearDownClass()
626
627     def setUp(self):
628         super(LDPThruHostStackIperf, self).setUp()
629
630         self.thru_host_stack_setup()
631         self.client_iperf3_timeout = 20
632         self.client_iperf3_args = ["-4d", "-t 2", "-c", self.loop0.local_ip4]
633         self.server_iperf3_args = ["-4d", "-s"]
634
635     def tearDown(self):
636         self.thru_host_stack_tear_down()
637         super(LDPThruHostStackIperf, self).tearDown()
638
639     def show_commands_at_teardown(self):
640         self.logger.debug(self.vapi.cli("show session verbose 2"))
641         self.logger.debug(self.vapi.cli("show app mq"))
642
643     @unittest.skipUnless(_have_iperf3, "'%s' not found, Skipping.")
644     def test_ldp_thru_host_stack_iperf3(self):
645         """ run LDP thru host stack iperf3 test """
646
647         self.timeout = self.client_iperf3_timeout
648         self.thru_host_stack_test(iperf3, self.server_iperf3_args,
649                                   iperf3, self.client_iperf3_args)
650
651
652 class LDPThruHostStackIperfUdp(VCLTestCase):
653     """ LDP Thru Host Stack Iperf UDP """
654
655     @classmethod
656     def setUpClass(cls):
657         super(LDPThruHostStackIperfUdp, cls).setUpClass()
658
659     @classmethod
660     def tearDownClass(cls):
661         super(LDPThruHostStackIperfUdp, cls).tearDownClass()
662
663     def setUp(self):
664         super(LDPThruHostStackIperfUdp, self).setUp()
665
666         self.thru_host_stack_setup()
667         self.client_iperf3_timeout = 20
668         self.client_iperf3_args = ["-4d", "-t 2", "-u", "-l 1400",
669                                    "-c", self.loop0.local_ip4]
670         self.server_iperf3_args = ["-4d", "-s"]
671
672     def tearDown(self):
673         self.thru_host_stack_tear_down()
674         super(LDPThruHostStackIperfUdp, self).tearDown()
675
676     def show_commands_at_teardown(self):
677         self.logger.debug(self.vapi.cli("show session verbose 2"))
678         self.logger.debug(self.vapi.cli("show app mq"))
679
680     @unittest.skipUnless(_have_iperf3, "'%s' not found, Skipping.")
681     def test_ldp_thru_host_stack_iperf3_udp(self):
682         """ run LDP thru host stack iperf3 UDP test """
683
684         self.timeout = self.client_iperf3_timeout
685         self.thru_host_stack_test(iperf3, self.server_iperf3_args,
686                                   iperf3, self.client_iperf3_args)
687
688
689 class LDPIpv6CutThruTestCase(VCLTestCase):
690     """ LDP IPv6 Cut Thru Tests """
691
692     @classmethod
693     def setUpClass(cls):
694         super(LDPIpv6CutThruTestCase, cls).setUpClass()
695
696     @classmethod
697     def tearDownClass(cls):
698         super(LDPIpv6CutThruTestCase, cls).tearDownClass()
699
700     def show_commands_at_teardown(self):
701         self.logger.debug(self.vapi.cli("show session verbose 2"))
702         self.logger.debug(self.vapi.cli("show app mq"))
703
704     def setUp(self):
705         super(LDPIpv6CutThruTestCase, self).setUp()
706
707         self.cut_thru_setup()
708         self.client_iperf3_timeout = 20
709         self.client_uni_dir_nsock_timeout = 20
710         self.client_bi_dir_nsock_timeout = 20
711         self.client_ipv6_echo_test_args = ["-6", "-E", self.echo_phrase, "-X",
712                                            self.server_ipv6_addr,
713                                            self.server_port]
714         self.client_ipv6_iperf3_args = ["-6d", "-t 2", "-c",
715                                         self.server_ipv6_addr]
716         self.server_ipv6_iperf3_args = ["-6d", "-s"]
717         self.client_ipv6_uni_dir_nsock_test_args = ["-N", "1000", "-U", "-X",
718                                                     "-6",
719                                                     "-I", "2",
720                                                     self.server_ipv6_addr,
721                                                     self.server_port]
722         self.client_ipv6_bi_dir_nsock_test_args = ["-N", "1000", "-B", "-X",
723                                                    "-6",
724                                                    "-I", "2",
725                                                    self.server_ipv6_addr,
726                                                    self.server_port]
727
728     def tearDown(self):
729         super(LDPIpv6CutThruTestCase, self).tearDown()
730         self.cut_thru_tear_down()
731
732     def test_ldp_ipv6_cut_thru_echo(self):
733         """ run LDP IPv6 cut thru echo test """
734
735         self.cut_thru_test("sock_test_server",
736                            self.server_ipv6_args,
737                            "sock_test_client",
738                            self.client_ipv6_echo_test_args)
739
740     @unittest.skipUnless(_have_iperf3, "'%s' not found, Skipping.")
741     @unittest.skipUnless(running_extended_tests, "part of extended tests")
742     def test_ldp_ipv6_cut_thru_iperf3(self):
743         """ run LDP IPv6 cut thru iperf3 test """
744
745         self.timeout = self.client_iperf3_timeout
746         self.cut_thru_test(iperf3, self.server_ipv6_iperf3_args,
747                            iperf3, self.client_ipv6_iperf3_args)
748
749     @unittest.skipUnless(running_extended_tests, "part of extended tests")
750     def test_ldp_ipv6_cut_thru_uni_dir_nsock(self):
751         """ run LDP IPv6 cut thru uni-directional (multiple sockets) test """
752
753         self.timeout = self.client_uni_dir_nsock_timeout
754         self.cut_thru_test("sock_test_server", self.server_ipv6_args,
755                            "sock_test_client",
756                            self.client_ipv6_uni_dir_nsock_test_args)
757
758     @unittest.skipUnless(running_extended_tests, "part of extended tests")
759     @unittest.skip("sock test apps need to be improved")
760     def test_ldp_ipv6_cut_thru_bi_dir_nsock(self):
761         """ run LDP IPv6 cut thru bi-directional (multiple sockets) test """
762
763         self.timeout = self.client_bi_dir_nsock_timeout
764         self.cut_thru_test("sock_test_server", self.server_ipv6_args,
765                            "sock_test_client",
766                            self.client_ipv6_bi_dir_nsock_test_args)
767
768
769 class VCLIpv6CutThruTestCase(VCLTestCase):
770     """ VCL IPv6 Cut Thru Tests """
771
772     @classmethod
773     def setUpClass(cls):
774         super(VCLIpv6CutThruTestCase, cls).setUpClass()
775
776     @classmethod
777     def tearDownClass(cls):
778         super(VCLIpv6CutThruTestCase, cls).tearDownClass()
779
780     def show_commands_at_teardown(self):
781         self.logger.debug(self.vapi.cli("show session verbose 2"))
782         self.logger.debug(self.vapi.cli("show app mq"))
783
784     def setUp(self):
785         super(VCLIpv6CutThruTestCase, self).setUp()
786
787         self.cut_thru_setup()
788         self.client_uni_dir_nsock_timeout = 20
789         self.client_bi_dir_nsock_timeout = 20
790         self.client_ipv6_echo_test_args = ["-6", "-E", self.echo_phrase, "-X",
791                                            self.server_ipv6_addr,
792                                            self.server_port]
793         self.client_ipv6_uni_dir_nsock_test_args = ["-N", "1000", "-U", "-X",
794                                                     "-6",
795                                                     "-I", "2",
796                                                     self.server_ipv6_addr,
797                                                     self.server_port]
798         self.client_ipv6_bi_dir_nsock_test_args = ["-N", "1000", "-B", "-X",
799                                                    "-6",
800                                                    "-I", "2",
801                                                    self.server_ipv6_addr,
802                                                    self.server_port]
803
804     def tearDown(self):
805         super(VCLIpv6CutThruTestCase, self).tearDown()
806         self.cut_thru_tear_down()
807
808     def show_commands_at_teardown(self):
809         self.logger.debug(self.vapi.cli("show session verbose 2"))
810         self.logger.debug(self.vapi.cli("show app mq"))
811
812     def test_vcl_ipv6_cut_thru_echo(self):
813         """ run VCL IPv6 cut thru echo test """
814
815         self.cut_thru_test("vcl_test_server",
816                            self.server_ipv6_args,
817                            "vcl_test_client",
818                            self.client_ipv6_echo_test_args)
819
820     @unittest.skipUnless(running_extended_tests, "part of extended tests")
821     def test_vcl_ipv6_cut_thru_uni_dir_nsock(self):
822         """ run VCL IPv6 cut thru uni-directional (multiple sockets) test """
823
824         self.timeout = self.client_uni_dir_nsock_timeout
825         self.cut_thru_test("vcl_test_server", self.server_ipv6_args,
826                            "vcl_test_client",
827                            self.client_ipv6_uni_dir_nsock_test_args)
828
829     @unittest.skipUnless(running_extended_tests, "part of extended tests")
830     def test_vcl_ipv6_cut_thru_bi_dir_nsock(self):
831         """ run VCL IPv6 cut thru bi-directional (multiple sockets) test """
832
833         self.timeout = self.client_bi_dir_nsock_timeout
834         self.cut_thru_test("vcl_test_server", self.server_ipv6_args,
835                            "vcl_test_client",
836                            self.client_ipv6_bi_dir_nsock_test_args)
837
838
839 class VCLIpv6ThruHostStackEcho(VCLTestCase):
840     """ VCL IPv6 Thru Host Stack Echo """
841
842     @classmethod
843     def setUpClass(cls):
844         super(VCLIpv6ThruHostStackEcho, cls).setUpClass()
845
846     @classmethod
847     def tearDownClass(cls):
848         super(VCLIpv6ThruHostStackEcho, cls).tearDownClass()
849
850     def setUp(self):
851         super(VCLIpv6ThruHostStackEcho, self).setUp()
852
853         self.thru_host_stack_ipv6_setup()
854         self.client_ipv6_echo_test_args = ["-6", "-E", self.echo_phrase, "-X",
855                                            self.loop0.local_ip6,
856                                            self.server_port]
857
858     def tearDown(self):
859         self.thru_host_stack_ipv6_tear_down()
860         super(VCLIpv6ThruHostStackEcho, self).tearDown()
861
862     def test_vcl_ipv6_thru_host_stack_echo(self):
863         """ run VCL IPv6 thru host stack echo test """
864
865         self.thru_host_stack_test("vcl_test_server",
866                                   self.server_ipv6_args,
867                                   "vcl_test_client",
868                                   self.client_ipv6_echo_test_args)
869
870
871 if __name__ == '__main__':
872     unittest.main(testRunner=VppTestRunner)