blob: e1faa9a0c1db2e738b2009a4049f51aa6656a485 [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
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -070016 @classmethod
17 def tearDownClass(cls):
18 super(TestSCTP, cls).tearDownClass()
19
Marco Varlese191a5942017-10-30 18:17:21 +010020 def setUp(self):
21 super(TestSCTP, self).setUp()
22 self.vapi.session_enable_disable(is_enabled=1)
Klement Sekerab9ef2732018-06-24 22:49:33 +020023 self.create_loopback_interfaces(2)
Marco Varlese191a5942017-10-30 18:17:21 +010024
25 table_id = 0
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
Paul Vinciguerra22ab6f72019-03-07 17:55:33 -080039 self.vapi.app_namespace_add_del(namespace_id=b"0",
Ole Troane1ade682019-03-04 23:55:43 +010040 sw_if_index=self.loop0.sw_if_index)
Paul Vinciguerra22ab6f72019-03-07 17:55:33 -080041 self.vapi.app_namespace_add_del(namespace_id=b"1",
Ole Troane1ade682019-03-04 23:55:43 +010042 sw_if_index=self.loop1.sw_if_index)
Marco Varlese191a5942017-10-30 18:17:21 +010043
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(TestSCTP, self).tearDown()
51
Marco Varlese191a5942017-10-30 18:17:21 +010052 def test_sctp_transfer(self):
Florin Coras4399c2e2018-01-25 06:34:42 -080053 """ SCTP echo client/server transfer """
Marco Varlese191a5942017-10-30 18:17:21 +010054
55 # Add inter-table routes
56 ip_t01 = VppIpRoute(self, self.loop1.local_ip4, 32,
57 [VppRoutePath("0.0.0.0",
58 0xffffffff,
59 nh_table_id=1)])
60 ip_t10 = VppIpRoute(self, self.loop0.local_ip4, 32,
61 [VppRoutePath("0.0.0.0",
62 0xffffffff,
63 nh_table_id=0)], table_id=1)
64 ip_t01.add_vpp_config()
65 ip_t10.add_vpp_config()
66
67 # Start builtin server and client
68 uri = "sctp://" + self.loop0.local_ip4 + "/1234"
Florin Corasb0f662f2018-12-27 14:51:46 -080069 error = self.vapi.cli("test echo server appns 0 fifo-size 4 " +
70 "no-echo uri " + uri)
Marco Varlese191a5942017-10-30 18:17:21 +010071 if error:
72 self.logger.critical(error)
Paul Vinciguerra9a6dafd2019-03-06 15:11:28 -080073 self.assertNotIn("failed", error)
Marco Varlese191a5942017-10-30 18:17:21 +010074
Florin Corasb0f662f2018-12-27 14:51:46 -080075 error = self.vapi.cli("test echo client mbytes 10 no-return " +
Marco Varlese04e5d642018-02-23 17:43:06 +010076 " appns 1" +
Marco Varlese191a5942017-10-30 18:17:21 +010077 " fifo-size 4" +
Marco Varlese04e5d642018-02-23 17:43:06 +010078 " no-output test-bytes syn-timeout 3" +
Marco Varlese87971682018-10-04 15:46:05 +020079 " test-timeout 30" +
Marco Varlese191a5942017-10-30 18:17:21 +010080 " uri " + uri)
81 if error:
82 self.logger.critical(error)
Paul Vinciguerra9a6dafd2019-03-06 15:11:28 -080083 self.assertNotIn("failed", error)
Marco Varlese191a5942017-10-30 18:17:21 +010084
85 # Delete inter-table routes
86 ip_t01.remove_vpp_config()
87 ip_t10.remove_vpp_config()
88
89if __name__ == '__main__':
90 unittest.main(testRunner=VppTestRunner)