Commit 635e13be authored by neelesh thakur's avatar neelesh thakur
Browse files

fix integration test

parent 8cd63cc8
Pipeline #99416 failed with stages
in 64 minutes and 50 seconds
......@@ -400,7 +400,6 @@ public class IndexerServiceImpl implements IndexerService {
IndexRequest indexRequest = new IndexRequest(index).id(record.getId()).source(this.gson.toJson(sourceMap), XContentType.JSON);
bulkRequest.add(indexRequest);
} else if (operation == OperationType.update) {
jaxRsDpsLog.info("Updating record: "+record.getId());
UpdateRequest updateRequest = new UpdateRequest(index, "_doc", record.getId()).doc(this.gson.toJson(sourceMap), XContentType.JSON).docAsUpsert(true);
bulkRequest.add(updateRequest);
}
......
......@@ -90,6 +90,11 @@ public class Steps extends SchemaServiceRecordSteps {
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$")
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);
......
......@@ -58,6 +58,11 @@ public class Steps extends SchemaServiceRecordSteps {
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$")
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);
......
......@@ -134,6 +134,11 @@ public class RecordSteps extends TestsBase {
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 {
index = generateActualName(index, timeStamp);
Map<String, MappingMetadata> elasticMapping = elasticUtils.getMapping(index);
......@@ -253,6 +258,32 @@ public class RecordSteps extends TestsBase {
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) {
Gson gson = new Gson();
Type mapType = new TypeToken<Map<String, Object>>() {}.getType();
......
......@@ -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 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 0 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:
| kind_v1 | index_v1 | recordFile | acl | kind_v2 | index_v2 |
......
......@@ -46,6 +46,11 @@ public class Steps extends SchemaServiceRecordSteps {
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$")
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);
......
......@@ -63,6 +63,11 @@ public class Steps extends SchemaServiceRecordSteps {
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$")
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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment