diff --git a/testing/indexer-test-aws/build-aws/prepare-dist.sh b/testing/indexer-test-aws/build-aws/prepare-dist.sh index f0451cabc005a3b79eb27c897c294a11fda496b0..86ce9d20889cf1ccdc4c8eac6aab83bb44738b3b 100755 --- a/testing/indexer-test-aws/build-aws/prepare-dist.sh +++ b/testing/indexer-test-aws/build-aws/prepare-dist.sh @@ -29,3 +29,5 @@ chmod +x "${INTEGRATION_TEST_OUTPUT_BIN_DIR}"/install-deps.sh mvn clean -f "$INTEGRATION_TEST_SOURCE_DIR_AWS"/pom.xml cp -R "$INTEGRATION_TEST_SOURCE_DIR_AWS"/* "${INTEGRATION_TEST_OUTPUT_DIR}"/ +#copy testing parent pom to output +cp "$INTEGRATION_TEST_SOURCE_DIR/pom.xml" "${OUTPUT_DIR}/testing" \ No newline at end of file diff --git a/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/CleanupIndiciesSteps.java b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/CleanupIndiciesSteps.java index d6324b425e2a51c858d97f513fee8a58b2f25062..b1f4377b50e9fc71d76e064b91bd716dcbc0d5dc 100644 --- a/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/CleanupIndiciesSteps.java +++ b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/CleanupIndiciesSteps.java @@ -1,16 +1,19 @@ -/* Copyright 2017-2019, Schlumberger +/* + Copyright 2020 Google LLC + Copyright 2020 EPAM Systems, Inc - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.*/ + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ package org.opengroup.osdu.common; @@ -52,7 +55,7 @@ public class CleanupIndiciesSteps extends TestsBase { super(httpClient); } - public void the_schema_is_created_with_the_following_kind(DataTable dataTable) { + public void theSchemaIsCreatedWithTheFollowingKind(DataTable dataTable) { List<Setup> inputList = dataTable.asList(Setup.class); for (Setup input : inputList) { TestIndex testIndex = getTextIndex(); @@ -71,7 +74,7 @@ public class CleanupIndiciesSteps extends TestsBase { } } - public void i_ingest_records_with_the_for_a_given(String record, String dataGroup, String kind) { + public void iIngestRecordsWithTheforAGiven(String record, String dataGroup, String kind) { String actualKind = generateActualName(kind, timeStamp); try { String fileContent = FileHandler.readFile(String.format("%s.%s", record, "json")); @@ -93,11 +96,11 @@ public class CleanupIndiciesSteps extends TestsBase { } } - public void i_check_that_the_index_for_has_been_created(String kind) throws IOException, InterruptedException { + public void iCheckThatTheIndexForHasBeenCreated(String kind) throws IOException, InterruptedException { assertTrue(isNewIndexCreated(generateActualName(kind, timeStamp))); } - public void i_should_delete_the_records_for_i_created_earlier() { + public void iShouldDeleteTheRecordsForICreatedEarlier() { List<Map<String, Object>> deletedRecords = new ArrayList<>(); if (records != null && !records.isEmpty()) { for (Map<String, Object> testRecord : records) { @@ -113,25 +116,27 @@ public class CleanupIndiciesSteps extends TestsBase { } } - public void i_should_delete_the_schema_for_i_created_earlier(String kind) { + public void iShouldDeleteTheSchemaForICreatedEarlier(String kind) { ClientResponse response = httpClient.send(HttpMethod.DELETE, String.format("%sschemas%s", getStorageBaseURL(), "/" + generateActualName(kind, timeStamp)),null, - headers, httpClient.getAccessToken()); + headers, httpClient.getAccessToken()); assertEquals(HttpStatus.SC_NO_CONTENT, response.getStatus()); } - public void i_should_check_that_the_index_for_has_not_been_deleted(String kind) throws IOException, InterruptedException { + public void iShouldCheckThetTheIndexforHasNotBeenDeleted(String kind) throws IOException, InterruptedException { assertTrue(isNewIndexExist(generateActualName(kind, timeStamp))); } - public void i_should_to_run_cleanup_of_indexes_for_and(String kind, String message) { + public void iShouldToRunCleanupOfIndexesForAnd(String kind, String message) { - ClientResponse response = httpClient.send(HttpMethod.POST, String.format("%sindex-cleanup", getIndexerBaseURL()), + String url = getIndexerBaseURL() + "index-cleanup"; + log.info("URL: " + url); + ClientResponse response = httpClient.send(HttpMethod.POST, url, convertMessageIntoJson(kind, message), headers, httpClient.getAccessToken()); assertEquals(HttpStatus.SC_OK, response.getStatus()); } - public void i_should_check_that_the_index_for_has_been_deleted(String kind) throws IOException, InterruptedException { + public void iShouldCheckThatTheIndexForHasBeenDeleted(String kind) throws IOException, InterruptedException { assertFalse(isNewIndexExist(generateActualName(kind, timeStamp))); } diff --git a/testing/indexer-test-core/src/main/java/org/opengroup/osdu/util/ElasticUtils.java b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/util/ElasticUtils.java index f6d7ac6ad5596d81e20203997cfcdb542ded04c6..4612f07cf3efd111c178ef607c6d1af2789d60dd 100644 --- a/testing/indexer-test-core/src/main/java/org/opengroup/osdu/util/ElasticUtils.java +++ b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/util/ElasticUtils.java @@ -1,3 +1,20 @@ +/* + Copyright 2020 Google LLC + Copyright 2020 EPAM Systems, Inc + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + package org.opengroup.osdu.util; import com.google.gson.Gson; @@ -298,17 +315,24 @@ public class ElasticUtils { return builder; } - public boolean isIndexExist(String index) throws IOException { + public boolean isIndexExist(String index) { boolean exists = false; try { - try (RestHighLevelClient client = this.createClient(username, password, host)) { - GetIndexRequest request = new GetIndexRequest(); - request.indices(index); - exists = client.indices().exists(request, RequestOptions.DEFAULT); - } + exists = createRestClientAndCheckIndexExist(index); } catch (ElasticsearchStatusException e) { - log.log(Level.INFO, String.format("Error getting index: %s status", index)); + log.log(Level.INFO, String.format("Error getting index: %s %s", index, e.getMessage())); } return exists; } + + private boolean createRestClientAndCheckIndexExist(String index) { + try (RestHighLevelClient client = this.createClient(username, password, host)) { + GetIndexRequest request = new GetIndexRequest(); + request.indices(index); + return client.indices().exists(request, RequestOptions.DEFAULT); + } catch (IOException e) { + log.log(Level.INFO, String.format("Error getting index: %s %s", index, e.getMessage())); + } + return false; + } } \ No newline at end of file diff --git a/testing/indexer-test-gcp/src/test/java/org/opengroup/osdu/step_definitions/index/cleanup/RunTest.java b/testing/indexer-test-gcp/src/test/java/org/opengroup/osdu/step_definitions/index/cleanup/RunTest.java index f01c141fa43122aa39e1632336bcf6530514baff..baa367cab29a6bda105b22654ee69d5850033bec 100644 --- a/testing/indexer-test-gcp/src/test/java/org/opengroup/osdu/step_definitions/index/cleanup/RunTest.java +++ b/testing/indexer-test-gcp/src/test/java/org/opengroup/osdu/step_definitions/index/cleanup/RunTest.java @@ -1,3 +1,20 @@ +/* + Copyright 2020 Google LLC + Copyright 2020 EPAM Systems, Inc + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + package org.opengroup.osdu.step_definitions.index.cleanup; import cucumber.api.CucumberOptions; diff --git a/testing/indexer-test-gcp/src/test/java/org/opengroup/osdu/step_definitions/index/cleanup/Steps.java b/testing/indexer-test-gcp/src/test/java/org/opengroup/osdu/step_definitions/index/cleanup/Steps.java index 017ca4df69ba0bf4229f76bd8d9aca489622ff7c..d40b77949c357be505521d5207e176ac4698f5fb 100644 --- a/testing/indexer-test-gcp/src/test/java/org/opengroup/osdu/step_definitions/index/cleanup/Steps.java +++ b/testing/indexer-test-gcp/src/test/java/org/opengroup/osdu/step_definitions/index/cleanup/Steps.java @@ -1,3 +1,20 @@ +/* + Copyright 2020 Google LLC + Copyright 2020 EPAM Systems, Inc + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + package org.opengroup.osdu.step_definitions.index.cleanup; import cucumber.api.DataTable; @@ -25,42 +42,42 @@ public class Steps extends CleanupIndiciesSteps { } @Given("^the schema is created with the following kind$") - public void the_schema_is_created_with_the_following_kind(DataTable dataTable) { - super.the_schema_is_created_with_the_following_kind(dataTable); + public void theSchemaIsCreatedWithTheFollowingKind(DataTable dataTable) { + super.theSchemaIsCreatedWithTheFollowingKind(dataTable); } @When("^I ingest records with the \"(.*?)\" with \"(.*?)\" for a given \"(.*?)\"$") - public void i_ingest_records_with_the_for_a_given(String record, String dataGroup, String kind) { - super.i_ingest_records_with_the_for_a_given(record, dataGroup, kind); + public void iIngestRecordsWithTheforAGiven(String record, String dataGroup, String kind) { + super.iIngestRecordsWithTheforAGiven(record, dataGroup, kind); } @Then("^I check that the index for \"(.*?)\" has been created$") - public void i_check_that_the_index_for_has_been_created(String kind) throws IOException, InterruptedException { - super.i_check_that_the_index_for_has_been_created(kind); + public void iCheckThatTheIndexForHasBeenCreated(String kind) throws IOException, InterruptedException { + super.iCheckThatTheIndexForHasBeenCreated(kind); } @Then("^I should delete the records I created earlier$") - public void i_should_delete_the_records_for_i_created_earlier() { - super.i_should_delete_the_records_for_i_created_earlier(); + public void iShouldDeleteTheRecordsForICreatedEarlier() { + super.iShouldDeleteTheRecordsForICreatedEarlier(); } @Then("^I should delete the schema for \"(.*?)\" I created earlier$") - public void i_should_delete_the_schema_for_i_created_earlier(String kind) { - super.i_should_delete_the_schema_for_i_created_earlier(kind); + public void iShouldDeleteTheSchemaForICreatedEarlier(String kind) { + super.iShouldDeleteTheSchemaForICreatedEarlier(kind); } @Then("^I should check that the index for \"(.*?)\" has not been deleted$") - public void i_should_check_that_the_index_for_has_not_been_deleted(String kind) throws IOException, InterruptedException { - super.i_should_check_that_the_index_for_has_not_been_deleted(kind); + public void iShouldCheckThetTheIndexforHasNotBeenDeleted(String kind) throws IOException, InterruptedException { + super.iShouldCheckThetTheIndexforHasNotBeenDeleted(kind); } @Then("^I should to run cleanup of indexes for \"(.*?)\" and \"(.*?)\"$") - public void i_should_to_run_cleanup_of_indexes_for_and(String kind, String message) { - super.i_should_to_run_cleanup_of_indexes_for_and(kind, message); + public void iShouldToRunCleanupOfIndexesForAnd(String kind, String message) { + super.iShouldToRunCleanupOfIndexesForAnd(kind, message); } @Then("^I should check that the index for \"(.*?)\" has been deleted$") - public void i_should_check_that_the_index_for_has_been_deleted(String kind) throws IOException, InterruptedException { - super.i_should_check_that_the_index_for_has_been_deleted(kind); + public void iShouldCheckThatTheIndexForHasBeenDeleted(String kind) throws IOException, InterruptedException { + super.iShouldCheckThatTheIndexForHasBeenDeleted(kind); } } \ No newline at end of file