Skip to content

Commit

Permalink
Fixes intermittent failures in ifmap tests
Browse files Browse the repository at this point in the history
1) Made changes in config_json_parser_test ServerParser16InParts to ensure that
the ref and parent dependencies are managed while feeding the configuration.
2) In config_graph_walker_test made changes to ensure that thetest passes even
when download is triggered before all configuration is processed.
3) Cosmetic changes and Debugs
Closes-Bug: 1651276

Change-Id: Ic3794c6243b69e717412b0dc624dceaee6ddb4ec
  • Loading branch information
psdsouza committed Jul 27, 2017
1 parent 08c102b commit c134579
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 45 deletions.
48 changes: 23 additions & 25 deletions src/ifmap/client/config_cassandra_client.cc
Expand Up @@ -206,7 +206,7 @@ bool ConfigCassandraClient::ReadObjUUIDTable(set<string> *uuid_list) {
// These lists are used to determine which list/map properties need to be pushed
// to the backend, they are built as columns are parsed. Once all columns are
// parsed,
// in ListMapPropReviseUpdatelist, for each property name in
// in ListMapPropReviseUpdateList, for each property name in
// candidate_list_map_properties we check it is already in the
// updated_list_map_property list, if not we proceed to find at least one stale
// list/map key value pair with the property name in the ObJUuidCache, if one is
Expand Down Expand Up @@ -255,7 +255,7 @@ bool ConfigCassandraClient::ProcessObjUUIDTableEntry(const string &uuid_key,
return false;
}

GetPartition(uuid_key)->ListMapPropReviseUpdatelist(uuid_key, context);
GetPartition(uuid_key)->ListMapPropReviseUpdateList(uuid_key, context);

// Read the context for map and list properties
if (context.updated_list_map_properties.size()) {
Expand Down Expand Up @@ -739,31 +739,29 @@ void ConfigCassandraPartition::RemoveObjReqEntry(string &uuid) {
uuid_read_set_.erase(req_it);
}

void ConfigCassandraPartition::ListMapPropReviseUpdatelist(
void ConfigCassandraPartition::ListMapPropReviseUpdateList(
const string &uuid, ConfigCassandraParseContext &context) {
if (context.candidate_list_map_properties.size()) {
for(std::set<std::string>::iterator it =
context.candidate_list_map_properties.begin();
it != context.candidate_list_map_properties.end(); it++) {
if (context.updated_list_map_properties.find(*it) !=
context.updated_list_map_properties.end()) {
continue;
}
ObjectCacheMap::iterator uuid_iter = object_cache_map_.find(uuid);
assert(uuid_iter != object_cache_map_.end());
FieldDetailMap::iterator field_iter =
uuid_iter->second.lower_bound(*it);
assert(field_iter != uuid_iter->second.end());
assert(it->compare(0, it->size() - 1, field_iter->first,
0, it->size() - 1) == 0);
while (it->compare(0, it->size() - 1, field_iter->first,
0, it->size() - 1) == 0) {
if (field_iter->second.second == false) {
context.updated_list_map_properties.insert(*it);
break;
}
field_iter++;
for (std::set<std::string>::iterator it =
context.candidate_list_map_properties.begin();
it != context.candidate_list_map_properties.end(); it++) {
if (context.updated_list_map_properties.find(*it) !=
context.updated_list_map_properties.end()) {
continue;
}
ObjectCacheMap::iterator uuid_iter = object_cache_map_.find(uuid);
assert(uuid_iter != object_cache_map_.end());
FieldDetailMap::iterator field_iter =
uuid_iter->second.lower_bound(*it);
assert(field_iter != uuid_iter->second.end());
assert(it->compare(0, it->size() - 1, field_iter->first,
0, it->size() - 1) == 0);
while (it->compare(0, it->size() - 1, field_iter->first,
0, it->size() - 1) == 0) {
if (field_iter->second.second == false) {
context.updated_list_map_properties.insert(*it);
break;
}
field_iter++;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ifmap/client/config_cassandra_client.h
Expand Up @@ -57,7 +57,7 @@ class ConfigCassandraPartition {
bool StoreKeyIfUpdated(const std::string &uuid, const std::string &key,
const std::string &value, uint64_t timestamp,
ConfigCassandraParseContext &context);
void ListMapPropReviseUpdatelist(const string &uuid,
void ListMapPropReviseUpdateList(const string &uuid,
ConfigCassandraParseContext &context);

void MarkCacheDirty(const std::string &uuid);
Expand Down
3 changes: 3 additions & 0 deletions src/ifmap/client/test/config_json_parser_test.cc
Expand Up @@ -1583,6 +1583,8 @@ TEST_F(ConfigJsonParserTest, ServerParser16InParts) {
ParseEventsJson(
"controller/src/ifmap/testdata/server_parser_test16_p1.json");
FeedEventsJson();
FeedEventsJson();
FeedEventsJson();
TASK_UTIL_EXPECT_EQ(1, vrtable->Size());
TASK_UTIL_EXPECT_EQ(1, vmtable->Size());
TASK_UTIL_EXPECT_EQ(0, gsctable->Size());
Expand All @@ -1603,6 +1605,7 @@ TEST_F(ConfigJsonParserTest, ServerParser16InParts) {

// Using datafile from test13_p2
FeedEventsJson();
FeedEventsJson();
task_util::WaitForIdle();
TASK_UTIL_EXPECT_EQ(1, gsctable->Size());
TASK_UTIL_EXPECT_EQ(1, vrtable->Size());
Expand Down
5 changes: 4 additions & 1 deletion src/ifmap/ifmap_server_table.cc
Expand Up @@ -125,6 +125,7 @@ IFMapLink *IFMapServerTable::LinkNodeAdd(IFMapNode *first, IFMapNode *second,
IFMapLinkTable *table = static_cast<IFMapLinkTable *>(
database()->FindTable("__ifmap_metadata__.0"));
assert(table != NULL);
IFMAP_DEBUG(IFMapLinkOperation, "Creating", metadata);
return table->AddLink(first, second, metadata, sequence_number, origin);
}

Expand All @@ -134,10 +135,12 @@ void IFMapServerTable::LinkNodeUpdate(IFMapLink *link, uint64_t sequence_number,
link->UpdateProperties(origin, sequence_number);
}

void IFMapServerTable::LinkNodeDelete(IFMapLink *link, const IFMapOrigin &origin) {
void IFMapServerTable::LinkNodeDelete(IFMapLink *link,
const IFMapOrigin &origin) {
IFMapLinkTable *table = static_cast<IFMapLinkTable *>(
database()->FindTable("__ifmap_metadata__.0"));
assert(table != NULL);
IFMAP_DEBUG(IFMapLinkOperation, "Deleting", link->ToString());
table->DeleteLink(link, origin);
}

Expand Down
11 changes: 8 additions & 3 deletions src/ifmap/test/ifmap_graph_walker_test.cc
Expand Up @@ -507,6 +507,7 @@ TEST_F(IFMapGraphWalkerTest, ConfigVrsub) {
// Config
ParseEventsJson("controller/src/ifmap/testdata/vr_gsc_config.json");
FeedEventsJson();
task_util::WaitForIdle();

// VR-reg
IFMapClientMock c1("gsc1:vr1");
Expand Down Expand Up @@ -542,12 +543,16 @@ TEST_F(IFMapGraphWalkerTest, VrsubConfig) {
ParseEventsJson("controller/src/ifmap/testdata/vr_gsc_config.json");
FeedEventsJson();

TASK_UTIL_EXPECT_EQ(3, c1.count());
TASK_UTIL_EXPECT_EQ(2, c1.node_count());
// Could end up sending GSC dummy entry
TASK_UTIL_EXPECT_GE(4, c1.count());
TASK_UTIL_EXPECT_LE(3, c1.count());
TASK_UTIL_EXPECT_GE(3, c1.node_count());
TASK_UTIL_EXPECT_LE(2, c1.node_count());
TASK_UTIL_EXPECT_EQ(1, c1.link_count());

TASK_UTIL_EXPECT_EQ(c1.NodeKeyCount("virtual-router"), 1);
TASK_UTIL_EXPECT_EQ(c1.NodeKeyCount("global-system-config"), 1);
TASK_UTIL_EXPECT_GE(2,c1.NodeKeyCount("global-system-config"));
TASK_UTIL_EXPECT_LE(1,c1.NodeKeyCount("global-system-config"));
TASK_UTIL_EXPECT_EQ(1, c1.LinkKeyCount("virtual-router",
"global-system-config"));
TASK_UTIL_EXPECT_TRUE(c1.LinkExists("virtual-router","global-system-config",
Expand Down
34 changes: 19 additions & 15 deletions src/ifmap/testdata/server_parser_test16_p1.json
Expand Up @@ -15,9 +15,12 @@
}
}
},
{
"operation": "pause"
},
{
"operation": "rabbit_enqueue",
"message": "{\"oper\":\"CREATE\",\"fq_name\":[\"gsc\",\"vr1\"],\"type\":\"virtual_router\",\"uuid\":\"1:8c5eeb87-0b08-4724-b53f-0a0368055374\"}",
"message": "{\"oper\":\"CREATE\",\"fq_name\":[\"gsc\",\"vr1\"],\"type\":\"virtual_router\",\"uuid\":\"2:8c5eeb87-0b08-4724-b53f-0a0368055374\"}",
"db": {
"8c5eeb87-0b08-4724-b53f-0a0368055374": {
"fq_name": "[\"gsc\",\"vr1\"]",
Expand All @@ -31,9 +34,12 @@
}
}
},
{
"operation": "pause"
},
{
"operation": "rabbit_enqueue",
"message": "{\"oper\":\"UPDATE\",\"fq_name\":\"[\\\"vm1\\\"]\",\"type\":\"virtual_machine\",\"uuid\":\"2:8c5eeb87-0b08-4725-b53f-0a0368055375\"}",
"message": "{\"oper\":\"UPDATE\",\"fq_name\":[\"vm1\"],\"type\":\"virtual_machine\",\"uuid\":\"4:8c5eeb87-0b08-4725-b53f-0a0368055375\"}",
"db": {
"8c5eeb87-0b08-4724-b53f-0a0368055374": {
"fq_name": "[\"gsc\",\"vr1\"]",
Expand All @@ -53,14 +59,13 @@
},
{
"operation": "rabbit_enqueue",
"message": "{\"oper\":\"UPDATE\",\"fq_name\":[\"gsc\",\"vr1\"],\"type\":\"virtual_router\",\"uuid\":\"4:8c5eeb87-0b08-4724-b53f-0a0368055374\"}",
"message": "{\"oper\":\"CREATE\",\"fq_name\":[\"gsc\"],\"type\":\"global_system_config\",\"uuid\":\"6:8c5eeb87-0b08-4b0c-b53f-0a036805575c\"}",
"db": {
"8c5eeb87-0b08-4724-b53f-0a0368055374": {
"fq_name": "[\"gsc\",\"vr1\"]",
"type": "\"virtual_router\"",
"ref:virtual_machine:8c5eeb87-0b08-4725-b53f-0a0368055375": "\"{\"attr\":null}\"",
"prop:id_perms": "{\"uuid\":{\"uuid_mslong\":\"10114780778358916900\",\"uuid_lslong\":\"13060168454144086900\"},\"created\":null,\"last_modified\":null}",
"parent:global_system_config:8c5eeb87-0b08-4b0c-b53f-0a036805575c": "null"
"prop:id_perms": "{\"uuid\":{\"uuid_mslong\":\"10114780778358916900\",\"uuid_lslong\":\"13060168454144086900\"},\"created\":null,\"last_modified\":null}"
},
"8c5eeb87-0b08-4725-b53f-0a0368055375": {
"fq_name": "[\"vm1\"]",
Expand All @@ -74,25 +79,24 @@
}
}
},
{
"operation": "pause"
},
{
"operation": "rabbit_enqueue",
"message": "{\"oper\":\"CREATE\",\"fq_name\":[\"gsc\"],\"type\":\"global_system_config\",\"uuid\":\"5:8c5eeb87-0b08-4b0c-b53f-0a036805575c\"}",
"message": "{\"oper\":\"UPDATE\",\"fq_name\":[\"gsc\",\"vr1\"],\"type\":\"virtual_router\",\"uuid\":\"8:8c5eeb87-0b08-4724-b53f-0a0368055374\"}",
"db": {
"8c5eeb87-0b08-4724-b53f-0a0368055374": {
"fq_name": "[\"gsc\",\"vr1\"]",
"type": "\"virtual_router\"",
"ref:virtual_machine:8c5eeb87-0b08-4725-b53f-0a0368055375": "\"{\"attr\":null}\"",
"prop:id_perms": "{\"uuid\":{\"uuid_mslong\":\"10114780778358916900\",\"uuid_lslong\":\"13060168454144086900\"},\"created\":null,\"last_modified\":null}"
"prop:id_perms": "{\"uuid\":{\"uuid_mslong\":\"10114780778358916900\",\"uuid_lslong\":\"13060168454144086900\"},\"created\":null,\"last_modified\":null}",
"parent:global_system_config:8c5eeb87-0b08-4b0c-b53f-0a036805575c": "null"
},
"8c5eeb87-0b08-4725-b53f-0a0368055375": {
"fq_name": "[\"vm1\"]",
"type": "\"virtual_machine\"",
"prop:id_perms": "{\"uuid\":{\"uuid_mslong\":\"10114780778358916901\",\"uuid_lslong\":\"13060168454144086901\"},\"created\":null,\"last_modified\":null}"
},
"8c5eeb87-0b08-4b0c-b53f-0a036805575c": {
"fq_name": "[\"gsc\"]",
"type": "\"global_system_config\"",
"prop:id_perms": "{\"uuid\":{\"uuid_mslong\":\"10114780778358917900\",\"uuid_lslong\":\"13060168454144087900\"},\"created\":null,\"last_modified\":null}"
}
}
},
Expand All @@ -101,7 +105,7 @@
},
{
"operation": "rabbit_enqueue",
"message": "{\"oper\":\"UPDATE\",\"fq_name\":[\"gsc\",\"vr1\"],\"type\":\"virtual_router\",\"uuid\":\"7:8c5eeb87-0b08-4724-b53f-0a0368055374\"}",
"message": "{\"oper\":\"UPDATE\",\"fq_name\":[\"gsc\",\"vr1\"],\"type\":\"virtual_router\",\"uuid\":\"10:8c5eeb87-0b08-4724-b53f-0a0368055374\"}",
"db": {
"8c5eeb87-0b08-4724-b53f-0a0368055374": {
"fq_name": "[\"gsc\",\"vr1\"]",
Expand All @@ -123,7 +127,7 @@
},
{
"operation": "rabbit_enqueue",
"message": "{\"oper\":\"DELETE\",\"fq_name\":\"[\\\"gsc\\\"]\",\"type\":\"global_system_config\",\"uuid\":\"8:8c5eeb87-0b08-4b0c-b53f-0a036805575c\"}",
"message": "{\"oper\":\"DELETE\",\"fq_name\":[\"gsc\"],\"type\":\"global_system_config\",\"uuid\":\"11:8c5eeb87-0b08-4b0c-b53f-0a036805575c\"}",
"db": {
"8c5eeb87-0b08-4724-b53f-0a0368055374": {
"fq_name": "[\"gsc\",\"vr1\"]",
Expand All @@ -140,7 +144,7 @@
},
{
"operation": "rabbit_enqueue",
"message": "{\"oper\":\"DELETE\",\"fq_name\":[\"gsc\",\"vr1\"],\"type\":\"virtual_router\",\"uuid\":\"9:8c5eeb87-0b08-4724-b53f-0a0368055374\"}",
"message": "{\"oper\":\"DELETE\",\"fq_name\":[\"gsc\",\"vr1\"],\"type\":\"virtual_router\",\"uuid\":\"12:8c5eeb87-0b08-4724-b53f-0a0368055374\"}",
"db": {
"8c5eeb87-0b08-4725-b53f-0a0368055375": {
"fq_name": "[\"vm1\"]",
Expand Down

0 comments on commit c134579

Please sign in to comment.