8 from framework import VppTestCase, VppTestRunner, running_extended_tests, \
10 from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath
13 class QUICAppWorker(Worker):
14 """ QUIC Test Application Worker """
17 def __init__(self, build_dir, appname, executable_args, logger, role,
18 testcase, env=None, *args, **kwargs):
21 app = "%s/vpp/bin/%s" % (build_dir, appname)
22 self.args = [app] + executable_args
24 self.wait_for_gdb = 'wait-for-gdb'
25 self.testcase = testcase
26 super(QUICAppWorker, self).__init__(self.args, logger, env,
30 super(QUICAppWorker, self).run()
32 def teardown(self, logger, timeout):
33 if self.process is None:
36 logger.debug("Killing worker process (pid %d)" % self.process.pid)
37 os.killpg(os.getpgid(self.process.pid), signal.SIGKILL)
40 logger.debug("Couldn't kill worker process")
45 class QUICTestCase(VppTestCase):
46 """ QUIC Test Case """
54 cls.extra_vpp_plugin_config.append("plugin quic_plugin.so { enable }")
55 super(QUICTestCase, cls).setUpClass()
58 super(QUICTestCase, self).setUp()
60 self.build_dir = os.getenv(var, None)
61 if self.build_dir is None:
62 raise Exception("Environment variable `%s' not set" % var)
63 self.vppDebug = 'vpp_debug' in self.build_dir
64 self.vapi.session_enable_disable(is_enabled=1)
66 self.create_loopback_interfaces(2)
67 self.uri = "quic://%s/1234" % self.loop0.local_ip4
69 for i in self.lo_interfaces:
73 tbl = VppIpTable(self, table_id)
76 i.set_table_ip4(table_id)
80 # Configure namespaces
81 self.vapi.app_namespace_add_del(namespace_id=b"server",
82 sw_if_index=self.loop0.sw_if_index)
83 self.vapi.app_namespace_add_del(namespace_id=b"client",
84 sw_if_index=self.loop1.sw_if_index)
86 # Add inter-table routes
87 self.ip_t01 = VppIpRoute(self, self.loop1.local_ip4, 32,
88 [VppRoutePath("0.0.0.0",
90 nh_table_id=2)], table_id=1)
91 self.ip_t10 = VppIpRoute(self, self.loop0.local_ip4, 32,
92 [VppRoutePath("0.0.0.0",
94 nh_table_id=1)], table_id=2)
95 self.ip_t01.add_vpp_config()
96 self.ip_t10.add_vpp_config()
97 self.logger.debug(self.vapi.cli("show ip fib"))
100 self.vapi.session_enable_disable(is_enabled=0)
101 # Delete inter-table routes
102 self.ip_t01.remove_vpp_config()
103 self.ip_t10.remove_vpp_config()
105 for i in self.lo_interfaces:
109 super(QUICTestCase, self).tearDown()
112 class QUICEchoIntTestCase(QUICTestCase):
113 """QUIC Echo Internal Test Case"""
114 test_bytes = ' test-bytes'
117 super(QUICEchoIntTestCase, self).setUp()
118 self.client_args = 'uri {uri} fifo-size 64{testbytes} appns client' \
119 .format(uri=self.uri, testbytes=self.test_bytes)
120 self.server_args = "uri %s fifo-size 64 appns server" % self.uri
122 def server(self, *args):
123 error = self.vapi.cli(
124 "test echo server %s %s" %
125 (self.server_args, ' '.join(args)))
127 self.logger.critical(error)
128 self.assertNotIn("failed", error)
130 def client(self, *args):
131 error = self.vapi.cli(
132 "test echo client %s %s" %
133 (self.client_args, ' '.join(args)))
135 self.logger.critical(error)
136 self.assertNotIn("failed", error)
139 class QUICEchoIntTransferTestCase(QUICEchoIntTestCase):
140 """QUIC Echo Internal Transfer Test Case"""
141 def test_quic_int_transfer(self):
143 self.client("no-output", "mbytes", "2")
146 class QUICEchoIntTransferBigTestCase(QUICEchoIntTestCase):
147 """QUIC Echo Internal Transfer Big Test Case"""
150 @unittest.skipUnless(running_extended_tests, "part of extended tests")
151 def test_quic_int_transfer_big(self):
153 self.client("no-output", "gbytes", "10")
156 class QUICEchoIntSerialTestCase(QUICEchoIntTestCase):
157 """QUIC Echo Internal Serial Transfer Test Case"""
158 def test_quic_serial_int_transfer(self):
160 self.client("no-output", "mbytes", "2")
161 self.client("no-output", "mbytes", "2")
162 self.client("no-output", "mbytes", "2")
163 self.client("no-output", "mbytes", "2")
164 self.client("no-output", "mbytes", "2")
167 class QUICEchoIntSerialBigTestCase(QUICEchoIntTestCase):
168 """QUIC Echo Internal Serial Transfer Big Test Case"""
170 @unittest.skipUnless(running_extended_tests, "part of extended tests")
171 def test_quic_serial_int_transfer_big(self):
173 self.client("no-output", "gbytes", "5")
174 self.client("no-output", "gbytes", "5")
175 self.client("no-output", "gbytes", "5")
176 self.client("no-output", "gbytes", "5")
177 self.client("no-output", "gbytes", "5")
180 class QUICEchoIntMStreamTestCase(QUICEchoIntTestCase):
181 """QUIC Echo Internal MultiStream Test Case"""
182 def test_quic_int_multistream_transfer(self):
184 self.client("nclients", "10", "mbytes", "1", "no-output")
187 class QUICEchoIntMStreamBigTestCase(QUICEchoIntTestCase):
188 """QUIC Echo Internal MultiStream Big Test Case"""
190 @unittest.skipUnless(running_extended_tests, "part of extended tests")
191 def test_quic_int_multistream_transfer(self):
193 self.client("nclients", "10", "gbytes", "5", "no-output")
196 class QUICEchoExtTestCase(QUICTestCase):
197 extra_vpp_punt_config = ["session", "{", "evt_qs_memfd_seg", "}"]
198 quic_setup = "default"
199 test_bytes = "test-bytes:assert"
203 super(QUICEchoExtTestCase, self).setUp()
209 "socket-name", self.api_sock,
210 "quic-setup", self.quic_setup]
211 self.server_echo_test_args = common_args + \
212 ["server", "appns", "server"] # use default fifo-size
213 self.client_echo_test_args = common_args + \
214 ["client", "appns", "client", "fifo-size", "4M"]
215 error = self.vapi.cli("quic set fifo-size 2M")
217 self.logger.critical(error)
218 self.assertNotIn("failed", error)
220 def server(self, *args):
221 _args = self.server_echo_test_args + list(args)
222 self.worker_server = QUICAppWorker(
229 self.worker_server.start()
230 self.sleep(self.pre_test_sleep)
232 def client(self, *args):
233 _args = self.client_echo_test_args + list(args)
234 self.worker_client = QUICAppWorker(
241 self.worker_client.start()
242 timeout = None if self.debug_all else self.timeout
243 self.worker_client.join(timeout)
244 self.worker_server.join(timeout)
245 self.sleep(self.post_test_sleep)
247 def validate_ext_test_results(self):
248 server_result = self.worker_server.result
249 client_result = self.worker_client.result
250 self.logger.info("Server worker result is `%s'" %
252 self.logger.info("Client worker result is `%s'" %
254 server_kill_error = False
255 if self.worker_server.result is None:
256 server_kill_error = self.worker_server.teardown(
257 self.logger, self.timeout)
258 if self.worker_client.result is None:
259 self.worker_client.teardown(self.logger, self.timeout)
260 err_msg = "Wrong server worker return code (%s)" % server_result
261 self.assertEqual(server_result, 0, err_msg)
262 self.assertIsNotNone(
264 "Timeout! Client worker did not finish in %ss" %
266 err_msg = "Wrong client worker return code (%s)" % client_result
267 self.assertEqual(client_result, 0, err_msg)
268 self.assertFalse(server_kill_error, "Server kill errored")
271 class QUICEchoExtTransferTestCase(QUICEchoExtTestCase):
272 """QUIC Echo External Transfer Test Case"""
275 def test_quic_ext_transfer(self):
278 self.validate_ext_test_results()
281 class QUICEchoExtTransferBigTestCase(QUICEchoExtTestCase):
282 """QUIC Echo External Transfer Big Test Case"""
286 @unittest.skipUnless(running_extended_tests, "part of extended tests")
287 def test_quic_ext_transfer_big(self):
288 self.server("TX=0", "RX=10Gb")
289 self.client("TX=10Gb", "RX=0")
290 self.validate_ext_test_results()
293 class QUICEchoExtQcloseRxTestCase(QUICEchoExtTestCase):
294 """QUIC Echo External Transfer Qclose Rx Test Case"""
296 @unittest.skipUnless(running_extended_tests, "part of extended tests")
297 def test_quic_ext_qclose_rx(self):
298 self.server("TX=0", "RX=10Mb", "qclose=Y", "sclose=N")
299 self.client("TX=10Mb", "RX=0", "qclose=W", "sclose=W")
300 self.validate_ext_test_results()
303 class QUICEchoExtQcloseTxTestCase(QUICEchoExtTestCase):
304 """QUIC Echo External Transfer Qclose Tx Test Case"""
306 @unittest.skipUnless(running_extended_tests, "part of extended tests")
307 def test_quic_ext_qclose_tx(self):
308 self.server("TX=0", "RX=10Mb", "qclose=W", "sclose=W",
310 self.client("TX=10Mb", "RX=0", "qclose=Y", "sclose=N")
311 self.validate_ext_test_results()
314 class QUICEchoExtEarlyQcloseRxTestCase(QUICEchoExtTestCase):
315 """QUIC Echo External Transfer Early Qclose Rx Test Case"""
317 @unittest.skipUnless(running_extended_tests, "part of extended tests")
318 def test_quic_ext_early_qclose_rx(self):
319 self.server("TX=0", "RX=10Mb", "qclose=Y", "sclose=N")
320 self.client("TX=20Mb", "RX=0", "qclose=W", "sclose=W",
322 self.validate_ext_test_results()
325 class QUICEchoExtEarlyQcloseTxTestCase(QUICEchoExtTestCase):
326 """QUIC Echo External Transfer Early Qclose Tx Test Case"""
328 @unittest.skipUnless(running_extended_tests, "part of extended tests")
329 def test_quic_ext_early_qclose_tx(self):
330 self.server("TX=0", "RX=20Mb", "qclose=W", "sclose=W",
332 self.client("TX=10Mb", "RX=0", "qclose=Y", "sclose=N")
333 self.validate_ext_test_results()
336 class QUICEchoExtScloseRxTestCase(QUICEchoExtTestCase):
337 """QUIC Echo External Transfer Sclose Rx Test Case"""
339 @unittest.skipUnless(running_extended_tests, "part of extended tests")
340 def test_quic_ext_sclose_rx(self):
341 self.server("TX=0", "RX=10Mb", "qclose=N", "sclose=Y")
342 self.client("TX=10Mb", "RX=0", "qclose=W", "sclose=W")
343 self.validate_ext_test_results()
346 class QUICEchoExtScloseTxTestCase(QUICEchoExtTestCase):
347 """QUIC Echo External Transfer Sclose Tx Test Case"""
349 @unittest.skipUnless(running_extended_tests, "part of extended tests")
350 def test_quic_ext_sclose_tx(self):
351 self.server("TX=0", "RX=10Mb", "qclose=W", "sclose=W")
352 self.client("TX=10Mb", "RX=0", "qclose=Y", "sclose=Y")
353 self.validate_ext_test_results()
356 class QUICEchoExtEarlyScloseRxTestCase(QUICEchoExtTestCase):
357 """QUIC Echo External Transfer Early Sclose Rx Test Case"""
359 @unittest.skipUnless(running_extended_tests, "part of extended tests")
360 def test_quic_ext_early_sclose_rx(self):
361 self.server("TX=0", "RX=10Mb", "qclose=N", "sclose=Y")
362 self.client("TX=20Mb", "RX=0", "qclose=W", "sclose=W",
364 self.validate_ext_test_results()
367 class QUICEchoExtEarlyScloseTxTestCase(QUICEchoExtTestCase):
368 """QUIC Echo External Transfer Early Sclose Tx Test Case"""
370 @unittest.skipUnless(running_extended_tests, "part of extended tests")
371 def test_quic_ext_early_sclose_tx(self):
372 self.server("TX=0", "RX=20Mb", "qclose=W", "sclose=W",
374 self.client("TX=10Mb", "RX=0", "qclose=Y", "sclose=Y")
375 self.validate_ext_test_results()
378 class QUICEchoExtServerStreamTestCase(QUICEchoExtTestCase):
379 """QUIC Echo External Transfer Server Stream Test Case"""
380 quic_setup = "serverstream"
382 def test_quic_ext_transfer_server_stream(self):
383 self.server("TX=10Mb", "RX=0")
384 self.client("TX=0", "RX=10Mb")
385 self.validate_ext_test_results()
388 class QUICEchoExtBigServerStreamTestCase(QUICEchoExtTestCase):
389 """QUIC Echo External Transfer Big Server Stream Test Case"""
390 quic_setup = "serverstream"
393 @unittest.skipUnless(running_extended_tests, "part of extended tests")
394 def test_quic_ext_transfer_big_server_stream(self):
395 self.server("TX=10Gb", "RX=0")
396 self.client("TX=0", "RX=10Gb")
397 self.validate_ext_test_results()
400 class QUICEchoExtServerStreamQcloseRxTestCase(QUICEchoExtTestCase):
401 """QUIC Echo External Transfer Server Stream Qclose Rx Test Case"""
402 quic_setup = "serverstream"
404 @unittest.skipUnless(running_extended_tests, "part of extended tests")
405 def test_quic_ext_server_stream_qclose_rx(self):
406 self.server("TX=10Mb", "RX=0", "qclose=W", "sclose=W")
407 self.client("TX=0", "RX=10Mb", "qclose=Y", "sclose=N")
408 self.validate_ext_test_results()
411 class QUICEchoExtServerStreamQcloseTxTestCase(QUICEchoExtTestCase):
412 """QUIC Echo External Transfer Server Stream Qclose Tx Test Case"""
413 quic_setup = "serverstream"
415 @unittest.skipUnless(running_extended_tests, "part of extended tests")
416 def test_quic_ext_server_stream_qclose_tx(self):
417 self.server("TX=10Mb", "RX=0", "qclose=Y", "sclose=N")
418 self.client("TX=0", "RX=10Mb", "qclose=W", "sclose=W",
420 self.validate_ext_test_results()
423 class QUICEchoExtServerStreamEarlyQcloseRxTestCase(QUICEchoExtTestCase):
424 """QUIC Echo External Transfer Server Stream Early Qclose Rx Test Case"""
425 quic_setup = "serverstream"
427 @unittest.skipUnless(running_extended_tests, "part of extended tests")
428 def test_quic_ext_server_stream_early_qclose_rx(self):
429 self.server("TX=20Mb", "RX=0", "qclose=W", "sclose=W",
431 self.client("TX=0", "RX=10Mb", "qclose=Y", "sclose=N")
432 self.validate_ext_test_results()
435 class QUICEchoExtServerStreamEarlyQcloseTxTestCase(QUICEchoExtTestCase):
436 """QUIC Echo External Transfer Server Stream Early Qclose Tx Test Case"""
437 quic_setup = "serverstream"
439 @unittest.skipUnless(running_extended_tests, "part of extended tests")
440 def test_quic_ext_server_stream_early_qclose_tx(self):
441 self.server("TX=10Mb", "RX=0", "qclose=Y", "sclose=N")
442 self.client("TX=0", "RX=20Mb", "qclose=W", "sclose=W",
444 self.validate_ext_test_results()
447 class QUICEchoExtServerStreamScloseRxTestCase(QUICEchoExtTestCase):
448 """QUIC Echo External Transfer Server Stream Sclose Rx Test Case"""
449 quic_setup = "serverstream"
451 @unittest.skipUnless(running_extended_tests, "part of extended tests")
452 def test_quic_ext_server_stream_sclose_rx(self):
453 self.server("TX=10Mb", "RX=0", "qclose=W", "sclose=W")
454 self.client("TX=0", "RX=10Mb", "qclose=N", "sclose=Y")
455 self.validate_ext_test_results()
458 class QUICEchoExtServerStreamScloseTxTestCase(QUICEchoExtTestCase):
459 """QUIC Echo External Transfer Server Stream Sclose Tx Test Case"""
460 quic_setup = "serverstream"
462 @unittest.skipUnless(running_extended_tests, "part of extended tests")
463 def test_quic_ext_server_stream_sclose_tx(self):
464 self.server("TX=10Mb", "RX=0", "qclose=Y", "sclose=Y")
465 self.client("TX=0", "RX=10Mb", "qclose=W", "sclose=W")
466 self.validate_ext_test_results()
469 class QUICEchoExtServerStreamEarlyScloseRxTestCase(QUICEchoExtTestCase):
470 """QUIC Echo External Transfer Server Stream Early Sclose Rx Test Case"""
471 quic_setup = "serverstream"
473 @unittest.skipUnless(running_extended_tests, "part of extended tests")
474 def test_quic_ext_server_stream_early_sclose_rx(self):
475 self.server("TX=20Mb", "RX=0", "qclose=W", "sclose=W",
477 self.client("TX=0", "RX=10Mb", "qclose=N", "sclose=Y")
478 self.validate_ext_test_results()
481 class QUICEchoExtServerStreamEarlyScloseTxTestCase(QUICEchoExtTestCase):
482 """QUIC Echo Ext Transfer Server Stream Early Sclose Tx Test Case"""
483 quic_setup = "serverstream"
485 @unittest.skipUnless(running_extended_tests, "part of extended tests")
486 def test_quic_ext_server_stream_early_sclose_tx(self):
487 self.server("TX=10Mb", "RX=0", "qclose=Y", "sclose=Y")
488 self.client("TX=0", "RX=20Mb", "qclose=W", "sclose=W",
490 self.validate_ext_test_results()
493 class QUICEchoExtServerStreamWorkersTestCase(QUICEchoExtTestCase):
494 """QUIC Echo External Transfer Server Stream MultiWorker Test Case"""
495 quic_setup = "serverstream"
497 @unittest.skipUnless(running_extended_tests, "part of extended tests")
498 def test_quic_ext_transfer_server_stream_multi_workers(self):
499 self.server("nclients", "4", "quic-streams", "4", "TX=10Mb", "RX=0")
500 self.client("nclients", "4", "quic-streams", "4", "TX=0", "RX=10Mb")
501 self.validate_ext_test_results()
504 if __name__ == '__main__':
505 unittest.main(testRunner=VppTestRunner)