Skip to content
Snippets Groups Projects
Commit 34c83a20 authored by Alok Joshi's avatar Alok Joshi
Browse files

Merge branch 'update_event' of...

Merge branch 'update_event' of https://community.opengroup.org/osdu/platform/system/indexer-service into update_event
parents ecb0b0a1 635e13be
No related branches found
No related tags found
2 merge requests!346Merge branch 'aws-integration' into 'master',!284Update kind event support
Pipeline #99459 failed
...@@ -400,7 +400,7 @@ public class IndexerServiceImpl implements IndexerService { ...@@ -400,7 +400,7 @@ public class IndexerServiceImpl implements IndexerService {
IndexRequest indexRequest = new IndexRequest(index).id(record.getId()).source(this.gson.toJson(sourceMap), XContentType.JSON); IndexRequest indexRequest = new IndexRequest(index).id(record.getId()).source(this.gson.toJson(sourceMap), XContentType.JSON);
bulkRequest.add(indexRequest); bulkRequest.add(indexRequest);
} else if (operation == OperationType.update) { } else if (operation == OperationType.update) {
UpdateRequest updateRequest = new UpdateRequest(index, record.getId()).doc(this.gson.toJson(sourceMap), XContentType.JSON).docAsUpsert(true); UpdateRequest updateRequest = new UpdateRequest(index, "_doc", record.getId()).doc(this.gson.toJson(sourceMap), XContentType.JSON).docAsUpsert(true);
bulkRequest.add(updateRequest); bulkRequest.add(updateRequest);
} }
} }
......
...@@ -90,6 +90,11 @@ public class Steps extends SchemaServiceRecordSteps { ...@@ -90,6 +90,11 @@ public class Steps extends SchemaServiceRecordSteps {
super.i_should_get_the_documents_for_the_in_the_Elastic_Search(expectedCount, index); super.i_should_get_the_documents_for_the_in_the_Elastic_Search(expectedCount, index);
} }
@Then("^I should not get any documents for the \"([^\"]*)\" in the Elastic Search$")
public void i_should_not_get_any_documents_for_the_index_in_the_Elastic_Search(String index) throws Throwable {
super.i_should_not_get_any_documents_for_the_index_in_the_Elastic_Search(index);
}
@Then("^I should get the elastic \"(.*?)\" for the \"([^\"]*)\" and \"([^\"]*)\" in the Elastic Search$") @Then("^I should get the elastic \"(.*?)\" for the \"([^\"]*)\" and \"([^\"]*)\" in the Elastic Search$")
public void i_should_get_the_elastic_for_the_tenant_testindex_timestamp_well_in_the_Elastic_Search(String expectedMapping, String kind, String index) throws Throwable { public void i_should_get_the_elastic_for_the_tenant_testindex_timestamp_well_in_the_Elastic_Search(String expectedMapping, String kind, String index) throws Throwable {
super.i_should_get_the_elastic_for_the_tenant_testindex_timestamp_well_in_the_Elastic_Search(expectedMapping, kind, index); super.i_should_get_the_elastic_for_the_tenant_testindex_timestamp_well_in_the_Elastic_Search(expectedMapping, kind, index);
......
...@@ -58,6 +58,11 @@ public class Steps extends SchemaServiceRecordSteps { ...@@ -58,6 +58,11 @@ public class Steps extends SchemaServiceRecordSteps {
super.i_should_get_the_documents_for_the_in_the_Elastic_Search(expectedCount, index); super.i_should_get_the_documents_for_the_in_the_Elastic_Search(expectedCount, index);
} }
@Then("^I should not get any documents for the \"([^\"]*)\" in the Elastic Search$")
public void i_should_not_get_any_documents_for_the_index_in_the_Elastic_Search(String index) throws Throwable {
super.i_should_not_get_any_documents_for_the_index_in_the_Elastic_Search(index);
}
@Then("^I should get the elastic \"(.*?)\" for the \"([^\"]*)\" and \"([^\"]*)\" in the Elastic Search$") @Then("^I should get the elastic \"(.*?)\" for the \"([^\"]*)\" and \"([^\"]*)\" in the Elastic Search$")
public void i_should_get_the_elastic_for_the_tenant_testindex_timestamp_well_in_the_Elastic_Search(String expectedMapping, String kind, String index) throws Throwable { public void i_should_get_the_elastic_for_the_tenant_testindex_timestamp_well_in_the_Elastic_Search(String expectedMapping, String kind, String index) throws Throwable {
super.i_should_get_the_elastic_for_the_tenant_testindex_timestamp_well_in_the_Elastic_Search(expectedMapping, kind, index); super.i_should_get_the_elastic_for_the_tenant_testindex_timestamp_well_in_the_Elastic_Search(expectedMapping, kind, index);
......
...@@ -134,6 +134,11 @@ public class RecordSteps extends TestsBase { ...@@ -134,6 +134,11 @@ public class RecordSteps extends TestsBase {
assertEquals(expectedCount, numOfIndexedDocuments); assertEquals(expectedCount, numOfIndexedDocuments);
} }
public void i_should_not_get_any_documents_for_the_index_in_the_Elastic_Search(String index) throws Throwable {
index = generateActualName(index, timeStamp);
getRecordsInIndex(index, 0);
}
public void i_should_get_the_elastic_for_the_tenant_testindex_timestamp_well_in_the_Elastic_Search(String expectedMapping, String kind, String index) throws Throwable { public void i_should_get_the_elastic_for_the_tenant_testindex_timestamp_well_in_the_Elastic_Search(String expectedMapping, String kind, String index) throws Throwable {
index = generateActualName(index, timeStamp); index = generateActualName(index, timeStamp);
Map<String, MappingMetadata> elasticMapping = elasticUtils.getMapping(index); Map<String, MappingMetadata> elasticMapping = elasticUtils.getMapping(index);
...@@ -253,6 +258,32 @@ public class RecordSteps extends TestsBase { ...@@ -253,6 +258,32 @@ public class RecordSteps extends TestsBase {
return numOfIndexedDocuments; return numOfIndexedDocuments;
} }
private long getRecordsInIndex(String index, int expectedCount) throws InterruptedException, IOException {
long numOfIndexedDocuments = 0;
int iterator;
// index.refresh_interval is set to default 30s, wait for 40s initially
Thread.sleep(40000);
for (iterator = 0; iterator < 20; iterator++) {
numOfIndexedDocuments = elasticUtils.fetchRecords(index);
if (expectedCount == numOfIndexedDocuments) {
log.info(String.format("index: %s | attempts: %s | documents acknowledged by elastic: %s", index, iterator, numOfIndexedDocuments));
break;
} else {
log.info(String.format("index: %s | documents acknowledged by elastic: %s", index, numOfIndexedDocuments));
Thread.sleep(5000);
}
if ((iterator + 1) % 5 == 0) elasticUtils.refreshIndex(index);
}
if (iterator >= 20) {
fail(String.format("index not created after waiting for %s seconds", ((40000 + iterator * 5000) / 1000)));
}
return numOfIndexedDocuments;
}
private Boolean areJsonEqual(String firstJson, String secondJson) { private Boolean areJsonEqual(String firstJson, String secondJson) {
Gson gson = new Gson(); Gson gson = new Gson();
Type mapType = new TypeToken<Map<String, Object>>() {}.getType(); Type mapType = new TypeToken<Map<String, Object>>() {}.getType();
......
...@@ -73,7 +73,7 @@ Feature: Indexing of the documents ...@@ -73,7 +73,7 @@ Feature: Indexing of the documents
Then I should get the 1 documents for the <index_v1> in the Elastic Search Then I should get the 1 documents for the <index_v1> in the Elastic Search
Then I ingest records with the <recordFile> with <acl> for a given <kind_v2> Then I ingest records with the <recordFile> with <acl> for a given <kind_v2>
Then I should get the 1 documents for the <index_v2> in the Elastic Search Then I should get the 1 documents for the <index_v2> in the Elastic Search
Then I should get the 1 documents for the <index_v1> in the Elastic Search Then I should not get any documents for the <index_v1> in the Elastic Search
Examples: Examples:
| kind_v1 | index_v1 | recordFile | acl | kind_v2 | index_v2 | | kind_v1 | index_v1 | recordFile | acl | kind_v2 | index_v2 |
......
...@@ -46,6 +46,11 @@ public class Steps extends SchemaServiceRecordSteps { ...@@ -46,6 +46,11 @@ public class Steps extends SchemaServiceRecordSteps {
super.i_should_get_the_documents_for_the_in_the_Elastic_Search(expectedCount, index); super.i_should_get_the_documents_for_the_in_the_Elastic_Search(expectedCount, index);
} }
@Then("^I should not get any documents for the \"([^\"]*)\" in the Elastic Search$")
public void i_should_not_get_any_documents_for_the_index_in_the_Elastic_Search(String index) throws Throwable {
super.i_should_not_get_any_documents_for_the_index_in_the_Elastic_Search(index);
}
@Then("^I should get the elastic \"(.*?)\" for the \"([^\"]*)\" and \"([^\"]*)\" in the Elastic Search$") @Then("^I should get the elastic \"(.*?)\" for the \"([^\"]*)\" and \"([^\"]*)\" in the Elastic Search$")
public void i_should_get_the_elastic_for_the_tenant_testindex_timestamp_well_in_the_Elastic_Search(String expectedMapping, String kind, String index) throws Throwable { public void i_should_get_the_elastic_for_the_tenant_testindex_timestamp_well_in_the_Elastic_Search(String expectedMapping, String kind, String index) throws Throwable {
super.i_should_get_the_elastic_for_the_tenant_testindex_timestamp_well_in_the_Elastic_Search(expectedMapping, kind, index); super.i_should_get_the_elastic_for_the_tenant_testindex_timestamp_well_in_the_Elastic_Search(expectedMapping, kind, index);
......
...@@ -63,6 +63,11 @@ public class Steps extends SchemaServiceRecordSteps { ...@@ -63,6 +63,11 @@ public class Steps extends SchemaServiceRecordSteps {
super.i_should_get_the_documents_for_the_in_the_Elastic_Search(expectedCount, index); super.i_should_get_the_documents_for_the_in_the_Elastic_Search(expectedCount, index);
} }
@Then("^I should not get any documents for the \"([^\"]*)\" in the Elastic Search$")
public void i_should_not_get_any_documents_for_the_index_in_the_Elastic_Search(String index) throws Throwable {
super.i_should_not_get_any_documents_for_the_index_in_the_Elastic_Search(index);
}
@Then("^I should get the elastic \"(.*?)\" for the \"([^\"]*)\" and \"([^\"]*)\" in the Elastic Search$") @Then("^I should get the elastic \"(.*?)\" for the \"([^\"]*)\" and \"([^\"]*)\" in the Elastic Search$")
public void i_should_get_the_elastic_for_the_tenant_testindex_timestamp_well_in_the_Elastic_Search(String expectedMapping, String kind, String index) throws Throwable { public void i_should_get_the_elastic_for_the_tenant_testindex_timestamp_well_in_the_Elastic_Search(String expectedMapping, String kind, String index) throws Throwable {
super.i_should_get_the_elastic_for_the_tenant_testindex_timestamp_well_in_the_Elastic_Search(expectedMapping, kind, index); super.i_should_get_the_elastic_for_the_tenant_testindex_timestamp_well_in_the_Elastic_Search(expectedMapping, kind, index);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment