diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IndexerServiceImpl.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IndexerServiceImpl.java index 88acc1aa12a805c941c2f2450c691be7bc5281ca..844b310f1e5048782cd4ab69bde83f43e6375df3 100644 --- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IndexerServiceImpl.java +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/IndexerServiceImpl.java @@ -400,7 +400,7 @@ 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) { - 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); } } diff --git a/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/step_definitions/index/record/Steps.java b/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/step_definitions/index/record/Steps.java index 898fe91989c407fd4ced01549bd5726bc58dc8fd..37dd8f26ea74440a4c9affde1844a74d4168ec0b 100644 --- a/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/step_definitions/index/record/Steps.java +++ b/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/step_definitions/index/record/Steps.java @@ -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); diff --git a/testing/indexer-test-azure/src/test/java/org/opengroup/osdu/step_definitions/index/record/Steps.java b/testing/indexer-test-azure/src/test/java/org/opengroup/osdu/step_definitions/index/record/Steps.java index 41354dfe5492f750dad653e0a1a1510db5e11ec7..ae5e82f842d377236fccbedf449f30d25167f811 100644 --- a/testing/indexer-test-azure/src/test/java/org/opengroup/osdu/step_definitions/index/record/Steps.java +++ b/testing/indexer-test-azure/src/test/java/org/opengroup/osdu/step_definitions/index/record/Steps.java @@ -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); diff --git a/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/RecordSteps.java b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/RecordSteps.java index 969c9c6ece88f270bed27a8debc1b40e8d36a798..4ab3a430f6a32a9d75232eef30b6787f54589db0 100644 --- a/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/RecordSteps.java +++ b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/RecordSteps.java @@ -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(); diff --git a/testing/indexer-test-core/src/main/resources/features/indexrecord/indexRecord-schema-service.feature b/testing/indexer-test-core/src/main/resources/features/indexrecord/indexRecord-schema-service.feature index dd2ff8cf31999323ea932b782ec3d7dbd87f16d2..d52b2aa429e49e6c54e7850e717d51b6e198aa41 100644 --- a/testing/indexer-test-core/src/main/resources/features/indexrecord/indexRecord-schema-service.feature +++ b/testing/indexer-test-core/src/main/resources/features/indexrecord/indexRecord-schema-service.feature @@ -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 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: | kind_v1 | index_v1 | recordFile | acl | kind_v2 | index_v2 | diff --git a/testing/indexer-test-gcp/src/test/java/org/opengroup/osdu/step_definitions/index/record/Steps.java b/testing/indexer-test-gcp/src/test/java/org/opengroup/osdu/step_definitions/index/record/Steps.java index 991818c68099e24165b3d35cbb017e25a65323f0..3a3cdd3cab71937ba02f1a2a05b71eca3a430f47 100644 --- a/testing/indexer-test-gcp/src/test/java/org/opengroup/osdu/step_definitions/index/record/Steps.java +++ b/testing/indexer-test-gcp/src/test/java/org/opengroup/osdu/step_definitions/index/record/Steps.java @@ -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); diff --git a/testing/indexer-test-ibm/src/test/java/org/opengroup/osdu/step_definitions/index/record/Steps.java b/testing/indexer-test-ibm/src/test/java/org/opengroup/osdu/step_definitions/index/record/Steps.java index c6c8662a1f6951d90cfafe2075c1565f74b286df..624f994deeeded56f15e7acd660e8873e7ed0518 100644 --- a/testing/indexer-test-ibm/src/test/java/org/opengroup/osdu/step_definitions/index/record/Steps.java +++ b/testing/indexer-test-ibm/src/test/java/org/opengroup/osdu/step_definitions/index/record/Steps.java @@ -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);