summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorNeale Ranns <neale.ranns@cisco.com>2018-04-11 08:08:30 -0700
committerFlorin Coras <florin.coras@gmail.com>2018-07-18 04:48:34 +0000
commitee8b973de9d6cfd01f7f5ac6c9058c23f6220ab6 (patch)
tree5e73109cb579729800962bd752841f6fce32c4fe /test
parentb4b2488202ff4282cc4a7bd779cc33934286c5cd (diff)
VOM: support for pipes
Change-Id: I5c381dfe2f926f94a34ee8ed8f1b9ec6038d5fe2 Signed-off-by: Neale Ranns <neale.ranns@cisco.com> (cherry picked from commit 208c29aac523231af2420a95ba7e5d361698780b)
Diffstat (limited to 'test')
-rw-r--r--test/ext/vom_test.cpp78
-rw-r--r--test/test_pipe.py10
2 files changed, 82 insertions, 6 deletions
diff --git a/test/ext/vom_test.cpp b/test/ext/vom_test.cpp
index 0213c42196e..5ccdf55f5da 100644
--- a/test/ext/vom_test.cpp
+++ b/test/ext/vom_test.cpp
@@ -67,6 +67,8 @@
#include "vom/nat_static_cmds.hpp"
#include "vom/nat_binding.hpp"
#include "vom/nat_binding_cmds.hpp"
+#include "vom/pipe.hpp"
+#include "vom/pipe_cmds.hpp"
using namespace boost;
using namespace VOM;
@@ -427,6 +429,14 @@ public:
{
rc = handle_derived<interface_cmds::events_cmd>(f_exp, f_act);
}
+ else if (typeid(*f_exp) == typeid(pipe_cmds::create_cmd))
+ {
+ rc = handle_derived<pipe_cmds::create_cmd>(f_exp, f_act);
+ }
+ else if (typeid(*f_exp) == typeid(pipe_cmds::delete_cmd))
+ {
+ rc = handle_derived<pipe_cmds::delete_cmd>(f_exp, f_act);
+ }
else
{
throw ExpException(2);
@@ -1860,4 +1870,72 @@ BOOST_AUTO_TEST_CASE(test_prefixes) {
}
+BOOST_AUTO_TEST_CASE(test_pipes) {
+ VppInit vi;
+ const std::string gk = "GKChesterton";
+
+ const std::string pipe_name_1 = "pipe1";
+ VOM::pipe pipe1(1, interface::admin_state_t::UP);
+ HW::item<handle_t> hw_hdl(4, rc_t::OK);
+ HW::item<pipe::handle_pair_t> hw_hdl_pair(std::make_pair(5,6), rc_t::OK);
+
+ HW::item<interface::admin_state_t> hw_as_up(interface::admin_state_t::UP,
+ rc_t::OK);
+ HW::item<interface::admin_state_t> hw_as_down(interface::admin_state_t::DOWN,
+ rc_t::OK);
+ ADD_EXPECT(pipe_cmds::create_cmd(hw_hdl, pipe_name_1, 1, hw_hdl_pair));
+ ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_hdl));
+ TRY_CHECK_RC(OM::write(gk, pipe1));
+
+ pipe1.set_ends(hw_hdl_pair.data());
+
+ // put each end of the pipe in a BD
+ bridge_domain bd1(33, bridge_domain::learning_mode_t::OFF,
+ bridge_domain::arp_term_mode_t::OFF,
+ bridge_domain::flood_mode_t::OFF,
+ bridge_domain::mac_age_mode_t::ON);
+
+ HW::item<uint32_t> hw_bd(33, rc_t::OK);
+ ADD_EXPECT(bridge_domain_cmds::create_cmd(hw_bd,
+ bridge_domain::learning_mode_t::OFF,
+ bridge_domain::arp_term_mode_t::OFF,
+ bridge_domain::flood_mode_t::OFF,
+ bridge_domain::mac_age_mode_t::ON));
+
+ TRY_CHECK_RC(OM::write(gk, bd1));
+
+ l2_binding *l2_1 = new l2_binding(*pipe1.east(), bd1);
+ HW::item<bool> hw_l2_1_bind(true, rc_t::OK);
+
+ ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_1_bind,
+ pipe1.east()->handle(),
+ hw_bd.data(), false));
+ TRY_CHECK_RC(OM::write(gk, *l2_1));
+
+ l2_binding *l2_2 = new l2_binding(*pipe1.west(), bd1);
+ HW::item<bool> hw_l2_2_bind(true, rc_t::OK);
+
+ ADD_EXPECT(l2_binding_cmds::bind_cmd(hw_l2_2_bind,
+ pipe1.west()->handle(),
+ hw_bd.data(), false));
+ TRY_CHECK_RC(OM::write(gk, *l2_2));
+
+ STRICT_ORDER_OFF();
+
+ delete l2_1;
+ delete l2_2;
+ ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_1_bind,
+ pipe1.east()->handle(),
+ hw_bd.data(),
+ false));
+ ADD_EXPECT(l2_binding_cmds::unbind_cmd(hw_l2_1_bind,
+ pipe1.west()->handle(),
+ hw_bd.data(),
+ false));
+ ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_hdl));
+ ADD_EXPECT(pipe_cmds::delete_cmd(hw_hdl, hw_hdl_pair));
+ ADD_EXPECT(bridge_domain_cmds::delete_cmd(hw_bd));
+ TRY_CHECK(OM::remove(gk));
+}
+
BOOST_AUTO_TEST_SUITE_END()
diff --git a/test/test_pipe.py b/test/test_pipe.py
index a89c1e90236..a2b630fc301 100644
--- a/test/test_pipe.py
+++ b/test/test_pipe.py
@@ -32,11 +32,11 @@ class VppPipe(VppInterface):
self.result = self._test.vapi.pipe_create(
0 if self.instance == 0xffffffff else 1,
self.instance)
- self.set_sw_if_index(self.result.parent_sw_if_index)
+ self.set_sw_if_index(self.result.sw_if_index)
def remove_vpp_config(self):
self._test.vapi.pipe_delete(
- self.result.parent_sw_if_index)
+ self.result.sw_if_index)
def __str__(self):
return self.object_id()
@@ -47,7 +47,7 @@ class VppPipe(VppInterface):
def query_vpp_config(self):
pipes = self._test.vapi.pipe_dump()
for p in pipes:
- if p.parent_sw_if_index == self.result.parent_sw_if_index:
+ if p.sw_if_index == self.result.sw_if_index:
return True
return False
@@ -78,9 +78,7 @@ class TestPipe(VppTestCase):
def test_pipe(self):
""" Pipes """
- pipes = []
- pipes.append(VppPipe(self))
- pipes.append(VppPipe(self, 10))
+ pipes = [VppPipe(self), VppPipe(self, 10)]
for p in pipes:
p.add_vpp_config()