diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/ext/vom_test.cpp | 18 | ||||
-rw-r--r-- | test/test_qos.py | 30 | ||||
-rw-r--r-- | test/vpp_qos.py | 38 |
3 files changed, 84 insertions, 2 deletions
diff --git a/test/ext/vom_test.cpp b/test/ext/vom_test.cpp index 6b6a1d7dab0..fa9ecdafe80 100644 --- a/test/ext/vom_test.cpp +++ b/test/ext/vom_test.cpp @@ -84,6 +84,8 @@ #include "vom/qos_map_cmds.hpp" #include "vom/qos_record.hpp" #include "vom/qos_record_cmds.hpp" +#include "vom/qos_store.hpp" +#include "vom/qos_store_cmds.hpp" using namespace boost; using namespace VOM; @@ -508,6 +510,14 @@ public: { rc = handle_derived<QoS::record_cmds::delete_cmd>(f_exp, f_act); } + else if (typeid(*f_exp) == typeid(QoS::store_cmds::create_cmd)) + { + rc = handle_derived<QoS::store_cmds::create_cmd>(f_exp, f_act); + } + else if (typeid(*f_exp) == typeid(QoS::store_cmds::delete_cmd)) + { + rc = handle_derived<QoS::store_cmds::delete_cmd>(f_exp, f_act); + } else if (typeid(*f_exp) == typeid(QoS::map_cmds::create_cmd)) { rc = handle_derived<QoS::map_cmds::create_cmd>(f_exp, f_act); @@ -2251,16 +2261,24 @@ BOOST_AUTO_TEST_CASE(test_qos) { ADD_EXPECT(QoS::record_cmds::create_cmd(hw_qr, hw_ifh.data(), QoS::source_t::IP)); TRY_CHECK_RC(OM::write(albert, *qr)); + QoS::store *qs = new QoS::store(itf, QoS::source_t::IP, 55); + HW::item<bool> hw_qs(true, rc_t::OK); + ADD_EXPECT(QoS::store_cmds::create_cmd(hw_qs, hw_ifh.data(), QoS::source_t::IP, 55)); + TRY_CHECK_RC(OM::write(albert, *qs)); + QoS::mark *qm = new QoS::mark(itf, qem, QoS::source_t::IP); HW::item<bool> hw_qm(true, rc_t::OK); ADD_EXPECT(QoS::mark_cmds::create_cmd(hw_qm, hw_ifh.data(), 1, QoS::source_t::IP)); TRY_CHECK_RC(OM::write(albert, *qm)); + STRICT_ORDER_OFF(); delete qr; delete qm; + delete qs; ADD_EXPECT(QoS::mark_cmds::delete_cmd(hw_qm, hw_ifh.data(), QoS::source_t::IP)); ADD_EXPECT(QoS::map_cmds::delete_cmd(hw_qem, 1)); ADD_EXPECT(QoS::record_cmds::delete_cmd(hw_qr, hw_ifh.data(), QoS::source_t::IP)); + ADD_EXPECT(QoS::store_cmds::delete_cmd(hw_qs, hw_ifh.data(), QoS::source_t::IP)); ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh)); ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf_name)); TRY_CHECK(OM::remove(albert)); diff --git a/test/test_qos.py b/test/test_qos.py index 9efa79854bf..149a9ebbe6e 100644 --- a/test/test_qos.py +++ b/test/test_qos.py @@ -15,7 +15,7 @@ from scapy.layers.inet import IP, UDP from scapy.layers.inet6 import IPv6 from scapy.contrib.mpls import MPLS from vpp_papi import VppEnum -from vpp_qos import VppQosRecord, VppQosEgressMap, VppQosMark +from vpp_qos import VppQosRecord, VppQosEgressMap, VppQosMark, VppQosStore NUM_PKTS = 67 @@ -63,7 +63,7 @@ class TestQOS(VppTestCase): super(TestQOS, self).tearDown() def test_qos_ip(self): - """ QoS Mark/Record IP """ + """ QoS Mark/Record/Store IP """ # # for table 1 map the n=0xff possible values of input QoS mark, @@ -256,6 +256,32 @@ class TestQOS(VppTestCase): self.assertEqual(p[IP].tos, 254) # + # enable QoS stroe instead of record + # + qst1 = VppQosStore(self, self.pg0, + self.QOS_SOURCE.QOS_API_SOURCE_IP, + 5).add_vpp_config() + self.logger.info(self.vapi.cli("sh qos store")) + + p_v4[IP].dst = self.pg1.remote_ip4 + rx = self.send_and_expect(self.pg0, p_v4 * NUM_PKTS, self.pg1) + for p in rx: + self.assertEqual(p[IP].tos, 250) + + # + # disable the input storing on pg0 + # + self.assertTrue(qst1.query_vpp_config()) + qst1.remove_vpp_config() + + # + # back to an unchanged TOS value + # + rx = self.send_and_expect(self.pg0, p_v4 * NUM_PKTS, self.pg1) + for p in rx: + self.assertEqual(p[IP].tos, 254) + + # # disable the egress map on pg1 and pg4 # qm1.remove_vpp_config() diff --git a/test/vpp_qos.py b/test/vpp_qos.py index 0577863ef8c..a7fa9e748aa 100644 --- a/test/vpp_qos.py +++ b/test/vpp_qos.py @@ -42,6 +42,44 @@ class VppQosRecord(VppObject): return ("qos-record-%s-%d" % (self.intf, self.source)) +class VppQosStore(VppObject): + """ QoS Store(ing) configuration """ + + def __init__(self, test, intf, source, value): + self._test = test + self.intf = intf + self.source = source + self.value = value + + def add_vpp_config(self): + self._test.vapi.qos_store_enable_disable( + enable=1, + store={'sw_if_index': self.intf.sw_if_index, + 'input_source': self.source, + 'value': self.value}) + self._test.registry.register(self, self._test.logger) + return self + + def remove_vpp_config(self): + self._test.vapi.qos_store_enable_disable( + enable=0, + store={'sw_if_index': self.intf.sw_if_index, + 'input_source': self.source}) + + def query_vpp_config(self): + rs = self._test.vapi.qos_store_dump() + + for r in rs: + if self.intf.sw_if_index == r.store.sw_if_index and \ + self.source == r.store.input_source and \ + self.value == r.store.value: + return True + return False + + def object_id(self): + return ("qos-store-%s-%d" % (self.intf, self.source)) + + class VppQosEgressMap(VppObject): """ QoS Egress Map(ping) configuration """ |