blob: 75bbb23f31f6d8f31dba6a18e263e3880338cc6c [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):
Florin Coras3ffe6ca2019-06-26 16:27:13 -070014 cls.extra_vpp_plugin_config.append("plugin sctp_plugin.so { enable }")
Marco Varlese191a5942017-10-30 18:17:21 +010015 super(TestSCTP, cls).setUpClass()
16
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -070017 @classmethod
18 def tearDownClass(cls):
19 super(TestSCTP, cls).tearDownClass()
20
Marco Varlese191a5942017-10-30 18:17:21 +010021 def setUp(self):
22 super(TestSCTP, self).setUp()
23 self.vapi.session_enable_disable(is_enabled=1)
Florin Corasb4ca8b12019-06-27 10:32:27 -070024 self.vapi.cli("sctp enable")
Klement Sekerab9ef2732018-06-24 22:49:33 +020025 self.create_loopback_interfaces(2)
Marco Varlese191a5942017-10-30 18:17:21 +010026
27 table_id = 0
28
29 for i in self.lo_interfaces:
30 i.admin_up()
31
32 if table_id != 0:
33 tbl = VppIpTable(self, table_id)
34 tbl.add_vpp_config()
35
36 i.set_table_ip4(table_id)
37 i.config_ip4()
38 table_id += 1
39
40 # Configure namespaces
Paul Vinciguerra22ab6f72019-03-07 17:55:33 -080041 self.vapi.app_namespace_add_del(namespace_id=b"0",
Ole Troane1ade682019-03-04 23:55:43 +010042 sw_if_index=self.loop0.sw_if_index)
Paul Vinciguerra22ab6f72019-03-07 17:55:33 -080043 self.vapi.app_namespace_add_del(namespace_id=b"1",
Ole Troane1ade682019-03-04 23:55:43 +010044 sw_if_index=self.loop1.sw_if_index)
Marco Varlese191a5942017-10-30 18:17:21 +010045
46 def tearDown(self):
47 for i in self.lo_interfaces:
48 i.unconfig_ip4()
49 i.set_table_ip4(0)
50 i.admin_down()
51 self.vapi.session_enable_disable(is_enabled=0)
52 super(TestSCTP, self).tearDown()
53
Marco Varlese191a5942017-10-30 18:17:21 +010054 def test_sctp_transfer(self):
Florin Coras4399c2e2018-01-25 06:34:42 -080055 """ SCTP echo client/server transfer """
Marco Varlese191a5942017-10-30 18:17:21 +010056
57 # Add inter-table routes
58 ip_t01 = VppIpRoute(self, self.loop1.local_ip4, 32,
59 [VppRoutePath("0.0.0.0",
60 0xffffffff,
61 nh_table_id=1)])
62 ip_t10 = VppIpRoute(self, self.loop0.local_ip4, 32,
63 [VppRoutePath("0.0.0.0",
64 0xffffffff,
65 nh_table_id=0)], table_id=1)
66 ip_t01.add_vpp_config()
67 ip_t10.add_vpp_config()
68
69 # Start builtin server and client
70 uri = "sctp://" + self.loop0.local_ip4 + "/1234"
Florin Corasb0f662f2018-12-27 14:51:46 -080071 error = self.vapi.cli("test echo server appns 0 fifo-size 4 " +
72 "no-echo uri " + uri)
Marco Varlese191a5942017-10-30 18:17:21 +010073 if error:
74 self.logger.critical(error)
Paul Vinciguerra9a6dafd2019-03-06 15:11:28 -080075 self.assertNotIn("failed", error)
Marco Varlese191a5942017-10-30 18:17:21 +010076
Florin Corasb0f662f2018-12-27 14:51:46 -080077 error = self.vapi.cli("test echo client mbytes 10 no-return " +
Marco Varlese04e5d642018-02-23 17:43:06 +010078 " appns 1" +
Marco Varlese191a5942017-10-30 18:17:21 +010079 " fifo-size 4" +
Marco Varlese04e5d642018-02-23 17:43:06 +010080 " no-output test-bytes syn-timeout 3" +
Marco Varlese87971682018-10-04 15:46:05 +020081 " test-timeout 30" +
Marco Varlese191a5942017-10-30 18:17:21 +010082 " uri " + uri)
83 if error:
84 self.logger.critical(error)
Paul Vinciguerra9a6dafd2019-03-06 15:11:28 -080085 self.assertNotIn("failed", error)
Marco Varlese191a5942017-10-30 18:17:21 +010086
87 # Delete inter-table routes
88 ip_t01.remove_vpp_config()
89 ip_t10.remove_vpp_config()
90
91if __name__ == '__main__':
92 unittest.main(testRunner=VppTestRunner)