5 from framework import VppTestCase, VppTestRunner
6 from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath
9 class TestSCTP(VppTestCase):
10 """ SCTP Test Case """
14 super(TestSCTP, cls).setUpClass()
17 super(TestSCTP, self).setUp()
18 self.vapi.session_enable_disable(is_enabled=1)
19 self.create_loopback_interfaces(range(2))
23 for i in self.lo_interfaces:
27 tbl = VppIpTable(self, table_id)
30 i.set_table_ip4(table_id)
34 # Configure namespaces
35 self.vapi.app_namespace_add(namespace_id="0",
36 sw_if_index=self.loop0.sw_if_index)
37 self.vapi.app_namespace_add(namespace_id="1",
38 sw_if_index=self.loop1.sw_if_index)
41 for i in self.lo_interfaces:
45 self.vapi.session_enable_disable(is_enabled=0)
46 super(TestSCTP, self).tearDown()
48 def test_sctp_unittest(self):
49 """ SCTP Unit Tests """
50 error = self.vapi.cli("test sctp all")
53 self.logger.critical(error)
54 self.assertEqual(error.find("failed"), -1)
56 def test_sctp_transfer(self):
57 """ SCTP builtin client/server transfer """
59 # Add inter-table routes
60 ip_t01 = VppIpRoute(self, self.loop1.local_ip4, 32,
61 [VppRoutePath("0.0.0.0",
64 ip_t10 = VppIpRoute(self, self.loop0.local_ip4, 32,
65 [VppRoutePath("0.0.0.0",
67 nh_table_id=0)], table_id=1)
68 ip_t01.add_vpp_config()
69 ip_t10.add_vpp_config()
71 # Start builtin server and client
72 uri = "sctp://" + self.loop0.local_ip4 + "/1234"
73 error = self.vapi.cli("test sctp server appns 0 fifo-size 4 uri " +
76 self.logger.critical(error)
78 error = self.vapi.cli("test sctp client mbytes 10 appns 1" +
80 " no-output test-bytes syn-timeout 20 " +
83 self.logger.critical(error)
84 self.assertEqual(error.find("failed"), -1)
86 # Delete inter-table routes
87 ip_t01.remove_vpp_config()
88 ip_t10.remove_vpp_config()
90 if __name__ == '__main__':
91 unittest.main(testRunner=VppTestRunner)