Skip to content

Commit

Permalink
Merge "Fix memory leak and failure in test_kstate. Also make test_kst…
Browse files Browse the repository at this point in the history
…ate non-flaky. Change-Id: Ie318042f04b26f08198645f5f0a75f9e6f1b84a4"
  • Loading branch information
Zuul authored and Gerrit Code Review committed Jul 30, 2014
2 parents 48ec49a + 4977398 commit 33e0886
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/vnsw/agent/kstate/test/SConscript
Expand Up @@ -12,7 +12,7 @@ AgentEnv.MakeTestEnv(env)
kstate_test_suite = []
kstate_flaky_test_suite = []

test_kstate = AgentEnv.MakeTestCmd(env, 'test_kstate', kstate_flaky_test_suite)
test_kstate = AgentEnv.MakeTestCmd(env, 'test_kstate', kstate_test_suite)
test_sandesh_kstate = AgentEnv.MakeTestCmdSrc(env, 'test_sandesh_kstate',
[
'test_sandesh_kstate.cc'
Expand Down
16 changes: 12 additions & 4 deletions src/vnsw/agent/kstate/test/test_kstate.cc
Expand Up @@ -271,11 +271,19 @@ TEST_F(KStateTest, NHGetTest) {
LOG(DEBUG, "nh count " << nh_count);

CreatePorts(0, nh_count, 0);
int count = 0;
//Two interface nexthops get created for each interface (with and without policy)
for (int i = 0; i < (MAX_TEST_FD * 2); i++) {
TestNHKState::Init(nh_count + i);
client->WaitForIdle();
client->KStateResponseWait(1);
for (int i = 0; count < (MAX_TEST_FD * 2); i++) {
uint32_t nh_id = nh_count + i;
/* Check whether nexthop-index is valid by checking it in oper db before doing
* Get from mock kernel */
NextHop *nh = Agent::GetInstance()->nexthop_table()->FindNextHop(nh_id);
if (nh) {
TestNHKState::Init(nh_id);
client->WaitForIdle();
client->KStateResponseWait(1);
count++;
}
}
DeletePorts();
}
Expand Down
4 changes: 4 additions & 0 deletions src/vnsw/agent/kstate/test/test_kstate.h
Expand Up @@ -63,6 +63,7 @@ class TestIfKState: public InterfaceKState, public TestKStateBase {
}
}
}
more_context_ = NULL;
}

void PrintIfResp(KInterfaceResp *r) {
Expand Down Expand Up @@ -132,6 +133,7 @@ class TestNHKState: public NHKState, public TestKStateBase {
}
}
}
more_context_ = NULL;
}

void PrintNHResp(KNHResp *r) {
Expand Down Expand Up @@ -200,6 +202,7 @@ class TestMplsKState: public MplsKState, public TestKStateBase {
}
}
}
more_context_ = NULL;
}

void PrintMplsResp(KMplsResp *r) {
Expand Down Expand Up @@ -267,6 +270,7 @@ class TestMirrorKState: public MirrorKState, public TestKStateBase {
}
}
}
more_context_ = NULL;
}

void PrintMirrorResp(KMirrorResp *r) {
Expand Down
8 changes: 8 additions & 0 deletions src/vnsw/agent/oper/nexthop.cc
Expand Up @@ -2100,6 +2100,14 @@ void NextHop::SetNHSandeshData(NhSandeshData &data) const {
data.set_ref_count(GetRefCount());
}

NextHop *NextHopTable::FindNextHop(size_t index) {
NextHop *nh = index_table_.At(index);
if (nh && nh->IsDeleted() != true) {
return nh;
}
return NULL;
}

bool NextHop::DBEntrySandesh(Sandesh *sresp, std::string &name) const {
NhListResp *resp = static_cast<NhListResp *>(sresp);

Expand Down

0 comments on commit 33e0886

Please sign in to comment.