Skip to content

Commit

Permalink
Merge "Fix corner case in IFMapDependencyTracker" into R2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Jul 9, 2015
2 parents 8956c04 + ed4053f commit e4af211
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
15 changes: 7 additions & 8 deletions src/bgp/test/bgp_config_listener_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,8 @@ TEST_F(BgpConfigListenerTest, IrrelevantNodeEvent) {
}

//
// Multiple node events for the same node should not cause it to get on the
// change list multiple times. However, it should get added to the node list
// multiple times per the current implementation.
// Multiple node events for same node should cause it to get on the change
// list multiple times.
//
TEST_F(BgpConfigListenerTest, DuplicateNodeEvent) {
string content = ReadFile("controller/src/bgp/testdata/config_listener_test_1.xml");
Expand All @@ -261,13 +260,13 @@ TEST_F(BgpConfigListenerTest, DuplicateNodeEvent) {
ifmap_test_util::IFMapNodeNotify(&db_, "bgp-router", id_name);
task_util::WaitForIdle();

TASK_UTIL_EXPECT_EQ(1, GetChangeListCount());
TASK_UTIL_EXPECT_EQ(2, GetChangeListCount());
TASK_UTIL_EXPECT_EQ(2, GetNodeListCount());
TASK_UTIL_EXPECT_EQ(0, GetEdgeListCount());

PerformChangeListPropagation();
TASK_UTIL_EXPECT_EQ(4, GetChangeListCount());
TASK_UTIL_EXPECT_EQ(1, GetChangeListCount("bgp-router"));
TASK_UTIL_EXPECT_EQ(5, GetChangeListCount());
TASK_UTIL_EXPECT_EQ(2, GetChangeListCount("bgp-router"));
TASK_UTIL_EXPECT_EQ(3, GetChangeListCount("bgp-peering"));

ResumeChangeListPropagation();
Expand Down Expand Up @@ -350,12 +349,12 @@ TEST_F(BgpConfigListenerTest, DeletedNodeEvent3) {
ifmap_test_util::IFMapNodeLookup(&db_, "virtual-network", "red");
TASK_UTIL_EXPECT_TRUE(node->IsDeleted());

TASK_UTIL_EXPECT_EQ(1, GetChangeListCount());
TASK_UTIL_EXPECT_EQ(2, GetChangeListCount());
TASK_UTIL_EXPECT_EQ(1, GetNodeListCount());
TASK_UTIL_EXPECT_EQ(0, GetEdgeListCount());

PerformChangeListPropagation();
TASK_UTIL_EXPECT_EQ(1, GetChangeListCount());
TASK_UTIL_EXPECT_EQ(2, GetChangeListCount());

ResumeChangeListPropagation();
TASK_UTIL_EXPECT_EQ(0, GetChangeListCount());
Expand Down
9 changes: 1 addition & 8 deletions src/ifmap/ifmap_dependency_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ void IFMapDependencyTracker::PropagateChanges() {
// list.
//
void IFMapDependencyTracker::Clear() {
vertex_list_.clear();
node_list_.clear();
edge_list_.clear();
}
Expand Down Expand Up @@ -209,15 +208,9 @@ void IFMapDependencyTracker::PropagateEdge(
}

//
// Add the IFMapNode to the change list it's not already on there.
// Add the IFMapNode to the change list.
//
void IFMapDependencyTracker::AddChangeEvent(IFMapNode *node) {
ostringstream identifier;
identifier << node->table()->Typename() << ':' << node->name();
if (vertex_list_.count(identifier.str()) > 0) {
return;
}
observer_(node);
vertex_list_.insert(identifier.str());
}

4 changes: 0 additions & 4 deletions src/ifmap/ifmap_dependency_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ class IFMapNode;
// The propagation of the NodeList and EdgeDescriptorList happens in context
// of the client task (e.g. bgp::Config) when the its requesst the ChangeList.
//
// The vertex list is used to make sure that we don't add duplicate entries to
// the ChangeList.
//
// CONCURRENCY: Not thread-safe. The class assumes that the caller ensures
// that only a single method can run at a time.
//
Expand Down Expand Up @@ -126,7 +123,6 @@ class IFMapDependencyTracker {
DBGraph *graph_;
ChangeObserver observer_;
NodeEventPolicy policy_;
std::set<std::string> vertex_list_;
EdgeDescriptorList edge_list_;
NodeList node_list_;
};
Expand Down

0 comments on commit e4af211

Please sign in to comment.