Skip to content
Snippets Groups Projects
Commit 914a0049 authored by Rustam Lotsmanenko (EPAM)'s avatar Rustam Lotsmanenko (EPAM)
Browse files

undo test-core index deletion changes & records steps

parent 980ea3a8
No related branches found
No related tags found
1 merge request!142Array of Objects support by Indexer (GONRG-2028)
Pipeline #37363 failed
......@@ -151,26 +151,23 @@ public class RecordSteps extends TestsBase {
public void i_should_get_the_documents_for_the_in_the_Elastic_Search_by_geoQuery (
int expectedNumber, String index, Double topLatitude, Double topLongitude, Double bottomLatitude, Double bottomLongitude, String field) throws Throwable {
index = generateActualName(index, timeStamp);
String actualName = generateActualName(index, timeStamp);
long numOfIndexedDocuments = createIndex(actualName);
long actualNumberOfRecords = elasticUtils.fetchRecordsByBoundingBoxQuery(actualName, field, topLatitude, topLongitude, bottomLatitude, bottomLongitude);
long numOfIndexedDocuments = createIndex(index);
long actualNumberOfRecords = elasticUtils.fetchRecordsByBoundingBoxQuery(index, field, topLatitude, topLongitude, bottomLatitude, bottomLongitude);
assertEquals(expectedNumber, actualNumberOfRecords);
}
public void i_should_get_the_documents_for_the_in_the_Elastic_Search_by_nestedQuery(
int expectedNumber, String index, String path, String firstNestedField, String firstNestedValue, String secondNestedField, String secondNestedValue)
throws Exception {
String actualName = generateActualName(index, timeStamp);
long numOfIndexedDocuments = createIndex(actualName);
long actualNumberOfRecords = elasticUtils.fetchRecordsByNestedQuery(actualName, path, firstNestedField, firstNestedValue, secondNestedField, secondNestedValue);
long numOfIndexedDocuments = createIndex(index);
long actualNumberOfRecords = elasticUtils.fetchRecordsByNestedQuery(index, path, firstNestedField, firstNestedValue, secondNestedField, secondNestedValue);
assertEquals(expectedNumber, actualNumberOfRecords);
}
public void i_should_be_able_search_documents_for_the_by_flattened_inner_properties(int expectedCount, String index, String flattenedField,
String flattenedFieldValue) throws IOException, InterruptedException {
String actualName = generateActualName(index, timeStamp);
long numOfIndexedDocuments = createIndex(actualName);
long actualNumberOfRecords = elasticUtils.fetchRecordsWithFlattenedFieldsQuery(actualName, flattenedField, flattenedFieldValue);
long numOfIndexedDocuments = createIndex(index);
long actualNumberOfRecords = elasticUtils.fetchRecordsWithFlattenedFieldsQuery(index, flattenedField, flattenedFieldValue);
assertEquals(expectedCount, actualNumberOfRecords);
}
......
package org.opengroup.osdu.common;
import cucumber.api.DataTable;
import java.util.List;
import java.util.Map;
import lombok.extern.java.Log;
import org.opengroup.osdu.models.Setup;
import org.opengroup.osdu.models.schema.PersistentSchemaTestIndex;
import org.opengroup.osdu.util.ElasticUtils;
import org.opengroup.osdu.util.HTTPClient;
import org.opengroup.osdu.util.IndexerClientUtil;
@Log
public class SchemaServiceRecordSteps extends RecordSteps {
import java.util.List;
import java.util.Map;
private IndexerClientUtil indexerClient;
public class SchemaServiceRecordSteps extends RecordSteps {
public SchemaServiceRecordSteps(HTTPClient httpClient, ElasticUtils elasticUtils) {
super(httpClient, elasticUtils);
indexerClient = new IndexerClientUtil(this.httpClient);
}
public void the_schema_is_created_with_the_following_kind(DataTable dataTable) {
List<Setup> inputList = dataTable.asList(Setup.class);
inputList.forEach(this::createSchema);
inputList.forEach(s -> deleteIndex(generateActualNameWithoutTs(s.getKind())));
inputList.forEach(s -> deleteIndex(generateActualNameWithoutTs(s.getIndex())));
super.addShutDownHook();
}
......@@ -38,8 +33,8 @@ public class SchemaServiceRecordSteps extends RecordSteps {
super.getInputIndexMap().put(testIndex.getKind(), testIndex);
}
private void deleteIndex(String kind) {
indexerClient.deleteIndex(kind);
private void deleteIndex(String index) {
this.elasticUtils.deleteIndex(index);
}
@Override
......
......@@ -19,7 +19,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Logger;
import org.opengroup.osdu.util.IndexerClientUtil;
import static org.junit.Assert.assertEquals;
import static org.opengroup.osdu.util.Config.*;
......@@ -39,7 +38,6 @@ public class TestIndex {
private HTTPClient httpClient;
private Map<String, String> headers;
private ElasticUtils elasticUtils;
protected IndexerClientUtil indexerClient;
private Gson gson = new Gson();
public TestIndex(ElasticUtils elasticUtils){
......@@ -49,7 +47,6 @@ public class TestIndex {
public void setHttpClient(HTTPClient httpClient) {
this.httpClient = httpClient;
headers = httpClient.getCommonHeader();
indexerClient = new IndexerClientUtil(this.httpClient);
}
public void setupIndex() {
......@@ -76,7 +73,7 @@ public class TestIndex {
}
public void cleanupIndex() {
this.indexerClient.deleteIndex(kind);
this.elasticUtils.deleteIndex(index);
}
private String getRecordFile() {
......
......@@ -11,6 +11,7 @@ import lombok.extern.java.Log;
import org.opengroup.osdu.common.SchemaServiceRecordSteps;
import org.opengroup.osdu.util.ElasticUtils;
import org.opengroup.osdu.util.GCPHTTPClient;
import org.opengroup.osdu.util.GcpElasticUtils;
@Log
public class Steps extends SchemaServiceRecordSteps {
......@@ -23,6 +24,7 @@ public class Steps extends SchemaServiceRecordSteps {
public void before(Scenario scenario) {
this.scenario = scenario;
this.httpClient = new GCPHTTPClient();
this.elasticUtils = new GcpElasticUtils(this.httpClient);
}
@Given("^the schema is created with the following kind$")
......@@ -41,39 +43,41 @@ public class Steps extends SchemaServiceRecordSteps {
}
@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 type, String index) throws Throwable {
public void i_should_get_the_elastic_for_the_tenant_testindex_timestamp_well_in_the_Elastic_Search(String expectedMapping, String type, String index)
throws Throwable {
super.i_should_get_the_elastic_for_the_tenant_testindex_timestamp_well_in_the_Elastic_Search(expectedMapping, type, index);
}
@Then("^I should get the (\\d+) documents for the \"([^\"]*)\" in the Elastic Search with out \"(.*?)\"$")
public void iShouldGetTheNumberDocumentsForTheIndexInTheElasticSearchWithOutSkippedAttribute(int expectedCount, String index, String skippedAttributes) throws Throwable {
public void iShouldGetTheNumberDocumentsForTheIndexInTheElasticSearchWithOutSkippedAttribute(int expectedCount, String index, String skippedAttributes)
throws Throwable {
super.iShouldGetTheNumberDocumentsForTheIndexInTheElasticSearchWithOutSkippedAttribute(expectedCount, index, skippedAttributes);
}
//TODO fix tags step
// @Then("^I should be able to search (\\d+) record with index \"([^\"]*)\" by tag \"([^\"]*)\" and value \"([^\"]*)\"$")
// public void iShouldBeAbleToSearchRecordByTagKeyAndTagValue(int expectedNumber, String index, String tagKey, String tagValue) throws Throwable {
// super.iShouldBeAbleToSearchRecordByTagKeyAndTagValue(index, tagKey, tagValue, expectedNumber);
// }
//
@Then("^I should be able search (\\d+) documents for the \"([^\"]*)\" by bounding box query with points \\((-?\\d+), (-?\\d+)\\) and \\((-?\\d+), (-?\\d+)\\) on field \"([^\"]*)\"$")
public void i_should_get_the_documents_for_the_in_the_Elastic_Search_by_geoQuery(
int expectedCount, String index, Double topLatitude, Double topLongitude, Double bottomLatitude, Double bottomLongitude, String field) throws Throwable {
super.i_should_get_the_documents_for_the_in_the_Elastic_Search_by_geoQuery(expectedCount, index, topLatitude, topLongitude, bottomLatitude, bottomLongitude, field);
int expectedCount, String index, Double topLatitude, Double topLongitude, Double bottomLatitude, Double bottomLongitude, String field)
throws Throwable {
String actualName = generateActualName(index, null);
super.i_should_get_the_documents_for_the_in_the_Elastic_Search_by_geoQuery(expectedCount, actualName, topLatitude, topLongitude, bottomLatitude,
bottomLongitude, field);
}
@Then("^I should be able search (\\d+) documents for the \"([^\"]*)\" by nested \"([^\"]*)\" and properties \\(\"([^\"]*)\", (\\d+)\\) and \\(\"([^\"]*)\", \"([^\"]*)\"\\)$")
public void i_should_get_the_documents_for_the_in_the_Elastic_Search_by_nestedQuery(
int expectedCount, String index, String path, String firstNestedProperty, String firstNestedValue, String secondNestedProperty,
String secondNestedValue) throws Exception {
super.i_should_get_the_documents_for_the_in_the_Elastic_Search_by_nestedQuery(expectedCount, index, path, firstNestedProperty, firstNestedValue,
String actualName = generateActualName(index, null);
super.i_should_get_the_documents_for_the_in_the_Elastic_Search_by_nestedQuery(expectedCount, actualName, path, firstNestedProperty, firstNestedValue,
secondNestedProperty, secondNestedValue);
}
@Then("^I should be able search (\\d+) documents for the \"([^\"]*)\" by flattened inner properties \\(\"([^\"]*)\", \"([^\"]*)\"\\)$")
public void i_should_be_able_search_documents_for_the_by_flattened_inner_properties(int expectedCount, String index, String flattenedField, String flattenedFieldValue)
public void i_should_be_able_search_documents_for_the_by_flattened_inner_properties(int expectedCount, String index, String flattenedField,
String flattenedFieldValue)
throws IOException, InterruptedException {
super.i_should_be_able_search_documents_for_the_by_flattened_inner_properties(expectedCount,index,flattenedField,flattenedFieldValue);
String actualName = generateActualName(index, null);
super.i_should_be_able_search_documents_for_the_by_flattened_inner_properties(expectedCount, actualName, flattenedField, flattenedFieldValue);
}
}
\ No newline at end of file
package org.opengroup.osdu.util;
public class GcpElasticUtils extends ElasticUtils {
private IndexerClientUtil indexerClientUtil;
public GcpElasticUtils(HTTPClient httpClient) {
super();
this.indexerClientUtil = new IndexerClientUtil(httpClient);
}
@Override
public void deleteIndex(String index) {
indexerClientUtil.deleteIndex(convertIndexToKindName(index));
}
private String convertIndexToKindName(String index) {
return index.replaceAll("-",":");
}
}
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