Skip to content

Commit

Permalink
Improve bgp_stress_test teardown code
Browse files Browse the repository at this point in the history
If the XmppServer is shutdown before the agents, the agents keep
trying to connect to it continuously and keep the scheduler busy.
Instead, cleanup the agents first and then shutdown XmppServer.

Change-Id: Iea6a65c907f4dddbc5f42c787e4d3974ffd6f3b2
Partial-Bug: 1464016
  • Loading branch information
Nischal Sheth committed Jun 30, 2015
1 parent ebd7166 commit 093407c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/bgp/test/bgp_stress_test.cc
Expand Up @@ -567,18 +567,16 @@ void BgpStressTest::SetUp() {
}

void BgpStressTest::TearDown() {
AgentCleanup();
WaitForIdle();
xmpp_server_test_->Shutdown();
WaitForIdle();
if (n_agents_) {
TASK_UTIL_EXPECT_EQ(0, xmpp_server_test_->ConnectionCount());
}
AgentCleanup();
TASK_UTIL_EXPECT_EQ(0, xmpp_server_test_->ConnectionCount());
channel_manager_.reset();
WaitForIdle();

TcpServerManager::DeleteServer(xmpp_server_test_);
xmpp_server_test_ = NULL;

BOOST_FOREACH(BgpServerTest *peer_server, peer_servers_) {
if (peer_server) {
peer_server->Shutdown();
Expand All @@ -600,6 +598,10 @@ void BgpStressTest::TearDown() {
}

void BgpStressTest::AgentCleanup() {
BOOST_FOREACH(test::NetworkAgentMock *agent, xmpp_agents_) {
agent->SessionDown();
}
WaitForIdle();
BOOST_FOREACH(test::NetworkAgentMock *agent, xmpp_agents_) {
agent->Delete();
}
Expand Down

0 comments on commit 093407c

Please sign in to comment.