Skip to content

Commit

Permalink
Merge "Verify that xmpp peer is not deleted till replicated routes ar…
Browse files Browse the repository at this point in the history
…e gone" into R2.20
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Jul 16, 2015
2 parents 7a86c05 + 07fa383 commit 070f2df
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
55 changes: 55 additions & 0 deletions src/bgp/test/bgp_xmpp_inetvpn_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,61 @@ TEST_F(BgpXmppInetvpn2ControlNodeTest, SecurityGroupsDifferentAsn) {
agent_b_->SessionDown();
}

//
// Peer should not be deleted till references from replicator are gone.
//
TEST_F(BgpXmppInetvpn2ControlNodeTest, PeerDelete) {
Configure();
task_util::WaitForIdle();

// Create XMPP Agent A connected to XMPP server X.
agent_a_.reset(
new test::NetworkAgentMock(&evm_, "agent-a", xs_x_->GetPort(),
"127.0.0.1", "127.0.0.1"));
TASK_UTIL_EXPECT_TRUE(agent_a_->IsEstablished());

// Create XMPP Agent B connected to XMPP server Y.
agent_b_.reset(
new test::NetworkAgentMock(&evm_, "agent-b", xs_y_->GetPort(),
"127.0.0.2", "127.0.0.2"));
TASK_UTIL_EXPECT_TRUE(agent_b_->IsEstablished());

// Register to blue instance
agent_a_->Subscribe("blue", 1);
agent_b_->Subscribe("blue", 1);

// Add route from agent A.
stringstream route_a;
route_a << "10.1.1.1/32";
agent_a_->AddRoute("blue", route_a.str(), "192.168.1.1");
task_util::WaitForIdle();

// Verify that route showed up on agents A and B.
VerifyRouteExists(agent_a_, "blue", route_a.str(), "192.168.1.1");
VerifyRouteExists(agent_b_, "blue", route_a.str(), "192.168.1.1");

// Disable all DB partition queue processing on server X.
task_util::WaitForIdle();
bs_x_->database()->SetQueueDisable(true);

// Close the session from agent A.
agent_a_->SessionDown();

// Verify that route is deleted at agent A but not at B.
VerifyRouteNoExists(agent_a_, "blue", route_a.str());
VerifyRouteExists(agent_b_, "blue", route_a.str(), "192.168.1.1");

// Enable all DB partition queue processing on server X.
bs_x_->database()->SetQueueDisable(false);

// Verify that route is deleted at agents A and B.
VerifyRouteNoExists(agent_a_, "blue", route_a.str());
VerifyRouteNoExists(agent_b_, "blue", route_a.str());

// Close the session from agent B.
agent_b_->SessionDown();
}

class TestEnvironment : public ::testing::Environment {
virtual ~TestEnvironment() { }
virtual void SetUp() {
Expand Down
6 changes: 6 additions & 0 deletions src/db/db.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ void DB::SetGraph(const std::string &name, DBGraph *graph) {
assert(result.second);
}

void DB::SetQueueDisable(bool disable) {
for (int i = 0; i < PartitionCount(); i++) {
partitions_[i]->SetQueueDisable(disable);
}
}

void DB::Clear() {
STLDeleteElements(&tables_);
STLDeleteValues(&partitions_);
Expand Down
1 change: 1 addition & 0 deletions src/db/db.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class DB {

DBGraph *GetGraph(const std::string &name);
void SetGraph(const std::string &name, DBGraph *graph);
void SetQueueDisable(bool disable);

static int PartitionCount();
static void RegisterFactory(const std::string &prefix,
Expand Down

0 comments on commit 070f2df

Please sign in to comment.