blob: e1ccc572968ef36150359693859c8b54e4d51cbb [file] [log] [blame]
Dave Wallaceb063ad02019-04-09 21:01:09 -04001#!/usr/bin/env python
2
3import unittest
4
5from framework import VppTestCase, VppTestRunner, running_extended_tests
6from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath
7
8
9class TestQUIC(VppTestCase):
10 """ QUIC Test Case """
11
12 @classmethod
13 def setUpClass(cls):
14 super(TestQUIC, cls).setUpClass()
15
16 @classmethod
17 def tearDownClass(cls):
18 super(TestQUIC, cls).tearDownClass()
19
20 def setUp(self):
21 super(TestQUIC, self).setUp()
22 self.vapi.session_enable_disable(is_enabled=1)
23 self.create_loopback_interfaces(2)
24
25 table_id = 1
26
27 for i in self.lo_interfaces:
28 i.admin_up()
29
30 if table_id != 0:
31 tbl = VppIpTable(self, table_id)
32 tbl.add_vpp_config()
33
34 i.set_table_ip4(table_id)
35 i.config_ip4()
36 table_id += 1
37
38 # Configure namespaces
39 self.vapi.app_namespace_add_del(namespace_id=b"1",
40 sw_if_index=self.loop0.sw_if_index)
41 self.vapi.app_namespace_add_del(namespace_id=b"2",
42 sw_if_index=self.loop1.sw_if_index)
43
44 def tearDown(self):
45 for i in self.lo_interfaces:
46 i.unconfig_ip4()
47 i.set_table_ip4(0)
48 i.admin_down()
49 self.vapi.session_enable_disable(is_enabled=0)
50 super(TestQUIC, self).tearDown()
51
52 @unittest.skipUnless(running_extended_tests, "part of extended tests")
53 def test_quic_transfer(self):
54 """ QUIC echo client/server transfer """
55
56 # Add inter-table routes
57 ip_t01 = VppIpRoute(self, self.loop1.local_ip4, 32,
58 [VppRoutePath("0.0.0.0",
59 0xffffffff,
60 nh_table_id=2)], table_id=1)
61 ip_t10 = VppIpRoute(self, self.loop0.local_ip4, 32,
62 [VppRoutePath("0.0.0.0",
63 0xffffffff,
64 nh_table_id=1)], table_id=2)
65 ip_t01.add_vpp_config()
66 ip_t10.add_vpp_config()
67 self.logger.debug(self.vapi.cli("show ip fib"))
68
69 # Start builtin server and client
70 uri = "quic://%s/1234" % self.loop0.local_ip4
71 error = self.vapi.cli("test echo server appns 1 fifo-size 4 uri %s" %
72 uri)
73 if error:
74 self.logger.critical(error)
75 self.assertNotIn("failed", error)
76 error = self.vapi.cli("test echo client bytes 1024 appns 2 " +
77 "fifo-size 4 test-bytes no-output " +
78 "uri %s" % uri)
79 self.logger.critical(error)
80 if error:
81 self.logger.critical(error)
82 self.assertNotIn("failed", error)
83
84 # Delete inter-table routes
85 ip_t01.remove_vpp_config()
86 ip_t10.remove_vpp_config()
87
88if __name__ == '__main__':
89 unittest.main(testRunner=VppTestRunner)