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