vcl: wait for segments with segment handle
[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.2)
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.2)
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 VCLCutThruTestCase(VCLTestCase):
216     """ VCL Cut Thru Tests """
217
218     def setUp(self):
219         super(VCLCutThruTestCase, 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(VCLCutThruTestCase, 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     def test_vcl_cut_thru_echo(self):
280         """ run VCL cut thru echo test """
281
282         self.cut_thru_test("vcl_test_server", self.server_args,
283                            "vcl_test_client", self.client_echo_test_args)
284
285     def test_vcl_cut_thru_uni_dir_nsock(self):
286         """ run VCL cut thru uni-directional (multiple sockets) test """
287
288         self.timeout = self.client_uni_dir_nsock_timeout
289         self.cut_thru_test("vcl_test_server", self.server_args,
290                            "vcl_test_client",
291                            self.client_uni_dir_nsock_test_args)
292
293     def test_vcl_cut_thru_bi_dir_nsock(self):
294         """ run VCL cut thru bi-directional (multiple sockets) test """
295
296         self.timeout = self.client_bi_dir_nsock_timeout
297         self.cut_thru_test("vcl_test_server", self.server_args,
298                            "vcl_test_client",
299                            self.client_bi_dir_nsock_test_args)
300
301
302 class VCLThruHostStackTestCase(VCLTestCase):
303     """ VCL Thru Host Stack Tests """
304
305     def setUp(self):
306         super(VCLThruHostStackTestCase, self).setUp()
307
308         self.thru_host_stack_setup()
309         self.client_echo_test_args = ["-E", self.echo_phrase, "-X",
310                                       self.loop0.local_ip4,
311                                       self.server_port]
312
313     def tearDown(self):
314         self.thru_host_stack_tear_down()
315
316         super(VCLThruHostStackTestCase, self).tearDown()
317
318     def test_ldp_thru_host_stack_echo(self):
319         """ run LDP thru host stack echo test """
320
321         self.thru_host_stack_test("sock_test_server", self.server_args,
322                                   "sock_test_client",
323                                   self.client_echo_test_args)
324         # TBD: Remove these when VPP thru host teardown config bug is fixed.
325         self.thru_host_stack_test("vcl_test_server", self.server_args,
326                                   "vcl_test_client",
327                                   self.client_echo_test_args)
328
329     def test_vcl_thru_host_stack_echo(self):
330         """ run VCL thru host stack echo test """
331
332         # TBD: Enable this when VPP  thru host teardown config bug is fixed.
333         # self.thru_host_stack_test("vcl_test_server", self.server_args,
334         #                           "vcl_test_client",
335         #                           self.client_echo_test_args)
336
337     # TBD: Remove VCLThruHostStackGroup*TestCase classes and move
338     #      tests here when VPP  thru host teardown/setup config bug
339     #      is fixed.
340
341
342 class VCLThruHostStackNSessionBidirTestCase(VCLTestCase):
343     """ VCL Thru Host Stack NSession Bidir Tests """
344
345     def setUp(self):
346         super(VCLThruHostStackNSessionBidirTestCase, self).setUp()
347
348         self.thru_host_stack_setup()
349         if self.vppDebug:
350             self.client_bi_dir_nsock_timeout = 20
351             self.client_bi_dir_nsock_test_args = ["-N", "1000", "-B", "-X",
352                                                   "-I", "2",
353                                                   self.loop0.local_ip4,
354                                                   self.server_port]
355         else:
356             self.client_bi_dir_nsock_timeout = 20
357             self.client_bi_dir_nsock_test_args = ["-N", "1000", "-B", "-X",
358                                                   "-I", "2",
359                                                   self.loop0.local_ip4,
360                                                   self.server_port]
361
362     def tearDown(self):
363         self.thru_host_stack_tear_down()
364
365         super(VCLThruHostStackNSessionBidirTestCase, self).tearDown()
366
367     def test_vcl_thru_host_stack_bi_dir_nsock(self):
368         """ run VCL thru host stack bi-directional (multiple sockets) test """
369
370         self.timeout = self.client_bi_dir_nsock_timeout
371         self.thru_host_stack_test("vcl_test_server", self.server_args,
372                                   "vcl_test_client",
373                                   self.client_bi_dir_nsock_test_args)
374
375
376 class VCLThruHostStackGroupBTestCase(VCLTestCase):
377     """ VCL Thru Host Stack Group B Tests """
378
379     def setUp(self):
380         super(VCLThruHostStackGroupBTestCase, self).setUp()
381
382         self.thru_host_stack_setup()
383         if self.vppDebug:
384             self.client_bi_dir_nsock_timeout = 20
385             self.client_bi_dir_nsock_test_args = ["-N", "1000", "-B", "-X",
386                                                   # OUCH! Host Stack Bug?
387                                                   # "-I", "2",
388                                                   self.loop0.local_ip4,
389                                                   self.server_port]
390         else:
391             self.client_bi_dir_nsock_timeout = 20
392             self.client_bi_dir_nsock_test_args = ["-N", "1000", "-B", "-X",
393                                                   # OUCH! Host Stack Bug?
394                                                   # "-I", "2",
395                                                   self.loop0.local_ip4,
396                                                   self.server_port]
397
398     def tearDown(self):
399         self.thru_host_stack_tear_down()
400
401         super(VCLThruHostStackGroupBTestCase, self).tearDown()
402
403     def test_ldp_thru_host_stack_bi_dir_nsock(self):
404         """ run LDP thru host stack bi-directional (multiple sockets) test """
405
406         self.timeout = self.client_bi_dir_nsock_timeout
407         self.thru_host_stack_test("sock_test_server", self.server_args,
408                                   "sock_test_client",
409                                   self.client_bi_dir_nsock_test_args)
410
411
412 class VCLThruHostStackGroupCTestCase(VCLTestCase):
413     """ VCL Thru Host Stack Group C Tests """
414
415     def setUp(self):
416         super(VCLThruHostStackGroupCTestCase, self).setUp()
417
418         self.thru_host_stack_setup()
419         if self.vppDebug:
420             self.client_uni_dir_nsock_timeout = 20
421             self.numSockets = "2"
422         else:
423             self.client_uni_dir_nsock_timeout = 20
424             self.numSockets = "5"
425
426         self.client_uni_dir_nsock_test_args = ["-N", "1000", "-U", "-X",
427                                                "-I", self.numSockets,
428                                                self.loop0.local_ip4,
429                                                self.server_port]
430
431     def tearDown(self):
432         self.thru_host_stack_tear_down()
433
434         super(VCLThruHostStackGroupCTestCase, self).tearDown()
435
436     def test_ldp_thru_host_stack_uni_dir_nsock(self):
437         """ run LDP thru host stack uni-directional (multiple sockets) test """
438
439         self.timeout = self.client_uni_dir_nsock_timeout
440         self.thru_host_stack_test("sock_test_server", self.server_args,
441                                   "sock_test_client",
442                                   self.client_uni_dir_nsock_test_args)
443
444
445 class VCLThruHostStackGroupDTestCase(VCLTestCase):
446     """ VCL Thru Host Stack Group D Tests """
447
448     def setUp(self):
449         super(VCLThruHostStackGroupDTestCase, self).setUp()
450
451         self.thru_host_stack_setup()
452         if self.vppDebug:
453             self.client_uni_dir_nsock_timeout = 20
454             self.numSockets = "2"
455         else:
456             self.client_uni_dir_nsock_timeout = 20
457             self.numSockets = "5"
458
459         self.client_uni_dir_nsock_test_args = ["-N", "1000", "-U", "-X",
460                                                "-I", self.numSockets,
461                                                self.loop0.local_ip4,
462                                                self.server_port]
463
464     def tearDown(self):
465         self.thru_host_stack_tear_down()
466
467         super(VCLThruHostStackGroupDTestCase, self).tearDown()
468
469     def test_vcl_thru_host_stack_uni_dir_nsock(self):
470         """ run VCL thru host stack uni-directional (multiple sockets) test """
471
472         self.timeout = self.client_uni_dir_nsock_timeout
473         self.thru_host_stack_test("vcl_test_server", self.server_args,
474                                   "vcl_test_client",
475                                   self.client_uni_dir_nsock_test_args)
476
477
478 class VCLThruHostStackIperfTestCase(VCLTestCase):
479     """ VCL Thru Host Stack Iperf Tests """
480
481     def setUp(self):
482         super(VCLThruHostStackIperfTestCase, self).setUp()
483
484         self.thru_host_stack_setup()
485         self.client_iperf3_timeout = 20
486         self.client_iperf3_args = ["-V4d", "-t 5", "-c", self.loop0.local_ip4]
487         self.server_iperf3_args = ["-V4d", "-s"]
488
489     def tearDown(self):
490         self.thru_host_stack_tear_down()
491
492         super(VCLThruHostStackIperfTestCase, self).tearDown()
493
494     def test_ldp_thru_host_stack_iperf3(self):
495         """ run LDP thru host stack iperf3 test """
496
497         try:
498             subprocess.check_output(['iperf3', '-v'])
499         except subprocess.CalledProcessError:
500             self.logger.error("WARNING: 'iperf3' is not installed,")
501             self.logger.error(
502                 "         'test_ldp_thru_host_stack_iperf3' not run!")
503             return
504
505         self.timeout = self.client_iperf3_timeout
506         self.thru_host_stack_test("iperf3", self.server_iperf3_args,
507                                   "iperf3", self.client_iperf3_args)
508
509
510 class VCLIpv6CutThruTestCase(VCLTestCase):
511     """ VCL IPv6 Cut Thru Tests """
512
513     def setUp(self):
514         super(VCLIpv6CutThruTestCase, self).setUp()
515
516         self.cut_thru_setup()
517         self.client_iperf3_timeout = 20
518         self.client_uni_dir_nsock_timeout = 20
519         self.client_bi_dir_nsock_timeout = 20
520         self.client_ipv6_echo_test_args = ["-6", "-E", self.echo_phrase, "-X",
521                                            self.server_ipv6_addr,
522                                            self.server_port]
523         self.client_ipv6_iperf3_args = ["-V6d", "-t 5", "-c",
524                                         self.server_ipv6_addr]
525         self.server_ipv6_iperf3_args = ["-V6d", "-s"]
526         self.client_ipv6_uni_dir_nsock_test_args = ["-N", "1000", "-U", "-X",
527                                                     "-6",
528                                                     "-I", "2",
529                                                     self.server_ipv6_addr,
530                                                     self.server_port]
531         self.client_ipv6_bi_dir_nsock_test_args = ["-N", "1000", "-B", "-X",
532                                                    "-6",
533                                                    "-I", "2",
534                                                    self.server_ipv6_addr,
535                                                    self.server_port]
536
537     def tearDown(self):
538         self.cut_thru_tear_down()
539
540         super(VCLIpv6CutThruTestCase, self).tearDown()
541
542     def test_ldp_ipv6_cut_thru_echo(self):
543         """ run LDP IPv6 cut thru echo test """
544
545         self.cut_thru_test("sock_test_server",
546                            self.server_ipv6_args,
547                            "sock_test_client",
548                            self.client_ipv6_echo_test_args)
549
550     def test_ldp_ipv6_cut_thru_iperf3(self):
551         """ run LDP IPv6 cut thru iperf3 test """
552
553         try:
554             subprocess.check_output(['iperf3', '-v'])
555         except:
556             self.logger.error("WARNING: 'iperf3' is not installed,")
557             self.logger.error(
558                 "         'test_ldp_ipv6_cut_thru_iperf3' not run!")
559             return
560
561         self.timeout = self.client_iperf3_timeout
562         self.cut_thru_test("iperf3", self.server_ipv6_iperf3_args,
563                            "iperf3", self.client_ipv6_iperf3_args)
564
565     def test_ldp_ipv6_cut_thru_uni_dir_nsock(self):
566         """ run LDP IPv6 cut thru uni-directional (multiple sockets) test """
567
568         self.timeout = self.client_uni_dir_nsock_timeout
569         self.cut_thru_test("sock_test_server", self.server_ipv6_args,
570                            "sock_test_client",
571                            self.client_ipv6_uni_dir_nsock_test_args)
572
573     def test_ldp_ipv6_cut_thru_bi_dir_nsock(self):
574         """ run LDP IPv6 cut thru bi-directional (multiple sockets) test """
575
576         self.timeout = self.client_bi_dir_nsock_timeout
577         self.cut_thru_test("sock_test_server", self.server_ipv6_args,
578                            "sock_test_client",
579                            self.client_ipv6_bi_dir_nsock_test_args)
580
581     def test_vcl_ipv6_cut_thru_echo(self):
582         """ run VCL IPv6 cut thru echo test """
583
584         self.cut_thru_test("vcl_test_server",
585                            self.server_ipv6_args,
586                            "vcl_test_client",
587                            self.client_ipv6_echo_test_args)
588
589     def test_vcl_ipv6_cut_thru_uni_dir_nsock(self):
590         """ run VCL IPv6 cut thru uni-directional (multiple sockets) test """
591
592         self.timeout = self.client_uni_dir_nsock_timeout
593         self.cut_thru_test("vcl_test_server", self.server_ipv6_args,
594                            "vcl_test_client",
595                            self.client_ipv6_uni_dir_nsock_test_args)
596
597     def test_vcl_ipv6_cut_thru_bi_dir_nsock(self):
598         """ run VCL IPv6 cut thru bi-directional (multiple sockets) test """
599
600         self.timeout = self.client_bi_dir_nsock_timeout
601         self.cut_thru_test("vcl_test_server", self.server_ipv6_args,
602                            "vcl_test_client",
603                            self.client_ipv6_bi_dir_nsock_test_args)
604
605
606 class VCLIpv6ThruHostStackTestCase(VCLTestCase):
607     """ VCL IPv6 Thru Host Stack Tests """
608
609     def setUp(self):
610         super(VCLIpv6ThruHostStackTestCase, self).setUp()
611
612         self.thru_host_stack_ipv6_setup()
613         self.client_ipv6_echo_test_args = ["-6", "-E", self.echo_phrase, "-X",
614                                            self.loop0.local_ip6,
615                                            self.server_port]
616
617     def tearDown(self):
618         self.thru_host_stack_ipv6_tear_down()
619
620         super(VCLIpv6ThruHostStackTestCase, self).tearDown()
621
622     def test_ldp_ipv6_thru_host_stack_echo(self):
623         """ run LDP IPv6 thru host stack echo test """
624
625         self.thru_host_stack_test("sock_test_server",
626                                   self.server_ipv6_args,
627                                   "sock_test_client",
628                                   self.client_ipv6_echo_test_args)
629         # TBD: Remove these when VPP thru host teardown config bug is fixed.
630         self.thru_host_stack_test("vcl_test_server",
631                                   self.server_ipv6_args,
632                                   "vcl_test_client",
633                                   self.client_ipv6_echo_test_args)
634
635     def test_vcl_ipv6_thru_host_stack_echo(self):
636         """ run VCL IPv6 thru host stack echo test """
637
638 #        self.thru_host_stack_test("vcl_test_server",
639 #                                  self.server_ipv6_args,
640 #                                  "vcl_test_client",
641 #                                  self.client_ipv6_echo_test_args)
642
643     # TBD: Remove VCLIpv6ThruHostStackGroup*TestCase classes and move
644     #      tests here when VPP  thru host teardown/setup config bug
645     #      is fixed.
646
647
648 class VCLIpv6ThruHostStackGroupATestCase(VCLTestCase):
649     """ VCL IPv6 Thru Host Stack Group A Tests """
650
651     def setUp(self):
652         super(VCLIpv6ThruHostStackGroupATestCase, self).setUp()
653
654         self.thru_host_stack_ipv6_setup()
655         if self.vppDebug:
656             self.client_bi_dir_nsock_timeout = 20
657             self.client_ipv6_bi_dir_nsock_test_args = ["-N", "1000",
658                                                        "-B", "-X", "-6",
659                                                        "-I", "2",
660                                                        self.loop0.local_ip6,
661                                                        self.server_port]
662         else:
663             self.client_bi_dir_nsock_timeout = 20
664             self.client_ipv6_bi_dir_nsock_test_args = ["-N", "1000",
665                                                        "-B", "-X", "-6",
666                                                        "-I", "2",
667                                                        self.loop0.local_ip6,
668                                                        self.server_port]
669
670     def tearDown(self):
671         self.thru_host_stack_ipv6_tear_down()
672
673         super(VCLIpv6ThruHostStackGroupATestCase, self).tearDown()
674
675     def test_vcl_thru_host_stack_bi_dir_nsock(self):
676         """ run VCL thru host stack bi-directional (multiple sockets) test """
677
678         self.timeout = self.client_bi_dir_nsock_timeout
679         self.thru_host_stack_test("vcl_test_server", self.server_ipv6_args,
680                                   "vcl_test_client",
681                                   self.client_ipv6_bi_dir_nsock_test_args)
682
683
684 class VCLIpv6ThruHostStackGroupBTestCase(VCLTestCase):
685     """ VCL IPv6 Thru Host Stack Group B Tests """
686
687     def setUp(self):
688         super(VCLIpv6ThruHostStackGroupBTestCase, self).setUp()
689
690         self.thru_host_stack_ipv6_setup()
691         if self.vppDebug:
692             self.client_bi_dir_nsock_timeout = 20
693             self.client_ipv6_bi_dir_nsock_test_args = ["-N", "1000",
694                                                        "-B", "-X", "-6",
695                                                        # OUCH! Host Stack Bug?
696                                                        # "-I", "2",
697                                                        self.loop0.local_ip6,
698                                                        self.server_port]
699         else:
700             self.client_bi_dir_nsock_timeout = 20
701             self.client_ipv6_bi_dir_nsock_test_args = ["-N", "1000",
702                                                        "-B", "-X", "-6",
703                                                        # OUCH! Host Stack Bug?
704                                                        # "-I", "2",
705                                                        self.loop0.local_ip6,
706                                                        self.server_port]
707
708     def tearDown(self):
709         self.thru_host_stack_ipv6_tear_down()
710
711         super(VCLIpv6ThruHostStackGroupBTestCase, self).tearDown()
712
713     def test_ldp_thru_host_stack_bi_dir_nsock(self):
714         """ run LDP thru host stack bi-directional (multiple sockets) test """
715
716         self.timeout = self.client_bi_dir_nsock_timeout
717         self.thru_host_stack_test("sock_test_server",
718                                   self.server_ipv6_args,
719                                   "sock_test_client",
720                                   self.client_ipv6_bi_dir_nsock_test_args)
721
722
723 class VCLIpv6ThruHostStackGroupCTestCase(VCLTestCase):
724     """ VCL IPv6 Thru Host Stack Group C Tests """
725
726     def setUp(self):
727         super(VCLIpv6ThruHostStackGroupCTestCase, self).setUp()
728
729         self.thru_host_stack_ipv6_setup()
730         if self.vppDebug:
731             self.client_uni_dir_nsock_timeout = 20
732             self.numSockets = "2"
733         else:
734             self.client_uni_dir_nsock_timeout = 20
735             self.numSockets = "5"
736
737         self.client_ipv6_uni_dir_nsock_test_args = ["-N", "1000", "-U", "-X",
738                                                     "-6",
739                                                     "-I", self.numSockets,
740                                                     self.loop0.local_ip6,
741                                                     self.server_port]
742
743     def tearDown(self):
744         self.thru_host_stack_ipv6_tear_down()
745
746         super(VCLIpv6ThruHostStackGroupCTestCase, self).tearDown()
747
748     def test_ldp_thru_host_stack_uni_dir_nsock(self):
749         """ run LDP thru host stack uni-directional (multiple sockets) test """
750
751         self.timeout = self.client_uni_dir_nsock_timeout
752         self.thru_host_stack_test("sock_test_server",
753                                   self.server_ipv6_args,
754                                   "sock_test_client",
755                                   self.client_ipv6_uni_dir_nsock_test_args)
756
757
758 class VCLIpv6ThruHostStackGroupDTestCase(VCLTestCase):
759     """ VCL IPv6 Thru Host Stack Group D Tests """
760
761     def setUp(self):
762         super(VCLIpv6ThruHostStackGroupDTestCase, self).setUp()
763
764         self.thru_host_stack_ipv6_setup()
765         if self.vppDebug:
766             self.client_uni_dir_nsock_timeout = 20
767             self.numSockets = "2"
768         else:
769             self.client_uni_dir_nsock_timeout = 20
770             self.numSockets = "5"
771
772         self.client_ipv6_uni_dir_nsock_test_args = ["-N", "1000", "-U", "-X",
773                                                     "-6",
774                                                     "-I", self.numSockets,
775                                                     self.loop0.local_ip6,
776                                                     self.server_port]
777
778     def tearDown(self):
779         self.thru_host_stack_ipv6_tear_down()
780
781         super(VCLIpv6ThruHostStackGroupDTestCase, self).tearDown()
782
783     def test_vcl_thru_host_stack_uni_dir_nsock(self):
784         """ run VCL thru host stack uni-directional (multiple sockets) test """
785
786         self.timeout = self.client_uni_dir_nsock_timeout
787         self.thru_host_stack_test("vcl_test_server", self.server_ipv6_args,
788                                   "vcl_test_client",
789                                   self.client_ipv6_uni_dir_nsock_test_args)
790
791
792 class VCLIpv6ThruHostStackIperfTestCase(VCLTestCase):
793     """ VCL IPv6 Thru Host Stack Iperf Tests """
794
795     def setUp(self):
796         super(VCLIpv6ThruHostStackIperfTestCase, self).setUp()
797
798         self.thru_host_stack_ipv6_setup()
799         self.client_iperf3_timeout = 20
800         self.client_ipv6_iperf3_args = ["-V6d", "-t 5", "-c",
801                                         self.loop0.local_ip6]
802         self.server_ipv6_iperf3_args = ["-V6d", "-s"]
803
804     def tearDown(self):
805         self.thru_host_stack_ipv6_tear_down()
806
807         super(VCLIpv6ThruHostStackIperfTestCase, self).tearDown()
808
809     def test_ldp_thru_host_stack_iperf3(self):
810         """ run LDP thru host stack iperf3 test """
811
812         try:
813             subprocess.check_output(['iperf3', '-v'])
814         except subprocess.CalledProcessError:
815             self.logger.error("WARNING: 'iperf3' is not installed,")
816             self.logger.error(
817                 "         'test_ldp_thru_host_stack_iperf3' not run!")
818             return
819
820         self.timeout = self.client_iperf3_timeout
821         self.thru_host_stack_test("iperf3", self.server_ipv6_iperf3_args,
822                                   "iperf3", self.client_ipv6_iperf3_args)
823
824
825 if __name__ == '__main__':
826     unittest.main(testRunner=VppTestRunner)