X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Fext%2Fvom_test.cpp;h=5ccdf55f5da6fd394340b9b8bc7280e8ed7f731e;hb=208c29aac523231af2420a95ba7e5d361698780b;hp=6958eb117a4100c5d5a28b05e7669dcfa736e64a;hpb=25b049484fcf9161edb2c19250066b893c38c264;p=vpp.git diff --git a/test/ext/vom_test.cpp b/test/ext/vom_test.cpp index 6958eb117a4..5ccdf55f5da 100644 --- a/test/ext/vom_test.cpp +++ b/test/ext/vom_test.cpp @@ -25,6 +25,8 @@ #include "vom/bond_group_binding_cmds.hpp" #include "vom/l2_binding.hpp" #include "vom/l2_binding_cmds.hpp" +#include "vom/l2_xconnect.hpp" +#include "vom/l2_xconnect_cmds.hpp" #include "vom/l3_binding.hpp" #include "vom/l3_binding_cmds.hpp" #include "vom/bridge_domain.hpp" @@ -65,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; @@ -293,6 +297,14 @@ public: { rc = handle_derived(f_exp, f_act); } + else if (typeid(*f_exp) == typeid(l2_xconnect_cmds::bind_cmd)) + { + rc = handle_derived(f_exp, f_act); + } + else if (typeid(*f_exp) == typeid(l2_xconnect_cmds::unbind_cmd)) + { + rc = handle_derived(f_exp, f_act); + } else if (typeid(*f_exp) == typeid(vxlan_tunnel_cmds::create_cmd)) { rc = handle_derived(f_exp, f_act); @@ -417,6 +429,14 @@ public: { rc = handle_derived(f_exp, f_act); } + else if (typeid(*f_exp) == typeid(pipe_cmds::create_cmd)) + { + rc = handle_derived(f_exp, f_act); + } + else if (typeid(*f_exp) == typeid(pipe_cmds::delete_cmd)) + { + rc = handle_derived(f_exp, f_act); + } else { throw ExpException(2); @@ -1017,6 +1037,60 @@ BOOST_AUTO_TEST_CASE(test_bridge) { TRY_CHECK(OM::remove(jkr)); } +BOOST_AUTO_TEST_CASE(test_l2_xconnect) { + VppInit vi; + const std::string nicholas = "NicholasAbercrombie"; + rc_t rc = rc_t::OK; + + /* + * Interface 1 + */ + std::string itf1_name = "host1"; + interface itf1(itf1_name, + interface::type_t::AFPACKET, + interface::admin_state_t::UP); + HW::item hw_ifh(2, rc_t::OK); + HW::item hw_as_up(interface::admin_state_t::UP, rc_t::OK); + ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh, itf1_name)); + ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh)); + TRY_CHECK_RC(OM::write(nicholas, itf1)); + + /* + * Interface 2 + */ + std::string itf2_name = "host2"; + interface itf2(itf2_name, + interface::type_t::AFPACKET, + interface::admin_state_t::UP); + + HW::item hw_ifh2(4, rc_t::OK); + ADD_EXPECT(interface_cmds::af_packet_create_cmd(hw_ifh2, itf2_name)); + ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh2)); + TRY_CHECK_RC(OM::write(nicholas, itf2)); + + l2_xconnect *l2_xconn = new l2_xconnect(itf1, itf2); + HW::item xconnect_east(true, rc_t::OK); + HW::item xconnect_west(true, rc_t::OK); + HW::item xconnect_east_unbind(false, rc_t::OK); + HW::item xconnect_west_unbind(false, rc_t::OK); + ADD_EXPECT(l2_xconnect_cmds::bind_cmd(xconnect_east, hw_ifh.data(), hw_ifh2.data())); + ADD_EXPECT(l2_xconnect_cmds::bind_cmd(xconnect_west, hw_ifh2.data(), hw_ifh.data())); + TRY_CHECK_RC(OM::write(nicholas, *l2_xconn)); + + delete l2_xconn; + + HW::item hw_as_down(interface::admin_state_t::DOWN, rc_t::OK); + STRICT_ORDER_OFF(); + ADD_EXPECT(l2_xconnect_cmds::unbind_cmd(xconnect_east_unbind, hw_ifh.data(), hw_ifh2.data())); + ADD_EXPECT(l2_xconnect_cmds::unbind_cmd(xconnect_west_unbind, hw_ifh2.data(), hw_ifh.data())); + ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh2)); + ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh2, itf2_name)); + ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_down, hw_ifh)); + ADD_EXPECT(interface_cmds::af_packet_delete_cmd(hw_ifh, itf1_name)); + + TRY_CHECK(OM::remove(nicholas)); +} + BOOST_AUTO_TEST_CASE(test_vxlan) { VppInit vi; const std::string franz = "FranzKafka"; @@ -1237,7 +1311,7 @@ BOOST_AUTO_TEST_CASE(test_arp_proxy) { ADD_EXPECT(interface_cmds::state_change_cmd(hw_as_up, hw_ifh)); TRY_CHECK_RC(OM::write(kurt, itf3)); - arp_proxy_binding *apb = new arp_proxy_binding(itf3, ap); + arp_proxy_binding *apb = new arp_proxy_binding(itf3); HW::item hw_binding(true, rc_t::OK); ADD_EXPECT(arp_proxy_binding_cmds::bind_cmd(hw_binding, hw_ifh.data())); TRY_CHECK_RC(OM::write(kurt, *apb)); @@ -1796,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 hw_hdl(4, rc_t::OK); + HW::item hw_hdl_pair(std::make_pair(5,6), rc_t::OK); + + HW::item hw_as_up(interface::admin_state_t::UP, + rc_t::OK); + HW::item 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 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 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 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()