Skip to content

Commit

Permalink
Merge "Improving OVSDB client coverage"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Apr 29, 2015
2 parents 533c214 + 694eedf commit 446458b
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -440,15 +440,14 @@ class LogicalSwitchSandeshTask : public Task {
virtual ~LogicalSwitchSandeshTask() {}
virtual bool Run() {
std::vector<OvsdbLogicalSwitchEntry> lswitch;
TorAgentInit *init =
static_cast<TorAgentInit *>(Agent::GetInstance()->agent_init());
OvsdbClient *ovsdb_client = Agent::GetInstance()->ovsdb_client();
OvsdbClientSession *session;
if (ip_.empty()) {
session = init->ovsdb_client()->NextSession(NULL);
session = ovsdb_client->NextSession(NULL);
} else {
boost::system::error_code ec;
Ip4Address ip_addr = Ip4Address::from_string(ip_, ec);
session = init->ovsdb_client()->FindSession(ip_addr, port_);
session = ovsdb_client->FindSession(ip_addr, port_);
}
if (session != NULL && session->client_idl() != NULL) {
LogicalSwitchTable *table =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extern "C" {

using OVSDB::MulticastMacLocalOvsdb;
using OVSDB::MulticastMacLocalEntry;
using OVSDB::OvsdbClient;
using OVSDB::OvsdbClientSession;
using std::string;

Expand Down Expand Up @@ -126,15 +127,14 @@ class MulticastMacLocalSandeshTask : public Task {
virtual ~MulticastMacLocalSandeshTask() {}
virtual bool Run() {
std::vector<OvsdbMulticastMacLocalEntry> macs;
TorAgentInit *init =
static_cast<TorAgentInit *>(Agent::GetInstance()->agent_init());
OvsdbClient *ovsdb_client = Agent::GetInstance()->ovsdb_client();
OvsdbClientSession *session;
if (ip_.empty()) {
session = init->ovsdb_client()->NextSession(NULL);
session = ovsdb_client->NextSession(NULL);
} else {
boost::system::error_code ec;
Ip4Address ip_addr = Ip4Address::from_string(ip_, ec);
session = init->ovsdb_client()->FindSession(ip_addr, port_);
session = ovsdb_client->FindSession(ip_addr, port_);
}
if (session != NULL && session->client_idl() != NULL) {
MulticastMacLocalOvsdb *table =
Expand Down
32 changes: 32 additions & 0 deletions src/vnsw/agent/ovs_tor_agent/ovsdb_client/test/test_ovs_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "ovs_tor_agent/ovsdb_client/logical_switch_ovsdb.h"
#include "ovs_tor_agent/ovsdb_client/physical_port_ovsdb.h"
#include "ovs_tor_agent/ovsdb_client/vrf_ovsdb.h"
#include "ovs_tor_agent/ovsdb_client/vlan_port_binding_ovsdb.h"
#include "test_ovs_agent_init.h"

#include <ovsdb_types.h>
Expand Down Expand Up @@ -92,6 +93,11 @@ class OvsBaseTest : public ::testing::Test {

TEST_F(OvsBaseTest, connection) {
WAIT_FOR(100, 10000, (tcp_session_->status() == string("Established")));

OvsdbClientReq *req = new OvsdbClientReq();
req->HandleRequest();
client->WaitForIdle();
req->Release();
}

TEST_F(OvsBaseTest, physical_router) {
Expand Down Expand Up @@ -138,6 +144,32 @@ TEST_F(OvsBaseTest, VrfAuditRead) {
VrfOvsdbObject *table = tcp_session_->client_idl()->vrf_ovsdb();
VrfOvsdbEntry vrf_key(table, UuidToString(MakeUuid(1)));
WAIT_FOR(1000, 10000, (table->Find(&vrf_key) != NULL));

OvsdbLogicalSwitchReq *req = new OvsdbLogicalSwitchReq();
req->HandleRequest();
client->WaitForIdle();
req->Release();

OvsdbMulticastMacLocalReq *mcast_req = new OvsdbMulticastMacLocalReq();
mcast_req->HandleRequest();
client->WaitForIdle();
mcast_req->Release();

OvsdbUnicastMacRemoteReq *mac_req = new OvsdbUnicastMacRemoteReq();
mac_req->HandleRequest();
client->WaitForIdle();
mac_req->Release();
}

TEST_F(OvsBaseTest, VlanPortBindingAuditRead) {
VlanPortBindingTable *table = tcp_session_->client_idl()->vlan_port_table();
VlanPortBindingEntry key(table, "test-router", "ge-0/0/0", 100, "");
WAIT_FOR(1000, 10000, (table->Find(&key) != NULL));

OvsdbVlanPortBindingReq *req = new OvsdbVlanPortBindingReq();
req->HandleRequest();
client->WaitForIdle();
req->Release();
}

TEST_F(OvsBaseTest, connection_close) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ TEST_F(UnicastLocalRouteTest, UnicastLocalBasic) {
WAIT_FOR(100, 10000,
(NULL != FindUcastLocal(entry->name(), "00:00:00:00:01:01")));

OvsdbUnicastMacLocalReq *req = new OvsdbUnicastMacLocalReq();
req->HandleRequest();
client->WaitForIdle();
req->Release();

WAIT_FOR(10, 10000,
(true == del_ucast_mac_local(entry->name(),
"00:00:00:00:01:01")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ extern "C" {

using OVSDB::UnicastMacLocalOvsdb;
using OVSDB::UnicastMacLocalEntry;
using OVSDB::OvsdbClient;
using OVSDB::OvsdbClientSession;
using std::string;

Expand Down Expand Up @@ -212,15 +213,14 @@ class UnicastMacLocalSandeshTask : public Task {
virtual ~UnicastMacLocalSandeshTask() {}
virtual bool Run() {
std::vector<OvsdbUnicastMacLocalEntry> macs;
TorAgentInit *init =
static_cast<TorAgentInit *>(Agent::GetInstance()->agent_init());
OvsdbClient *ovsdb_client = Agent::GetInstance()->ovsdb_client();
OvsdbClientSession *session;
if (ip_.empty()) {
session = init->ovsdb_client()->NextSession(NULL);
session = ovsdb_client->NextSession(NULL);
} else {
boost::system::error_code ec;
Ip4Address ip_addr = Ip4Address::from_string(ip_, ec);
session = init->ovsdb_client()->FindSession(ip_addr, port_);
session = ovsdb_client->FindSession(ip_addr, port_);
}
if (session != NULL && session->client_idl() != NULL) {
UnicastMacLocalOvsdb *table =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ using OVSDB::VrfOvsdbEntry;
using OVSDB::VrfOvsdbObject;
using OVSDB::OvsdbDBEntry;
using OVSDB::OvsdbDBObject;
using OVSDB::OvsdbClient;
using OVSDB::OvsdbClientSession;

UnicastMacRemoteEntry::UnicastMacRemoteEntry(UnicastMacRemoteTable *table,
Expand Down Expand Up @@ -391,15 +392,14 @@ class UnicastMacRemoteSandeshTask : public Task {
virtual ~UnicastMacRemoteSandeshTask() {}
virtual bool Run() {
std::vector<OvsdbUnicastMacRemoteEntry> macs;
TorAgentInit *init =
static_cast<TorAgentInit *>(Agent::GetInstance()->agent_init());
OvsdbClient *ovsdb_client = Agent::GetInstance()->ovsdb_client();
OvsdbClientSession *session;
if (ip_.empty()) {
session = init->ovsdb_client()->NextSession(NULL);
session = ovsdb_client->NextSession(NULL);
} else {
boost::system::error_code ec;
Ip4Address ip_addr = Ip4Address::from_string(ip_, ec);
session = init->ovsdb_client()->FindSession(ip_addr, port_);
session = ovsdb_client->FindSession(ip_addr, port_);
}
if (session != NULL && session->client_idl() != NULL) {
VrfOvsdbObject *vrf_obj = session->client_idl()->vrf_ovsdb();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ using OVSDB::VlanPortBindingTable;
using OVSDB::PhysicalSwitchEntry;
using OVSDB::PhysicalPortEntry;
using OVSDB::LogicalSwitchEntry;
using OVSDB::OvsdbClient;
using OVSDB::OvsdbClientSession;

VlanPortBindingEntry::VlanPortBindingEntry(VlanPortBindingTable *table,
Expand Down Expand Up @@ -311,15 +312,14 @@ class VlanPortBindingSandeshTask : public Task {
virtual ~VlanPortBindingSandeshTask() {}
virtual bool Run() {
std::vector<OvsdbVlanPortBindingEntry> bindings;
TorAgentInit *init =
static_cast<TorAgentInit *>(Agent::GetInstance()->agent_init());
OvsdbClient *ovsdb_client = Agent::GetInstance()->ovsdb_client();
OvsdbClientSession *session;
if (ip_.empty()) {
session = init->ovsdb_client()->NextSession(NULL);
session = ovsdb_client->NextSession(NULL);
} else {
boost::system::error_code ec;
Ip4Address ip_addr = Ip4Address::from_string(ip_, ec);
session = init->ovsdb_client()->FindSession(ip_addr, port_);
session = ovsdb_client->FindSession(ip_addr, port_);
}
if (session != NULL && session->client_idl() != NULL) {
VlanPortBindingTable *table =
Expand Down

0 comments on commit 446458b

Please sign in to comment.