blob: 4d04aa068288b2ad18ab931ff7600671bd661484 [file] [log] [blame]
Marco Varlese191a5942017-10-30 18:17:21 +01001#!/usr/bin/env python
2
3import unittest
4
5from framework import VppTestCase, VppTestRunner
6from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath
7
8
9class TestSCTP(VppTestCase):
10 """ SCTP Test Case """
11
12 @classmethod
13 def setUpClass(cls):
14 super(TestSCTP, cls).setUpClass()
15
16 def setUp(self):
17 super(TestSCTP, self).setUp()
18 self.vapi.session_enable_disable(is_enabled=1)
Klement Sekerab9ef2732018-06-24 22:49:33 +020019 self.create_loopback_interfaces(2)
Marco Varlese191a5942017-10-30 18:17:21 +010020
21 table_id = 0
22
23 for i in self.lo_interfaces:
24 i.admin_up()
25
26 if table_id != 0:
27 tbl = VppIpTable(self, table_id)
28 tbl.add_vpp_config()
29
30 i.set_table_ip4(table_id)
31 i.config_ip4()
32 table_id += 1
33
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)
39
40 def tearDown(self):
41 for i in self.lo_interfaces:
42 i.unconfig_ip4()
43 i.set_table_ip4(0)
44 i.admin_down()
45 self.vapi.session_enable_disable(is_enabled=0)
46 super(TestSCTP, self).tearDown()
47
Marco Varlese191a5942017-10-30 18:17:21 +010048 def test_sctp_transfer(self):
Florin Coras4399c2e2018-01-25 06:34:42 -080049 """ SCTP echo client/server transfer """
Marco Varlese191a5942017-10-30 18:17:21 +010050
51 # Add inter-table routes
52 ip_t01 = VppIpRoute(self, self.loop1.local_ip4, 32,
53 [VppRoutePath("0.0.0.0",
54 0xffffffff,
55 nh_table_id=1)])
56 ip_t10 = VppIpRoute(self, self.loop0.local_ip4, 32,
57 [VppRoutePath("0.0.0.0",
58 0xffffffff,
59 nh_table_id=0)], table_id=1)
60 ip_t01.add_vpp_config()
61 ip_t10.add_vpp_config()
62
63 # Start builtin server and client
64 uri = "sctp://" + self.loop0.local_ip4 + "/1234"
Florin Coras4399c2e2018-01-25 06:34:42 -080065 error = self.vapi.cli("test echo server appns 0 fifo-size 4 uri " +
Marco Varlese191a5942017-10-30 18:17:21 +010066 uri)
67 if error:
68 self.logger.critical(error)
Florin Coras4399c2e2018-01-25 06:34:42 -080069 self.assertEqual(error.find("failed"), -1)
Marco Varlese191a5942017-10-30 18:17:21 +010070
Marco Varlese29d22c52018-10-04 11:52:44 +020071 error = self.vapi.cli("test echo client mbytes 10" +
Marco Varlese04e5d642018-02-23 17:43:06 +010072 " appns 1" +
Marco Varlese191a5942017-10-30 18:17:21 +010073 " fifo-size 4" +
Marco Varlese04e5d642018-02-23 17:43:06 +010074 " no-output test-bytes syn-timeout 3" +
Marco Varlese191a5942017-10-30 18:17:21 +010075 " uri " + uri)
76 if error:
77 self.logger.critical(error)
Florin Coras4399c2e2018-01-25 06:34:42 -080078 self.assertEqual(error.find("failed"), -1)
Marco Varlese191a5942017-10-30 18:17:21 +010079
80 # Delete inter-table routes
81 ip_t01.remove_vpp_config()
82 ip_t10.remove_vpp_config()
83
84if __name__ == '__main__':
85 unittest.main(testRunner=VppTestRunner)