diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5795c42a204db5c396d8d56ea5c5ff4f374225b3..d3241259bf8c03c01e6a959ea87e032e6194ad3c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -28,6 +28,7 @@ variables: AZURE_BUILD_SUBDIR: provider/search-azure AZURE_TEST_SUBDIR: testing/integration-tests/search-test-azure SERVICE_JAVA_VERSION: "17" + ACCEPTANCE_TEST_DIR: "search-acceptance-test" include: - project: "osdu/platform/ci-cd-pipelines" diff --git a/devops/core-plus/pipeline/override-stages.yml b/devops/core-plus/pipeline/override-stages.yml index 52a5577c4f55125eed8b5b981264780e563f2a62..aa98aed37e97694bac7a74be9a9428ca2285a35b 100644 --- a/devops/core-plus/pipeline/override-stages.yml +++ b/devops/core-plus/pipeline/override-stages.yml @@ -7,3 +7,8 @@ core-test: variables: DEFAULT_DATA_PARTITION_ID_TENANT2: non-exist CUCUMBER_OPTIONS: "--tags ~@autocomplete" + +core-acceptance-test: + variables: + DEFAULT_DATA_PARTITION_ID_TENANT2: non-exist + CUCUMBER_OPTIONS: "--tags @default,@health,@SpatialLongitudeStandardRange" diff --git a/search-acceptance-test/docs/README.md b/search-acceptance-test/docs/README.md new file mode 100644 index 0000000000000000000000000000000000000000..411a5ea25af2c4e892474569e888b27419807b8b --- /dev/null +++ b/search-acceptance-test/docs/README.md @@ -0,0 +1,75 @@ +### Running Acceptance Tests + +You will need to have the following environment variables defined. + +| name | value | description | sensitive? | source | +|--------------------------------------|--------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------|--------| +| `HOST` | eg `https://osdu.core-dev.gcp.gnrg-osdu.projects.epam.com` | - | no | - | +| `SEARCH_HOST` | eg `https://osdu.core-dev.gcp.gnrg-osdu.projects.epam.com/api/search/v2/` | - | no | - | +| `STORAGE_HOST` | eg `https://osdu.core-dev.gcp.gnrg-osdu.projects.epam.com/api/storage/v2/` | - | no | - | +| `INDEXER_HOST` | eg `https://osdu.core-dev.gcp.gnrg-osdu.projects.epam.com/api/indexer/v2/` | - | no | - | +| `DEFAULT_DATA_PARTITION_ID_TENANT1` | eg `osdu` | Partition Id used for testing | no | - | +| `DEFAULT_DATA_PARTITION_ID_TENANT2` | eg `non-exist` | | no | - | +| `ENTITLEMENTS_DOMAIN` | eg `group` | | no | - | +| `GROUP_ID` | eg `group` | | no | - | +| `LEGAL_TAG` | eg `osdu-demo-legaltag` | | no | - | +| `OTHER_RELEVANT_DATA_COUNTRIES` | eg `US` | | no | - | + + +Authentication can be provided as OIDC config: + +| name | value | description | sensitive? | source | +|-------------------------------------------------|-----------------------------------------|-------------------------------|------------|--------| +| `PRIVILEGED_USER_OPENID_PROVIDER_CLIENT_ID` | `********` | PRIVILEGED_USER Client Id | yes | - | +| `PRIVILEGED_USER_OPENID_PROVIDER_CLIENT_SECRET` | `********` | PRIVILEGED_USER Client secret | yes | - | +| `TEST_OPENID_PROVIDER_URL` | `https://keycloak.com/auth/realms/osdu` | OpenID provider url | yes | - | + +Or tokens can be used directly from env variables: + +| name | value | description | sensitive? | source | +|-------------------------|------------|-----------------------|------------|--------| +| `PRIVILEGED_USER_TOKEN` | `********` | PRIVILEGED_USER_TOKEN Token | yes | - | + + +**Entitlements configuration for integration accounts** + +| PRIVILEGED_USER | +|---------------------------------------------------------------------------------------------------------------------------------------------------| +| users<br/>service.entitlements.user<br/>service.search.user<br/>data.test1<br/>data.integration.test<br/>users@{tenant1}@{groupId}.com | + + +Execute following command to build code and run all the integration tests: + +```bash +# Note: this assumes that the environment variables for integration tests as outlined +# above are already exported in your environment. +$ (cd search-acceptance-test && mvn clean test) +``` + +**Cucumber Tagging Scenarios** + +Tags being covered in acceptance test: +| Cucumber Tag | Covered | +|--------------------------------|--------| +| @default <br/> @health <br/> @autocomplete | YES | +| @xcollab | NO | + +## License + +Copyright © Google LLC + +Copyright © EPAM Systems + +Copyright © ExxonMobil + +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. diff --git a/search-acceptance-test/pom.xml b/search-acceptance-test/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..275cdc599e822031c72ae087d9f23799368a7248 --- /dev/null +++ b/search-acceptance-test/pom.xml @@ -0,0 +1,197 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.opengroup.osdu.search</groupId> + <artifactId>search-acceptance-test</artifactId> + <version>0.28.0-SNAPSHOT</version> + <packaging>jar</packaging> + + <properties> + <maven.compiler.target>17</maven.compiler.target> + <maven.compiler.source>17</maven.compiler.source> + <cucumber.version>1.2.5</cucumber.version> + <osdu.oscorecommon.version>0.27.2</osdu.oscorecommon.version> + <jackson-databind.version>2.15.2</jackson-databind.version> + <jackson.version>2.15.2</jackson.version> + <maven-surefire-plugin.version>3.2.5</maven-surefire-plugin.version> + <argLine> + --add-opens=java.base/java.util=ALL-UNNAMED + --add-opens java.base/java.lang=ALL-UNNAMED + --add-opens java.base/java.lang.reflect=ALL-UNNAMED + --add-opens java.base/java.text=ALL-UNNAMED + --add-opens java.desktop/java.awt.font=ALL-UNNAMED + </argLine> + </properties> + + <dependencies> + <dependency> + <groupId>org.opengroup.osdu</groupId> + <artifactId>os-core-common</artifactId> + <version>${osdu.oscorecommon.version}</version> + </dependency> + + <dependency> + <groupId>com.google.api-client</groupId> + <artifactId>google-api-client</artifactId> + <version>1.28.0</version> + <exclusions> + <exclusion> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-core</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>com.nimbusds</groupId> + <artifactId>oauth2-oidc-sdk</artifactId> + <version>9.15</version> + </dependency> + + <!-- Cucumber --> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.13.2</version> + </dependency> + <dependency> + <groupId>info.cukes</groupId> + <artifactId>cucumber-java</artifactId> + <version>${cucumber.version}</version> + </dependency> + <dependency> + <groupId>info.cukes</groupId> + <artifactId>cucumber-junit</artifactId> + <version>${cucumber.version}</version> + </dependency> + + <!-- Gson: Java to Json conversion --> + <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + <version>2.9.1</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.jaxrs</groupId> + <artifactId>jackson-jaxrs-json-provider</artifactId> + <version>2.15.2</version> + </dependency> + + <dependency> + <groupId>org.glassfish</groupId> + <artifactId>javax.json</artifactId> + <version>1.1.4</version> + </dependency> + <dependency> + <groupId>com.sun.jersey</groupId> + <artifactId>jersey-client</artifactId> + <version>1.19.4</version> + </dependency> + + <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + <version>1.18.26</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>2.6</version> + </dependency> + + <!--Logging--> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-to-slf4j</artifactId> + <version>2.11.2</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>1.7.30</version> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <version>1.2.3</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-core</artifactId> + <version>1.2.3</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + <version>27.1-jre</version> + </dependency> + + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-core</artifactId> + <version>${jackson.version}</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + <version>${jackson-databind.version}</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-annotations</artifactId> + <version>${jackson.version}</version> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>${maven-surefire-plugin.version}</version> + </plugin> + </plugins> + </build> + <repositories> + <repository> + <id>${repo.releases.id}</id> + <url>${repo.releases.url}</url> + </repository> + </repositories> + + <distributionManagement> + <repository> + <id>${publish.releases.id}</id> + <url>${publish.releases.url}</url> + </repository> + <snapshotRepository> + <id>${publish.snapshots.id}</id> + <url>${publish.snapshots.url}</url> + </snapshotRepository> + </distributionManagement> + <profiles> + <profile> + <id>Default</id> + <activation> + <property> + <name>!repo.releases.id</name> + </property> + </activation> + <properties> + <repo.releases.id>community-maven-repo</repo.releases.id> + <publish.snapshots.id>community-maven-via-job-token</publish.snapshots.id> + <publish.releases.id>community-maven-via-job-token</publish.releases.id> + <repo.releases.url> + https://community.opengroup.org/api/v4/groups/17/-/packages/maven</repo.releases.url> + <publish.snapshots.url> + https://community.opengroup.org/api/v4/projects/44/packages/maven</publish.snapshots.url> + <publish.releases.url> + https://community.opengroup.org/api/v4/projects/44/packages/maven</publish.releases.url> + </properties> + </profile> + </profiles> +</project> diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/common/InfoBase.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/common/InfoBase.java new file mode 100644 index 0000000000000000000000000000000000000000..95cb5c5ddca318b093eaa8c7886108be787f9065 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/common/InfoBase.java @@ -0,0 +1,50 @@ +package org.opengroup.osdu.common; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.opengroup.osdu.response.InfoResponseMock; +import org.opengroup.osdu.util.Config; +import org.opengroup.osdu.util.HTTPClient; + +public class InfoBase extends TestsBase { + + private InfoResponseMock response; + + public InfoBase(HTTPClient httpClient) { + super(httpClient); + } + + @Override + protected String getApi() { + return Config.getSearchBaseURL() + "info"; + } + + @Override + protected String getHttpMethod() { + return "GET"; + } + + public void i_send_get_request_to_version_info_endpoint() { + response = + executeQuery("", headers, httpClient.getAccessToken(), InfoResponseMock.class); + } + + public void i_send_get_request_to_version_info_endpoint_with_trailing_slash() { + String api = getApi(); + if(!api.endsWith("/")) api += "/"; + response = + executeQuery(api, "", headers, httpClient.getAccessToken(), InfoResponseMock.class); + } + + public void i_should_get_version_info_in_response() { + assertEquals(200, response.getResponseCode()); + assertNotNull(response.getGroupId()); + assertNotNull(response.getArtifactId()); + assertNotNull(response.getVersion()); + assertNotNull(response.getBuildTime()); + assertNotNull(response.getBranch()); + assertNotNull(response.getCommitId()); + assertNotNull(response.getCommitMessage()); + } +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/common/QueryBase.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/common/QueryBase.java new file mode 100644 index 0000000000000000000000000000000000000000..1bf8d4c54155ae6e5a9e4409c4bbdd4ddec79f41 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/common/QueryBase.java @@ -0,0 +1,174 @@ +package org.opengroup.osdu.common; + +import com.google.gson.Gson; +import org.opengroup.osdu.core.common.model.search.SortQuery; +import org.opengroup.osdu.request.Query; +import org.opengroup.osdu.response.ErrorResponseMock; +import org.opengroup.osdu.response.ResponseMock; +import org.opengroup.osdu.util.Config; +import org.opengroup.osdu.util.HTTPClient; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import static org.junit.Assert.*; + +public class QueryBase extends TestsBase { + + private Query requestQuery = new Query(); + + public QueryBase(HTTPClient httpClient) { + super(httpClient); + } + + @Override + protected String getApi() { + return Config.getSearchBaseURL() + "query"; + } + + @Override + protected String getHttpMethod() { + return "POST"; + } + + public void i_limit_the_count_of_returned_results_to(int limit) { + requestQuery.setLimit(limit); + } + + public void i_send_None_with(String kind) { + String actualKind = generateActualName(kind, timeStamp); + System.out.println("Kind while searching data is: "+actualKind); + requestQuery.setKind(actualKind); + } + + public void i_send_with(String query, String kind) { + requestQuery.setQuery(query); + requestQuery.setKind(generateActualName(kind, timeStamp)); + } + + public void i_send_with_multi_kinds(String query, int number, String kind) { + requestQuery.setQuery(query); + String actualKind = generateActualName(kind, timeStamp); + StringBuilder builder = new StringBuilder(); + for(int i = 0; i < number; i++) { + if(builder.length() > 0) { + builder.append(","); + } + builder.append(actualKind); + } + requestQuery.setKind(builder.toString()); + } + + public void i_set_the_fields_I_want_in_response_as(List<String> returnedFileds) { + if(returnedFileds.contains("NULL")) requestQuery.setReturnedFields(null); + else if (!returnedFileds.contains("All")) requestQuery.setReturnedFields(returnedFileds); + } + + public void i_set_autocomplete_phrase(String autocompletePhrase) { + requestQuery.setSuggestPhrase(autocompletePhrase); + } + + public void i_apply_geographical_query_on_field(String field) { + spatialFilter.setField(field); + requestQuery.setSpatialFilter(spatialFilter); + } + + public void i_should_get_in_response_records(int resultCount) { + String payload = requestQuery.toString(); + ResponseMock response = executeQuery(payload, headers, httpClient.getAccessToken(), ResponseMock.class); + assertEquals(200, response.getResponseCode()); + assertEquals(resultCount, response.getResults().size()); + } + + public void i_should_get_following_autocomplete_suggestions(String autocompleteOptions) { + String payload = requestQuery.toString(); + ResponseMock response = executeQuery(payload, headers, httpClient.getAccessToken(), ResponseMock.class); + assertEquals(200, response.getResponseCode()); + assertEquals(Arrays.asList(autocompleteOptions.split(",")), response.getPhraseSuggestions()); + } + + public void i_should_get_in_response_records_using_search_as_mode(int resultCount) { + String payload = requestQuery.toString(); + ResponseMock response = executeQuery(payload, headers, httpClient.getAccessToken(), ResponseMock.class); + assertEquals(200, response.getResponseCode()); + assertEquals(resultCount, response.getResults().size()); + } + + public void i_should_get_in_response_records(int resultCount, List<String> returnedFields) { + String payload = requestQuery.toString(); + ResponseMock response = executeQuery(payload, headers, httpClient.getAccessToken(), ResponseMock.class); + assertEquals(200, response.getResponseCode()); + assertEquals(resultCount, response.getResults().size()); + + if(returnedFields.contains("NULL") || returnedFields.contains("All")) { return; } + + for (Map<String, Object> results: response.getResults()) { + assertTrue(results.keySet().containsAll(returnedFields)); + } + } + + public void i_should_get_response_with_reason_message_and_errors(List<Integer> codes, String type, String msg, + String error) { + String payload = requestQuery.toString(); + ErrorResponseMock response = executeQuery(payload, headers, httpClient.getAccessToken(), ErrorResponseMock.class); + if (response.getErrors() != null) { + assertEquals(generateActualName(error, timeStamp), response.getErrors().get(0)); + } + assertEquals(type, response.getReason()); + assertEquals(msg, response.getMessage()); + assertTrue(codes.contains(response.getResponseCode())); + } + + public void i_set_the_offset_of_starting_point_as(int offset) { + requestQuery.setOffset(offset); + } + + public void i_sort_with(String sortJson) { + SortQuery sortArg = (new Gson()).fromJson(sortJson, SortQuery.class); + requestQuery.setSort(sortArg); + } + + public void i_aggregate_by(String aggField) throws Throwable { + requestQuery.setAggregateBy(aggField); + } + + public void i_search_as(String isOwner) { + requestQuery.setQueryAsOwner(Boolean.parseBoolean(isOwner)); + } + + public void i_should_get_records_in_right_order(String firstRecId, String lastRecId) { + String actualFirstId = generateActualName(firstRecId,timeStamp); + String actualLastId = generateActualName(lastRecId,timeStamp); + String payload = requestQuery.toString(); + ResponseMock response = executeQuery(payload, headers, httpClient.getAccessToken(), ResponseMock.class); + assertEquals(200, response.getResponseCode()); + assertNotNull(response.getResults()); + assertTrue(response.getResults().size() > 0); + assertEquals(actualFirstId, response.getResults().get(0).get("id").toString()); + assertEquals(actualLastId, response.getResults().get(response.getResults().size()-1).get("id").toString()); + } + + public void i_should_get_aggregation_with_unique_values(int uniqueValueCount) { + String payload = requestQuery.toString(); + ResponseMock response = executeQuery(payload, headers, httpClient.getAccessToken(), ResponseMock.class); + assertEquals(200, response.getResponseCode()); + assertEquals(uniqueValueCount, response.getAggregations().size()); + assertEquals(0, response.getAggregations().stream().filter(x -> x == null).count()); + } + + public void i_should_get_included_kinds_and_should_not_get_excluded_kinds_from_aggregation(String includedKinds, String excludedKinds) { + String payload = requestQuery.toString(); + ResponseMock response = executeQuery(payload, headers, httpClient.getAccessToken(), ResponseMock.class); + assertEquals(200, response.getResponseCode()); + Set<String> kinds = response.getAggregations().stream().map(agg -> agg.getKey()).collect(Collectors.toSet()); + for(String kind: generateActualName(includedKinds, timeStamp).split(",")) { + assertTrue(kinds.contains(kind)); + } + for(String kind: generateActualName(excludedKinds, timeStamp).split(",")) { + assertFalse(kinds.contains(kind)); + } + } +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/common/QueryByCursorBase.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/common/QueryByCursorBase.java new file mode 100644 index 0000000000000000000000000000000000000000..b9be8c09471db1ed9f9a305ae090403108f22973 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/common/QueryByCursorBase.java @@ -0,0 +1,123 @@ +package org.opengroup.osdu.common; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import com.google.gson.Gson; +import java.util.List; +import java.util.Arrays; +import org.opengroup.osdu.core.common.model.search.SortQuery; +import org.opengroup.osdu.request.CursorQuery; +import org.opengroup.osdu.response.ErrorResponseMock; +import org.opengroup.osdu.response.ResponseMock; +import org.opengroup.osdu.util.Config; +import org.opengroup.osdu.util.HTTPClient; + +public class QueryByCursorBase extends TestsBase { + + private CursorQuery requestQuery = new CursorQuery(); + + public QueryByCursorBase(HTTPClient httpClient) { + super(httpClient); + } + + @Override + protected String getApi() { + return Config.getSearchBaseURL() + "query_with_cursor"; + } + + @Override + protected String getHttpMethod() { + return "POST"; + } + + public void i_limit_the_count_of_returned_results_to(int limit) { + requestQuery.setLimit(limit); + } + + public void i_send_None_with(String kind) { + requestQuery.setKind(generateActualName(kind, timeStamp)); + } + + public void i_send_with(String query, String kind) { + requestQuery.setQuery(query); + requestQuery.setKind(generateActualName(kind, timeStamp)); + } + + public void i_set_the_fields_I_want_in_response_as(List<String> returnedFileds) { + if(returnedFileds.contains("NULL")) requestQuery.setReturnedFields(null); + else if (!returnedFileds.contains("All")) requestQuery.setReturnedFields(returnedFileds); + } + + public void i_set_autocomplete_phrase(String autocompletePhrase) { + requestQuery.setSuggestPhrase(autocompletePhrase); + } + + public void i_should_get_following_autocomplete_suggestions(String autocompleteOptions) { + String payload = requestQuery.toString(); + ResponseMock response = executeQuery(payload, headers, httpClient.getAccessToken(), ResponseMock.class); + assertEquals(200, response.getResponseCode()); + assertEquals(Arrays.asList(autocompleteOptions.split(",")), response.getPhraseSuggestions()); + } + + public void i_apply_geographical_query_on_field(String field) { + spatialFilter.setField(field); + requestQuery.setSpatialFilter(spatialFilter); + } + + public void i_should_get_in_response_records(int resultCount) { + String payload = requestQuery.toString(); + ResponseMock response = executeQuery(payload, headers, httpClient.getAccessToken(), ResponseMock.class); + assertEquals(200, response.getResponseCode()); + assertEquals(resultCount, response.getResults().size()); + if(resultCount == 0){ + assertNull(response.getCursor()); + } + } + + public void i_should_get_response_with_reason_message_and_errors(List<Integer> codes, String type, String msg, + String error) { + String payload = requestQuery.toString(); + ErrorResponseMock response = executeQuery(payload, headers, httpClient.getAccessToken(), ErrorResponseMock.class); + if (response.getErrors() != null) { + assertEquals(generateActualName(error, timeStamp), response.getErrors().get(0)); + } + assertEquals(type, response.getReason()); + assertEquals(generateActualName(msg, timeStamp), response.getMessage()); + assertTrue(codes.contains(response.getResponseCode())); + } + + public void i_should_get_in_response_records_along_with_a_cursor(int resultCount) { + String payload = requestQuery.toString(); + ResponseMock response = executeQuery(payload, headers, httpClient.getAccessToken(), ResponseMock.class); + assertEquals(200, response.getResponseCode()); + assertEquals(resultCount, response.getResults().size()); + requestQuery.setCursor(response.getCursor()); + } + + public void i_sort_with(String sortJson) { + SortQuery sortArg = (new Gson()).fromJson(sortJson, SortQuery.class); + requestQuery.setSort(sortArg); + } + + public void i_search_as(String isOwner) { + requestQuery.setQueryAsOwner(Boolean.parseBoolean(isOwner)); + } + + public void i_should_get_records_in_right_order(String firstRecId, String lastRecId) { + String actualFirstRecordId = generateActualName(firstRecId,timeStamp); + String actualLastRecordId = generateActualName(lastRecId,timeStamp); + String payload = requestQuery.toString(); + ResponseMock response = executeQuery(payload, headers, httpClient.getAccessToken(), ResponseMock.class); + assertEquals(200, response.getResponseCode()); + assertNotNull(response.getResults()); + assertTrue(response.getResults().size() > 0); + assertEquals(actualFirstRecordId, response.getResults().get(0).get("id").toString()); + assertEquals(actualLastRecordId, response.getResults().get(response.getResults().size()-1).get("id").toString()); + } + + public void i_set_an_invalid_cursor() { + requestQuery.setCursor("invalid cursor"); + } +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/common/SwaggerBase.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/common/SwaggerBase.java new file mode 100644 index 0000000000000000000000000000000000000000..4d7d1fcbfe002c13ade3aa7fffd77a43d9f0c0b8 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/common/SwaggerBase.java @@ -0,0 +1,43 @@ +package org.opengroup.osdu.common; + +import org.opengroup.osdu.response.SwaggerResponseMock; +import org.opengroup.osdu.util.Config; +import org.opengroup.osdu.util.HTTPClient; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +public class SwaggerBase extends TestsBase { + + private SwaggerResponseMock response; + + public SwaggerBase(HTTPClient httpClient) { + super(httpClient); + } + + @Override + protected String getApi() { + return Config.getSearchBaseURL() + "swagger"; + } + + @Override + protected String getHttpMethod() { + return "GET"; + } + + public void i_send_get_request_to_swagger_endpoint() { + response = executeQuery("", headers, httpClient.getAccessToken(), SwaggerResponseMock.class); + } + + public void i_should_get_openapi_spec_in_response() { + assertNotNull(response.getOpenapi()); + assertNotNull(response.getInfo()); + assertNotNull(response.getServers()); + assertNotNull(response.getSecurity()); + assertNotNull(response.getTags()); + assertNotNull(response.getPaths()); + assertNotNull(response.getComponents()); + assertEquals(200, response.getResponseCode()); + } + +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/common/TestsBase.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/common/TestsBase.java new file mode 100644 index 0000000000000000000000000000000000000000..0c8ec3cd884d14055b3698d82560e78c0e189fec --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/common/TestsBase.java @@ -0,0 +1,303 @@ +package org.opengroup.osdu.common; + +import com.google.gson.Gson; + +import com.google.gson.reflect.TypeToken; +import cucumber.api.DataTable; +import org.apache.logging.log4j.util.Strings; +import org.opengroup.osdu.core.common.model.entitlements.Acl; +import org.opengroup.osdu.core.common.model.legal.Legal; +import org.opengroup.osdu.core.common.model.search.Point; +import org.opengroup.osdu.core.common.model.search.Polygon; +import org.opengroup.osdu.models.Setup; +import org.opengroup.osdu.models.schema.PersistentSchemaTestIndex; +import org.opengroup.osdu.request.SpatialFilter; +import org.opengroup.osdu.response.ResponseBase; +import org.opengroup.osdu.util.FileHandler; +import org.opengroup.osdu.util.HTTPClient; + +import com.sun.jersey.api.client.ClientResponse; +import cucumber.api.Scenario; +import org.opengroup.osdu.util.SchemaServiceClient; + +import javax.ws.rs.HttpMethod; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import java.io.IOException; +import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.logging.Level; +import java.util.logging.Logger; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.opengroup.osdu.util.Config.*; +import static org.opengroup.osdu.util.Utility.beautifyJsonString; + + +public abstract class TestsBase { + private static final String X_COLLABORATION_HEADER = "x-collaboration"; + protected HTTPClient httpClient; + protected Scenario scenario; + protected Map<String, String> tenantMap = new HashMap<>(); + protected Map<String, String> headers = new HashMap<>(); + + private List<String> indexes = new ArrayList<>(); + private List<Map<String, Object>> records; + private Map<String, List<String>> schemaRecords = new HashMap<>(); + + protected SpatialFilter spatialFilter = new SpatialFilter(); + protected SpatialFilter.ByBoundingBox byBoundingBox; + protected SpatialFilter.ByIntersection byIntersection; + protected SpatialFilter.ByWithinPolygon byWithinPolygon; + + protected static final String timeStamp = String.valueOf(System.currentTimeMillis()); + private boolean dunit = false; + private static final Logger LOGGER = Logger.getLogger(SchemaServiceClient.class.getName()); + public TestsBase(HTTPClient httpClient) { + this.httpClient = httpClient; + headers = httpClient.getCommonHeader(); + tenantMap.put("tenant1", getDataPartitionIdTenant1()); + tenantMap.put("tenant2", getDataPartitionIdTenant2()); + tenantMap.put("common", "common"); + } + + + public void i_send_request_to_tenant(String tenant) { + headers = HTTPClient.overrideHeader(headers, getTenantMapping(tenant)); + } + + public void i_send_request_with_xcollab_header(String xCollaborationHeader) { + if (Strings.isNotEmpty(xCollaborationHeader)) { + headers = HTTPClient.addHeader(headers, X_COLLABORATION_HEADER, xCollaborationHeader); + } + } + + public void i_send_request_to_tenant(String tenant1, String tenant2) { + headers = HTTPClient.overrideHeader(headers, getTenantMapping(tenant1), getTenantMapping(tenant2)); + } + + protected abstract String getApi(); + + protected abstract String getHttpMethod(); + + public void offset_of_starting_point_as_None() { + //Do nothing on None + } + + public void define_bounding_box_with_points_and(Double topLatitude, Double topLongitude, Double bottomLatitude, Double + bottomLongitude) { + SpatialFilter.Points bottomRight = SpatialFilter.Points.builder().latitude(bottomLatitude).longitude(bottomLongitude).build(); + SpatialFilter.Points topLeft = SpatialFilter.Points.builder().latitude(topLatitude).longitude(topLongitude).build(); + byBoundingBox = SpatialFilter.ByBoundingBox.builder().topLeft(topLeft).bottomRight(bottomRight).build(); + spatialFilter.setByBoundingBox(byBoundingBox); + } + + public void define_intersection_polygon_with_points(Double latitude1, Double longitude1, Double latitude2, Double longitude2, + Double latitude3, Double longitude3, Double latitude4, Double longitude4, + Double latitude5, Double longitude5) { + Point point1 = new Point(latitude1, longitude1); + Point point2 = new Point(latitude2, longitude2); + Point point3 = new Point(latitude3, longitude3); + Point point4 = new Point(latitude4, longitude4); + Point point5 = new Point(latitude5, longitude5); + List<Point> points = Arrays.asList(point1, point2, point3, point4, point5); + Polygon polygon = new Polygon(points); + List<Polygon> polygons = Arrays.asList(polygon); + byIntersection = SpatialFilter.ByIntersection.builder().polygons(polygons).build(); + spatialFilter.setByIntersection(byIntersection); + } + + public void define_within_polygon_with_points(Double latitude1, Double longitude1) { + Point point1 = new Point(latitude1, longitude1); + List<Point> points = Arrays.asList(point1); + byWithinPolygon = SpatialFilter.ByWithinPolygon.builder().points(points).build(); + spatialFilter.setByWithinPolygon(byWithinPolygon); + } + + protected String executeQuery(String api, String payLoad, Map<String, String> headers, String token) { + ClientResponse clientResponse = httpClient.send(this.getHttpMethod(), api, payLoad, headers, token); + logCorrelationIdWithFunctionName(clientResponse.getHeaders()); + LOGGER.log( Level.INFO, String.format("Response status: %s, type: %s", clientResponse.getStatus(), clientResponse.getType().toString())); + assertEquals(MediaType.APPLICATION_JSON, clientResponse.getType().toString()); + return clientResponse.getEntity(String.class); + } + + protected <T extends ResponseBase> T executeQuery(String api, String payLoad, Map<String, String> headers, String token, Class<T> typeParameterClass) { + ClientResponse clientResponse = httpClient.send(this.getHttpMethod(), api, payLoad, headers, token); + logCorrelationIdWithFunctionName(clientResponse.getHeaders()); + return getResponse(clientResponse, typeParameterClass); + } + + protected <T extends ResponseBase> T executeQuery(String payLoad, Map<String, String> headers, String token, Class<T> typeParameterClass) { + ClientResponse clientResponse = httpClient.send(this.getHttpMethod(), this.getApi(), payLoad, headers, token); + logCorrelationIdWithFunctionName(clientResponse.getHeaders()); + return getResponse(clientResponse, typeParameterClass); + } + + private <T extends ResponseBase> T getResponse(ClientResponse clientResponse, Class<T> typeParameterClass) { + if (clientResponse.getType() == null || LOGGER == null){ + int i = 0; + } + LOGGER.log( Level.INFO, String.format("Response status: %s", clientResponse.getStatus())); + if(clientResponse.getType() != null){ + LOGGER.log( Level.INFO, String.format("Response type: %s", clientResponse.getType().toString())); + }else { + LOGGER.log( Level.INFO,"Got response type: null"); + } + assertTrue(clientResponse.getType().toString().contains(MediaType.APPLICATION_JSON)); + String responseEntity = clientResponse.getEntity(String.class); + + T response = new Gson().fromJson(responseEntity, typeParameterClass); + response.setHeaders(clientResponse.getHeaders()); + response.setResponseCode(clientResponse.getStatus()); + LOGGER.log( Level.INFO, String.format("Response body: %s\nCorrelation id: %s\nResponse code: %s", beautifyJsonString(responseEntity), response.getHeaders().get("correlation-id"), response.getResponseCode())); + return response; + } + + protected ClientResponse executeGetRequest(String api, Map<String, String> headers, String token) { + return executeRequest(this.getHttpMethod(), api, headers, token); + } + + protected ClientResponse executeRequest(String method, String api, Map<String, String> headers, String token) { + ClientResponse clientResponse = httpClient.send(method, api, null, headers, token); + if (clientResponse.getType() != null) { + LOGGER.log( Level.INFO, String.format("Response status: %s, type: %s", clientResponse.getStatus(), clientResponse.getType().toString())); + } + logCorrelationIdWithFunctionName(clientResponse.getHeaders()); + return clientResponse; + } + + private void logCorrelationIdWithFunctionName(MultivaluedMap<String, String> headers) { + LOGGER.log( Level.INFO, String.format("Scenario Name: %s, Correlation-Id: %s", scenario.getId(), headers.get("correlation-id"))); + } + + protected String getTenantMapping(String tenant) { + if (tenantMap.containsKey(tenant)) { + return tenantMap.get(tenant); + } + return null; + } + + public String generateActualName(String rawName, String timeStamp) { + for (String tenant : tenantMap.keySet()) { + rawName = rawName.replaceAll(tenant, getTenantMapping(tenant)); + } + return rawName.replaceAll("<timestamp>", this.timeStamp); + } + + protected Legal generateLegalTag() { + Legal legal = new Legal(); + Set<String> legalTags = new HashSet<>(); + legalTags.add(getLegalTag()); + legal.setLegaltags(legalTags); + Set<String> otherRelevantCountries = new HashSet<>(); + otherRelevantCountries.add(getOtherRelevantDataCountries()); + legal.setOtherRelevantDataCountries(otherRelevantCountries); + return legal; + } + + public void the_schema_is_created_with_the_following_kind(DataTable dataTable) { + List<Setup> inputList = dataTable.asList(Setup.class); + inputList.forEach(this::createSchema); + + + } + + protected void tearDownSchema() throws IOException { + String payload="{}"; + for(String kind : schemaRecords.keySet()){ + List<String> recordIds = schemaRecords.get(kind); + for (String id : recordIds) { + ClientResponse clientResponse = httpClient.send(HttpMethod.DELETE, getStorageBaseURL() + "records/" +id,payload,headers, httpClient.getAccessToken()); + LOGGER.log( Level.INFO, String.format("Deleted record with id: %s\nHttpMethod: %s\nStorage base URL: %s\nRequest body: %s\nCorrelation id: %s\nStatus code: %s", id, HttpMethod.DELETE, getStorageBaseURL(), beautifyJsonString(payload), clientResponse.getHeaders().get("correlation-id"), clientResponse.getStatus())); + } + ClientResponse clientResponse = httpClient.send(HttpMethod.DELETE, getIndexerBaseURL() + "index?kind=" +kind,payload,headers, httpClient.getAccessToken()); + LOGGER.log( Level.INFO, String.format("Deleted index with kind: %s\nHttpMethod: %s\nIndexer base URL: %s\nRequest body: %s\nCorrelation id: %s\nStatus code: %s", kind, HttpMethod.DELETE, getIndexerBaseURL(), beautifyJsonString(payload), clientResponse.getHeaders().get("correlation-id"), clientResponse.getStatus())); + } + + } + + private void createSchema(Setup input) { + PersistentSchemaTestIndex testIndex = new PersistentSchemaTestIndex(httpClient, this); + testIndex.setSchemaFile(input.getSchemaFile()); + testIndex.setHttpClient(httpClient); + testIndex.setupSchema(); + testIndex.setKind(testIndex.getSchemaModel().getSchemaInfo().getSchemaIdentity().getId()); + } + + public String generateActualNameWithoutTs(String rawName) { + for (Map.Entry<String, String> tenant : tenantMap.entrySet()) { + rawName = rawName.replaceAll(tenant.getKey(), tenant.getValue()); + } + return rawName.replaceAll("<timestamp>", ""); + } + + public void i_ingest_records_with_the_for_a_given(String record, String dataGroup, String kind) { + i_ingest_records_with_the_for_a_given_with_header(record, dataGroup, kind, ""); + } + + public void i_ingest_records_with_the_for_a_given_with_header(String record, String dataGroup, String kind, String xCollaborationHeader) { + + String actualKind = generateActualName(kind, timeStamp); + List<String> recordsForKind = new ArrayList<>(); + try { + String fileContent = FileHandler.readFile(String.format("%s.%s", record, "json")); + records = new Gson().fromJson(fileContent, new TypeToken<List<Map<String, Object>>>() {}.getType()); + String createTime = java.time.Instant.now().toString(); + + for (Map<String, Object> testRecord : records) { + testRecord.put("kind", actualKind); + testRecord.put("id", generateRecordId(testRecord)); + recordsForKind.add(testRecord.get("id").toString()); + testRecord.put("legal", generateLegalTag()); + String[] x_acl = {generateActualName(dataGroup, timeStamp) + "." + getEntitlementsDomain()}; + Acl acl = Acl.builder().viewers(x_acl).owners(x_acl).build(); + testRecord.put("acl", acl); + String[] kindParts = kind.split(":"); + String authority = tenantMap.get(kindParts[0]); + String source = kindParts[1]; + testRecord.put("authority", authority); + testRecord.put("source", generateActualName(source, timeStamp)); + testRecord.put("createUser", "TestUser"); + testRecord.put("createTime", createTime); + } + schemaRecords.put(actualKind, recordsForKind); + String payLoad = new Gson().toJson(records); + LOGGER.log( Level.INFO, String.format("Start ingesting records= %s", payLoad)); + if (Strings.isNotEmpty(xCollaborationHeader)) { + headers.put(X_COLLABORATION_HEADER, xCollaborationHeader); + } + ClientResponse clientResponse = httpClient.send(HttpMethod.PUT, getStorageBaseURL() + "records", payLoad, headers, httpClient.getAccessToken()); + LOGGER.log( Level.INFO, String.format("Response body: %s\n Correlation id: %s\nStatus code: %s",beautifyJsonString(clientResponse.getEntity(String.class)) , clientResponse.getHeaders().get("correlation-id"), clientResponse.getStatus())); + assertEquals(201, clientResponse.getStatus()); + Runtime.getRuntime().addShutdownHook(new Thread() { + public void run() { + try { + tearDownSchema(); + } catch (IOException e) { + e.printStackTrace(); + } + } + }); + TimeUnit.SECONDS.sleep(40); + } catch (Exception ex) { + throw new AssertionError(ex.getMessage()); + } + } + + protected String generateRecordId(Map<String, Object> testRecord) { + return generateActualId(testRecord.get("id").toString(), timeStamp, testRecord.get("kind").toString()); + } + + protected String generateActualId(String rawName, String timeStamp, String kind) { + + rawName = generateActualName(rawName, timeStamp); + + String kindSubType = kind.split(":")[2]; + + return rawName.replaceAll("<kindSubType>", kindSubType); + + } + +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/common/health/HealthSteps.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/common/health/HealthSteps.java new file mode 100644 index 0000000000000000000000000000000000000000..ecb35ad4ae2ced1190f16c63ff0947397945e0e9 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/common/health/HealthSteps.java @@ -0,0 +1,60 @@ +/* + * Copyright 2020-2023 Google LLC + * Copyright 2021-2023 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 + * + * https://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.common.health; + +import com.sun.jersey.api.client.ClientResponse; +import org.opengroup.osdu.common.TestsBase; +import org.opengroup.osdu.util.Config; +import org.opengroup.osdu.util.HTTPClient; + +import static org.junit.Assert.assertEquals; + +public class HealthSteps extends TestsBase { + protected String api; + + public HealthSteps(HTTPClient httpClient) { + super(httpClient); + } + + @Override + protected String getApi() { + return api; + } + + @Override + protected String getHttpMethod() { + return "GET"; + } + + private ClientResponse response; + + public void i_send_get_request_to_liveness_endpoint() { + api = Config.getSearchBaseURL() + "liveness_check"; + + response = executeGetRequest(api, headers, null); + } + + public void i_send_get_request_to_readiness_endpoint() { + api = Config.getSearchBaseURL() + "readiness_check"; + response = executeGetRequest(api, headers, null); + } + + public void i_should_get_OK_in_response() { + assertEquals(200, response.getStatus()); + } +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/common/info/InfoSteps.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/common/info/InfoSteps.java new file mode 100644 index 0000000000000000000000000000000000000000..2b8ab0fa45584058dd016bb6905b122d571e31b3 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/common/info/InfoSteps.java @@ -0,0 +1,12 @@ +package org.opengroup.osdu.common.info; + +import org.opengroup.osdu.common.InfoBase; +import org.opengroup.osdu.util.HTTPClient; + +public class InfoSteps extends InfoBase { + + public InfoSteps(HTTPClient httpClient) { + super(httpClient); + } + +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/common/query/singlecluster/QuerySteps.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/common/query/singlecluster/QuerySteps.java new file mode 100644 index 0000000000000000000000000000000000000000..696779e277cfc516122a9b3080ade170e80fe893 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/common/query/singlecluster/QuerySteps.java @@ -0,0 +1,44 @@ +package org.opengroup.osdu.common.query.singlecluster; + +import org.opengroup.osdu.common.QueryBase; +import org.opengroup.osdu.request.SpatialFilter; +import org.opengroup.osdu.util.HTTPClient; + +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + + +public class QuerySteps extends QueryBase { + + public QuerySteps(HTTPClient httpClient) { + super(httpClient); + } + + public void define_bounding_box_with_points_None_None_and(Double bottomLatitude, Double bottomLongitude) { + SpatialFilter.Points bottomRight = SpatialFilter.Points.builder().latitude(bottomLatitude).longitude(bottomLongitude).build(); + byBoundingBox = SpatialFilter.ByBoundingBox.builder().topLeft(null).bottomRight(bottomRight).build(); + spatialFilter.setByBoundingBox(byBoundingBox); + } + + public void define_focus_coordinates_as_and_search_in_a_radius(Double latitude, Double longitude, int distance) { + SpatialFilter.Points coordinate = SpatialFilter.Points.builder().latitude(latitude).longitude(longitude).build(); + SpatialFilter.ByDistance byDistance = SpatialFilter.ByDistance.builder().distance(distance).point(coordinate).build(); + spatialFilter.setByDistance(byDistance); + } + + public void define_geo_polygon_with_following_points_points_list(List<String> points) { + Pattern pattern = Pattern.compile("[(](.*?);(.*?)[)]"); + List<SpatialFilter.Points> coordinatesPoints = new ArrayList<>(); + for (int i = 0; i < points.size(); i++) { + Matcher matcher = pattern.matcher(points.get(i).trim()); + boolean matches = matcher.matches(); + if (matches) + coordinatesPoints.add(SpatialFilter.Points.builder().latitude(Double.valueOf(matcher.group(1))).longitude(Double.valueOf(matcher.group(2))).build()); + } + SpatialFilter.ByGeoPolygon byGeopolygon = SpatialFilter.ByGeoPolygon.builder().points(coordinatesPoints).build(); + spatialFilter.setByGeoPolygon(byGeopolygon); + } + +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/common/query/singlecluster/collaboration/QueryCollaborationSteps.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/common/query/singlecluster/collaboration/QueryCollaborationSteps.java new file mode 100644 index 0000000000000000000000000000000000000000..809e22921c7fa22240b0b1eb4251bcc336f334d4 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/common/query/singlecluster/collaboration/QueryCollaborationSteps.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024. 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.common.query.singlecluster.collaboration; + +import org.opengroup.osdu.common.QueryBase; +import org.opengroup.osdu.util.HTTPClient; + +public class QueryCollaborationSteps extends QueryBase { + + public QueryCollaborationSteps(HTTPClient httpClient) { + super(httpClient); + } +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/common/querybycursor/singlecluster/QueryByCursorSteps.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/common/querybycursor/singlecluster/QueryByCursorSteps.java new file mode 100644 index 0000000000000000000000000000000000000000..f2f466b778705f4d12fdd6d1bff72bef90186ef1 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/common/querybycursor/singlecluster/QueryByCursorSteps.java @@ -0,0 +1,24 @@ +package org.opengroup.osdu.common.querybycursor.singlecluster; + +import org.opengroup.osdu.common.QueryByCursorBase; +import org.opengroup.osdu.util.Config; +import org.opengroup.osdu.util.HTTPClient; + +public class QueryByCursorSteps extends QueryByCursorBase { + + + public QueryByCursorSteps(HTTPClient httpClient) { + super(httpClient); + } + + @Override + protected String getApi() { + return Config.getSearchBaseURL() + "query_with_cursor"; + } + + @Override + protected String getHttpMethod() { + return "POST"; + } + +} \ No newline at end of file diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/common/swagger/SwaggerSteps.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/common/swagger/SwaggerSteps.java new file mode 100644 index 0000000000000000000000000000000000000000..b1dda2503d6e8aab0bb9817ae7a8151fc38a9899 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/common/swagger/SwaggerSteps.java @@ -0,0 +1,12 @@ +package org.opengroup.osdu.common.swagger; + +import org.opengroup.osdu.common.SwaggerBase; +import org.opengroup.osdu.util.HTTPClient; + +public class SwaggerSteps extends SwaggerBase { + + public SwaggerSteps(HTTPClient httpClient) { + super(httpClient); + } + +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/models/Setup.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/models/Setup.java new file mode 100644 index 0000000000000000000000000000000000000000..c0b3f14daad584b69afbb4432a26e5a8f09023c7 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/models/Setup.java @@ -0,0 +1,23 @@ +package org.opengroup.osdu.models; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +import org.opengroup.osdu.util.HTTPClient; + +@Data +@NoArgsConstructor +public class Setup { + private String tenantId; + private String kind; + private String index; + private String viewerGroup; + private String ownerGroup; + private String mappingFile; + private String recordFile; + private String schemaFile; + private HTTPClient httpClient; + private Map<String, String> headers; +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/models/TestIndex.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/models/TestIndex.java new file mode 100644 index 0000000000000000000000000000000000000000..7bd9013d7e3483b39bded8272584127ef0c2e055 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/models/TestIndex.java @@ -0,0 +1,126 @@ +package org.opengroup.osdu.models; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.reflect.TypeToken; +import com.sun.jersey.api.client.ClientResponse; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.ws.rs.HttpMethod; + +import org.opengroup.osdu.core.common.model.entitlements.Acl; +import org.opengroup.osdu.core.common.model.legal.Legal; +import org.opengroup.osdu.util.FileHandler; +import org.opengroup.osdu.util.HTTPClient; + +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.logging.Logger; + +import static org.junit.Assert.assertEquals; +import static org.opengroup.osdu.util.Config.*; + +@Data +@NoArgsConstructor +public class TestIndex { + private static final Logger LOGGER = Logger.getLogger(TestIndex.class.getName()); + private String kind; + private String index; + private String mappingFile; + private String recordFile; + private int recordCount; + private String schemaFile; + private String[] dataGroup; + private String[] viewerGroup; + private String[] ownerGroup; + private HTTPClient httpClient; + private Map<String, String> headers; + private Gson gson = new Gson(); + + public void setHttpClient(HTTPClient httpClient) { + this.httpClient = httpClient; + headers = httpClient.getCommonHeader(); + } + + + public void setupSchema() { + ClientResponse clientResponse = this.httpClient.send(HttpMethod.POST, getStorageBaseURL() + "schemas", this.getStorageSchemaFromJson(), headers, httpClient.getAccessToken()); + if (clientResponse.getType() != null) + LOGGER.info(String.format("Response status: %s, type: %s", clientResponse.getStatus(), clientResponse.getType().toString())); + } + + public void deleteSchema(String kind) { + ClientResponse clientResponse = this.httpClient.send(HttpMethod.DELETE, getStorageBaseURL() + "schemas/" + kind, null, headers, httpClient.getAccessToken()); + assertEquals(204, clientResponse.getStatus()); + if (clientResponse.getType() != null) + LOGGER.info(String.format("Response status: %s, type: %s", clientResponse.getStatus(), clientResponse.getType().toString())); + } + + + private String getRecordFile() { + return String.format("%s.json", this.recordFile); + } + + private String getMappingFile() { + return String.format("%s.mapping", this.mappingFile); + } + + protected String getSchemaFile() { + return String.format("%s.schema", this.schemaFile); + } + + private List<Map<String, Object>> getRecordsFromTestFile() { + try { + String fileContent = FileHandler.readFile(getRecordFile()); + List<Map<String, Object>> records = new Gson().fromJson( + fileContent, new TypeToken<List<Map<String,Object>>>() {}.getType()); + + for (Map<String, Object> testRecord : records) { + testRecord.put("kind", this.kind); + testRecord.put("legal", generateLegalTag()); + testRecord.put("x-acl", dataGroup); + Acl acl = Acl.builder().viewers(viewerGroup).owners(ownerGroup).build(); + testRecord.put("acl", acl); + } + return records; + } catch (Exception ex) { + throw new AssertionError(ex.getMessage()); + } + } + + private String getIndexMappingFromJson() { + try { + String fileContent = FileHandler.readFile(getMappingFile()); + JsonElement json = gson.fromJson(fileContent, JsonElement.class); + return gson.toJson(json); + } catch (Exception e) { + throw new AssertionError(e.getMessage()); + } + } + + private String getStorageSchemaFromJson() { + try { + String fileContent = FileHandler.readFile(getSchemaFile()); + fileContent = fileContent.replaceAll("KIND_VAL", this.kind); + JsonElement json = gson.fromJson(fileContent, JsonElement.class); + return gson.toJson(json); + } catch (Exception e) { + throw new AssertionError(e.getMessage()); + } + } + + private Legal generateLegalTag() { + Legal legal = new Legal(); + Set<String> legalTags = new HashSet<>(); + legalTags.add(getLegalTag()); + legal.setLegaltags(legalTags); + Set<String> otherRelevantCountries = new HashSet<>(); + otherRelevantCountries.add(getOtherRelevantDataCountries()); + legal.setOtherRelevantDataCountries(otherRelevantCountries); + return legal; + } + +} \ No newline at end of file diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/models/schema/PersistentSchemaTestIndex.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/models/schema/PersistentSchemaTestIndex.java new file mode 100644 index 0000000000000000000000000000000000000000..0e51bc207cb6a5eb093cddecb01bc7654d21203e --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/models/schema/PersistentSchemaTestIndex.java @@ -0,0 +1,78 @@ +// Copyright © Microsoft Corporation +// +// 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.models.schema; + +import org.opengroup.osdu.common.TestsBase; +import org.opengroup.osdu.models.TestIndex; +import org.opengroup.osdu.util.FileHandler; +import org.opengroup.osdu.util.HTTPClient; +import org.opengroup.osdu.util.SchemaServiceClient; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.util.logging.Level; +import java.util.logging.Logger; + + +public class PersistentSchemaTestIndex extends TestIndex { + + private static final Logger LOGGER = Logger.getLogger(PersistentSchemaTestIndex.class.getName()); + private final SchemaServiceClient schemaServiceClient; + private final TestsBase testsBase; + private SchemaModel schemaModel; + + public PersistentSchemaTestIndex(HTTPClient client, TestsBase testsBase) { + super(); + this.schemaServiceClient = new SchemaServiceClient(client); + this.testsBase = testsBase; + } + + @Override + public void setupSchema() { + this.schemaModel = readSchemaFromJson(); + SchemaIdentity schemaIdentity = schemaModel.getSchemaInfo().getSchemaIdentity(); + LOGGER.log(Level.INFO, "Read the schema={0}", schemaIdentity); + schemaIdentity.setAuthority(testsBase.generateActualNameWithoutTs(schemaIdentity.getAuthority())); + schemaIdentity.setSource(testsBase.generateActualName(schemaIdentity.getSource(),"")); + LOGGER.log(Level.INFO, "Updated the schema={0}", schemaIdentity); + schemaServiceClient.createIfNotExist(schemaModel); + LOGGER.log(Level.INFO, "Finished setting up the schema={0}", schemaIdentity); + } + + @Override + public void deleteSchema(String kind) { + // The DELETE API is not supported in the Schema service. + // In order not to overwhelm a DB with a lots of test schemas + // the integration tests create/update a schema per schema file if the schema does not exists + // If a developer updates the schema manually, the developer is supposed to update its version as well + } + + private SchemaModel readSchemaFromJson(){ + try { + return FileHandler.readFile(getSchemaFile(), SchemaModel.class); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + public SchemaModel getSchemaModel() { + return schemaModel; + } + + @Override + protected String getSchemaFile() { + return super.getSchemaFile() + ".json"; + } +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/models/schema/SchemaIdentity.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/models/schema/SchemaIdentity.java new file mode 100644 index 0000000000000000000000000000000000000000..50f4d5844f39bf0168b15db7c23f264f14af2d5a --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/models/schema/SchemaIdentity.java @@ -0,0 +1,52 @@ +// Copyright © Microsoft Corporation +// +// 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.models.schema; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.Setter; + +import java.util.StringJoiner; + +@Getter +@Setter +public class SchemaIdentity { + + private String authority; + private String source; + private String entityType; + private String schemaVersionMajor; + private String schemaVersionMinor; + private String schemaVersionPatch; + + + @JsonIgnore + public String getId() { + return authority + ":" + source + ":" + entityType + ":" + + schemaVersionMajor + "." + schemaVersionMinor + "." + schemaVersionPatch; + } + + @Override + public String toString() { + return new StringJoiner(", ", SchemaIdentity.class.getSimpleName() + "[", "]") + .add("AUTHORITY='" + authority + "'") + .add("SOURCE='" + source + "'") + .add("ENTITY_TYPE='" + entityType + "'") + .add("schemaVersionMajor='" + schemaVersionMajor + "'") + .add("schemaVersionMinor='" + schemaVersionMinor + "'") + .add("schemaVersionPatch='" + schemaVersionPatch + "'") + .toString(); + } +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/models/schema/SchemaInfo.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/models/schema/SchemaInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..caf14bd891552c4353118e335a338c21d8d25427 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/models/schema/SchemaInfo.java @@ -0,0 +1,40 @@ +// Copyright © Microsoft Corporation +// +// 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.models.schema; + +import lombok.Getter; +import lombok.Setter; + +import java.util.StringJoiner; + +@Getter +@Setter +public class SchemaInfo { + + private SchemaIdentity schemaIdentity; + private SchemaStatus status; + + @Override + public String toString() { + return new StringJoiner(", ", SchemaInfo.class.getSimpleName() + "[", "]") + .add("schemaIdentity=" + schemaIdentity) + .add("status=" + status) + .toString(); + } + + public enum SchemaStatus { + PUBLISHED, OBSOLETE, DEVELOPMENT + } +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/models/schema/SchemaModel.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/models/schema/SchemaModel.java new file mode 100644 index 0000000000000000000000000000000000000000..ce69ceb578f72b39f4206dd990a3378ba7ffe605 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/models/schema/SchemaModel.java @@ -0,0 +1,36 @@ +// Copyright © Microsoft Corporation +// +// 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.models.schema; + +import lombok.Getter; +import lombok.Setter; + +import java.util.StringJoiner; + +@Getter +@Setter +public class SchemaModel { + + private SchemaInfo schemaInfo; + private Object schema; + + @Override + public String toString() { + return new StringJoiner(", ", SchemaModel.class.getSimpleName() + "[", "]") + .add("schemaInfo=" + schemaInfo) + .add("schema=" + schema) + .toString(); + } +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/request/CursorQuery.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/request/CursorQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..54dcf0ef116a1c3c4fb6e3d19a611fc026f6090a --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/request/CursorQuery.java @@ -0,0 +1,25 @@ +package org.opengroup.osdu.request; + +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.opengroup.osdu.core.common.model.search.SortQuery; + +@Data +@NoArgsConstructor +public class CursorQuery { + private String cursor; + private String kind; + private int limit; + private String query; + private List<String> returnedFields; + private SortQuery sort; + private Boolean queryAsOwner; + private String suggestPhrase; + private SpatialFilter spatialFilter; + + @Override + public String toString() { + return new com.google.gson.GsonBuilder().disableHtmlEscaping().create().toJson(this); + } +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/request/Query.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/request/Query.java new file mode 100644 index 0000000000000000000000000000000000000000..5e32df5a9e1931123cfd8816b8e6420ac814197f --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/request/Query.java @@ -0,0 +1,27 @@ +package org.opengroup.osdu.request; + +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.opengroup.osdu.core.common.model.search.SortQuery; + +@Data +@NoArgsConstructor +public class Query { + + private String kind; + private Integer offset; + private Integer limit; + private String query; + private SortQuery sort; + private Boolean queryAsOwner; + private String aggregateBy; + private String suggestPhrase; + private List<String> returnedFields; + private SpatialFilter spatialFilter; + + @Override + public String toString() { + return new com.google.gson.Gson().toJson(this); + } +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/request/SpatialFilter.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/request/SpatialFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..b8296a51af5267b86f591a5c4976490912b0b26e --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/request/SpatialFilter.java @@ -0,0 +1,58 @@ +package org.opengroup.osdu.request; + +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.AllArgsConstructor; +import lombok.Builder; +import org.opengroup.osdu.core.common.model.search.Point; +import org.opengroup.osdu.core.common.model.search.Polygon; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Setter +public class SpatialFilter { + String field; + ByBoundingBox byBoundingBox; + ByDistance byDistance; + ByGeoPolygon byGeoPolygon; + ByIntersection byIntersection; + ByWithinPolygon byWithinPolygon; + + @Builder + public static class ByDistance { + Points point; + int distance; + } + + @Builder + public static class ByBoundingBox { + Points topLeft; + Points bottomRight; + } + + @Builder + public static class Points { + Double latitude; + Double longitude; + } + + @Builder + public static class ByGeoPolygon { + List<Points> points; + } + + @Builder + public static class ByIntersection { + private List<Polygon> polygons; + } + + @Builder + public static class ByWithinPolygon { + private List<Point> points; + } +} \ No newline at end of file diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/response/AggregationMock.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/response/AggregationMock.java new file mode 100644 index 0000000000000000000000000000000000000000..fc4c2f1d125ccde24e89da962d6fd9148f4a7fa8 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/response/AggregationMock.java @@ -0,0 +1,9 @@ +package org.opengroup.osdu.response; + +import lombok.Data; + +@Data +public class AggregationMock { + private String key; + private long count; +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/response/ErrorResponseMock.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/response/ErrorResponseMock.java new file mode 100644 index 0000000000000000000000000000000000000000..20d0b943867335229ad846d60e6d99b3feceecfc --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/response/ErrorResponseMock.java @@ -0,0 +1,15 @@ +package org.opengroup.osdu.response; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +@Data +@EqualsAndHashCode(callSuper = true) +public class ErrorResponseMock extends ResponseBase { + private List<String> errors; + private String code; + private String reason; + private String message; +} \ No newline at end of file diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/response/HealthResponseMock.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/response/HealthResponseMock.java new file mode 100644 index 0000000000000000000000000000000000000000..d86784d6335d259b875ea6310b5cc477f568f045 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/response/HealthResponseMock.java @@ -0,0 +1,25 @@ +/* + * Copyright 2020-2023 Google LLC + * Copyright 2021-2023 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 + * + * https://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.response; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class HealthResponseMock extends ResponseBase {} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/response/InfoResponseMock.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/response/InfoResponseMock.java new file mode 100644 index 0000000000000000000000000000000000000000..1328c2ad6eeff2d03e9ddf0ee60cefe8452acfc7 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/response/InfoResponseMock.java @@ -0,0 +1,16 @@ +package org.opengroup.osdu.response; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class InfoResponseMock extends ResponseBase { + private String groupId; + private String artifactId; + private String version; + private String buildTime; + private String branch; + private String commitId; + private String commitMessage; +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/response/ResponseBase.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/response/ResponseBase.java new file mode 100644 index 0000000000000000000000000000000000000000..7e981ba8f4edd467cac3a28f5a57ab98edfc51b8 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/response/ResponseBase.java @@ -0,0 +1,11 @@ +package org.opengroup.osdu.response; + +import lombok.Data; + +import javax.ws.rs.core.MultivaluedMap; + +@Data +public abstract class ResponseBase { + private int responseCode; + private MultivaluedMap<String, String> headers; +} \ No newline at end of file diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/response/ResponseMock.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/response/ResponseMock.java new file mode 100644 index 0000000000000000000000000000000000000000..5842aaff3ff0cb47a6ae8be4625dac7eb6dd8632 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/response/ResponseMock.java @@ -0,0 +1,17 @@ +package org.opengroup.osdu.response; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; +import java.util.Map; + +@Data +@EqualsAndHashCode(callSuper = true) +public class ResponseMock extends ResponseBase { + private List<Map<String, Object>> results; + private List<AggregationMock> aggregations; + private long totalCount; + private String cursor; + private List<String> phraseSuggestions; +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/response/SwaggerResponseMock.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/response/SwaggerResponseMock.java new file mode 100644 index 0000000000000000000000000000000000000000..ab3a1048f631b9030e6a6e341dc94c2f516ad9b6 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/response/SwaggerResponseMock.java @@ -0,0 +1,16 @@ +package org.opengroup.osdu.response; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class SwaggerResponseMock extends ResponseBase { + private String openapi; + private Object info; + private Object servers; + private Object security; + private Object tags; + private Object paths; + private Object components; +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/step_definitions/health/RunTest.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/step_definitions/health/RunTest.java new file mode 100644 index 0000000000000000000000000000000000000000..21247db1935c4d2c4e311b442c14a9a4ed5e539b --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/step_definitions/health/RunTest.java @@ -0,0 +1,29 @@ +/* + * Copyright 2020-2023 Google LLC + * Copyright 2020-2023 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.health; + +import cucumber.api.CucumberOptions; +import cucumber.api.junit.Cucumber; +import org.junit.runner.RunWith; + +@RunWith(Cucumber.class) +@CucumberOptions( + features = "classpath:features/health/Health.feature", + glue = {"classpath:org.opengroup.osdu.step_definitions.health"}, + plugin = {"pretty", "junit:target/cucumber-reports/TEST-health.xml"}) +public class RunTest {} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/step_definitions/health/Steps.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/step_definitions/health/Steps.java new file mode 100644 index 0000000000000000000000000000000000000000..fe100eaa15a31cd8cf160deb70b142e7d92d28a5 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/step_definitions/health/Steps.java @@ -0,0 +1,58 @@ +/* + * Copyright 2020-2023 Google LLC + * Copyright 2020-2023 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.health; + +import cucumber.api.Scenario; +import cucumber.api.java.Before; +import cucumber.api.java.en.Then; +import cucumber.api.java.en.When; +import org.opengroup.osdu.common.health.HealthSteps; +import org.opengroup.osdu.util.HTTPClient; + +public class Steps extends HealthSteps { + + public Steps() { + super(new HTTPClient()); + } + + @Before + public void before(Scenario scenario) { + this.scenario = scenario; + this.httpClient = new HTTPClient(); + } + + @When("^I send get request to liveness check endpoint") + public void i_send_get_request_to_liveness_endpoint() { + super.i_send_get_request_to_liveness_endpoint(); + } + + @Then("^service should respond back with 200 in response$") + public void i_should_get_OK_in_response() { + super.i_should_get_OK_in_response(); + } + + @When("^I send get request to readiness check endpoint") + public void i_send_get_request_to_readiness_endpoint() { + super.i_send_get_request_to_readiness_endpoint(); + } + + @Override + protected String getHttpMethod() { + return "GET"; + } +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/step_definitions/info/RunTest.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/step_definitions/info/RunTest.java new file mode 100644 index 0000000000000000000000000000000000000000..777d95acb05df9a486ec9623a9736547ccb8a3d1 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/step_definitions/info/RunTest.java @@ -0,0 +1,31 @@ +/* + * Copyright 2020-2022 Google LLC + * Copyright 2020-2022 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.info; + +import cucumber.api.CucumberOptions; +import cucumber.api.junit.Cucumber; +import org.junit.runner.RunWith; + +@RunWith(Cucumber.class) +@CucumberOptions( + features = "classpath:features/info/Info.feature", + glue = {"classpath:org.opengroup.osdu.step_definitions.info"}, + plugin = {"pretty", "junit:target/cucumber-reports/TEST-info.xml"}) +public class RunTest { + +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/step_definitions/info/Steps.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/step_definitions/info/Steps.java new file mode 100644 index 0000000000000000000000000000000000000000..869f8aa1ea9cf2a5eac92b2da4b5bc87bbd3aaa1 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/step_definitions/info/Steps.java @@ -0,0 +1,68 @@ +/* + * Copyright 2020-2022 Google LLC + * Copyright 2020-2022 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.info; + +import cucumber.api.Scenario; +import cucumber.api.java.Before; +import cucumber.api.java.en.Then; +import cucumber.api.java.en.When; +import org.opengroup.osdu.common.info.InfoSteps; +import org.opengroup.osdu.util.HTTPClient; +import org.opengroup.osdu.util.Config; + +public class Steps extends InfoSteps { + + public Steps() { + super(new HTTPClient()); + } + + @Before + public void before(Scenario scenario) { + this.scenario = scenario; + this.httpClient = new HTTPClient(); + } + + /******************Inputs being set**************/ + + @When("^I send get request to version info endpoint$") + public void i_send_get_request_to_version_info_endpoint() { + super.i_send_get_request_to_version_info_endpoint(); + } + + @When("^I send get request to version info endpoint with trailing slash$") + public void i_send_get_request_to_version_info_endpoint_with_trailing_slash() { + super.i_send_get_request_to_version_info_endpoint_with_trailing_slash(); + } + + /******************Assert final response**************/ + + @Then("^I should get version info in response$") + public void i_should_get_version_info_in_response() { + super.i_should_get_version_info_in_response(); + } + + @Override + protected String getHttpMethod() { + return "GET"; + } + + @Override + protected String getApi() { + return Config.getSearchBaseURL() + "info"; + } +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/step_definitions/query/singlecluster/RunTest.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/step_definitions/query/singlecluster/RunTest.java new file mode 100644 index 0000000000000000000000000000000000000000..bbbe42717266bcaf2c0ad2d9d43c792d6eefe130 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/step_definitions/query/singlecluster/RunTest.java @@ -0,0 +1,31 @@ +/* + * Copyright 2020-2022 Google LLC + * Copyright 2020-2022 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.query.singlecluster; + +import cucumber.api.CucumberOptions; +import cucumber.api.junit.Cucumber; +import org.junit.runner.RunWith; + +@RunWith(Cucumber.class) +@CucumberOptions( + features = "classpath:features/query/singlecluster/Query.feature", + glue = {"classpath:org.opengroup.osdu.step_definitions.query.singlecluster"}, + plugin = {"pretty", "junit:target/cucumber-reports/TEST-query-sc.xml"}) +public class RunTest { + +} \ No newline at end of file diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/step_definitions/query/singlecluster/Steps.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/step_definitions/query/singlecluster/Steps.java new file mode 100644 index 0000000000000000000000000000000000000000..ac7e8dbbd8c933da3f7ee919de7bfda317e1a5b3 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/step_definitions/query/singlecluster/Steps.java @@ -0,0 +1,193 @@ +/* + * Copyright 2020-2022 Google LLC + * Copyright 2020-2022 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.query.singlecluster; + + +import cucumber.api.DataTable; +import cucumber.api.Scenario; +import cucumber.api.java.Before; +import cucumber.api.java.en.Given; +import cucumber.api.java.en.Then; +import cucumber.api.java.en.When; +import java.util.List; +import org.opengroup.osdu.common.query.singlecluster.QuerySteps; +import org.opengroup.osdu.util.HTTPClient; +import org.opengroup.osdu.util.Config; +import org.opengroup.osdu.util.conf.AnthosConfig; + +public class Steps extends QuerySteps { + + public Steps() { + super(new HTTPClient()); + } + + @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); + } + + @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); + } + + @Before + public void before(Scenario scenario) { + AnthosConfig.updateEntitlementsDomainVariable(); + this.scenario = scenario; + this.httpClient = new HTTPClient(); + } + + /******************Inputs being set**************/ + + @When("^I limit the count of returned results to (-?\\d+)$") + public void i_limit_the_count_of_returned_results_to(int limit) { + super.i_limit_the_count_of_returned_results_to(limit); + } + + @When("^I send None with \"(.*?)\"$") + public void i_send_None_with(String kind) { + super.i_send_None_with(kind); + } + + @When("^I send \"(.*?)\" with \"(.*?)\"$") + public void i_send_with(String query, String kind) { + super.i_send_with(query, kind); + } + + @When("^I want the results sorted by (.*?)$") + public void i_sort_with(String sortJson) { + super.i_sort_with(sortJson); + } + + @When("^I want to aggregate by \"(.*?)\"$") + public void i_aggregate_by(String aggField) throws Throwable { + super.i_aggregate_by(aggField); + } + + @When("^I want to search as owner (.*?)$") + public void i_search_as(String isOwner) { + super.i_search_as(isOwner); + } + + @When("^I set the fields I want in response as ([\"(a-zA-Z0-9)\",?]*)$") + public void i_set_the_fields_I_want_in_response_as(List<String> returnedFileds) { + super.i_set_the_fields_I_want_in_response_as(returnedFileds); + } + + @When("^I set autocomplete phrase to (.*?)$") + public void i_set_autocomplete_phrase(String autocompletePhrase) { + super.i_set_autocomplete_phrase(autocompletePhrase); + } + + @When("^I set the offset of starting point as None$$|^I limit the count of returned results to None$$") + public void offset_of_starting_point_as_None() { + super.offset_of_starting_point_as_None(); + } + + @When("^I set the offset of starting point as (-?\\d+)$") + public void i_set_the_offset_of_starting_point_as(int offset) { + super.i_set_the_offset_of_starting_point_as(offset); + } + + @When("^I send request to tenant \"(.*?)\"$") + public void i_send_request_to_tenant(String tenant) { + super.i_send_request_to_tenant(tenant); + } + + @When("^I apply geographical query on field \"(.*?)\"$") + public void i_apply_geographical_query_on_field(String field) { + super.i_apply_geographical_query_on_field(field); + } + + @When("^define bounding box with points \\((-?\\d+), (-?\\d+)\\) and \\((-?\\d+), (-?\\d+)\\)$") + public void define_bounding_box_with_points_and(Double topLatitude, Double topLongitude, Double bottomLatitude, Double + bottomLongitude) { + super.define_bounding_box_with_points_and(topLatitude, topLongitude, bottomLatitude, bottomLongitude); + } + + @When("^define bounding box with points \\(None, None\\) and \\((\\d+), (\\d+)\\)$") + public void define_bounding_box_with_points_None_None_and(Double bottomLatitude, Double bottomLongitude) { + super.define_bounding_box_with_points_None_None_and(bottomLatitude, bottomLongitude); + } + + @When("^define focus coordinates as \\((-?\\d+), (-?\\d+)\\) and search in a (\\d+) radius$") + public void define_focus_coordinates_as_and_search_in_a_radius(Double latitude, Double longitude, int distance) { + super.define_focus_coordinates_as_and_search_in_a_radius(latitude, longitude, distance); + } + + @When("^define intersection polygon with points \\((-?\\d+), (-?\\d+)\\) and \\((-?\\d+), (-?\\d+)\\) and \\((-?\\d+), (-?\\d+)\\) and \\((-?\\d+), (-?\\d+)\\) and \\((-?\\d+), (-?\\d+)\\)") + public void define_intersection_polygon_with_points(Double latitude1, Double longitude1, Double latitude2, Double longitude2, + Double latitude3, Double longitude3, Double latitude4, Double longitude4, + Double latitude5, Double longitude5) { + super.define_intersection_polygon_with_points(latitude1, longitude1, latitude2, longitude2, latitude3, longitude3, latitude4, longitude4, latitude5, + longitude5); + } + + @When("^define within polygon with points \\((-?\\d+), (-?\\d+)\\)") + public void define_within_polygon_with_points(Double latitude1, Double longitude1) { + super.define_within_polygon_with_points(latitude1, longitude1); + } + + /******************Assert final response**************/ + + @Then("^I should get in response (\\d+) records$") + public void i_should_get_in_response_records(int resultCount) { + super.i_should_get_in_response_records(resultCount); + } + + @Then("^I should get in response (\\d+) records with ([\"(a-zA-Z0-9)\",?]*)$") + public void i_should_get_in_response_records_with_fields(int resultCount, List<String> returnedFields) { + super.i_should_get_in_response_records(resultCount, returnedFields); + } + + @Then("^I should get records in right order first record id: \"(.*?)\", last record id: \"(.*?)\"$") + public void i_should_get_records_in_right_order(String firstRecId, String lastRecId) { + super.i_should_get_records_in_right_order(firstRecId, lastRecId); + } + + @Then("^I should get (\\d+) unique values") + public void i_should_get_aggregation_with_unique_values(int uniqueValueCount) { + super.i_should_get_aggregation_with_unique_values(uniqueValueCount); + } + + @Then("^I should get ([^\"]*) response with reason: \"(.*?)\", message: \"(.*?)\" and errors: \"(.*?)\"$") + public void i_should_get_response_with_reason_message_and_errors(List<Integer> codes, String type, String msg, String error) { + super.i_should_get_response_with_reason_message_and_errors(codes, type, msg, error); + } + + @Then("^I should get following autocomplete suggesstions (.*)") + public void i_should_get_following_autocomplete_suggestions(String autocompleteOptions) { + super.i_should_get_following_autocomplete_suggestions(autocompleteOptions); + } + + @When("^define geo polygon with following points ([^\"]*)$") + public void define_geo_polygon_with_following_points_points_list(List<String> points) { + super.define_geo_polygon_with_following_points_points_list(points); + } + + @Override + protected String getHttpMethod() { + return "POST"; + } + + @Override + protected String getApi() { + return Config.getSearchBaseURL() + "query"; + } +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/step_definitions/query/system_metadata/RunTest.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/step_definitions/query/system_metadata/RunTest.java new file mode 100644 index 0000000000000000000000000000000000000000..934b718aae2096c5206e25deb4fea09c2de8cda3 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/step_definitions/query/system_metadata/RunTest.java @@ -0,0 +1,31 @@ +/* + * Copyright 2020-2022 Google LLC + * Copyright 2020-2022 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.query.system_metadata; + +import cucumber.api.CucumberOptions; +import cucumber.api.junit.Cucumber; +import org.junit.runner.RunWith; + + +@RunWith(Cucumber.class) +@CucumberOptions( + features = "classpath:features/query/singlecluster/SystemMetadata.feature", + glue = {"classpath:org.opengroup.osdu.step_definitions/query/system_metadata"}, + plugin = {"pretty", "junit:target/cucumber-reports/TEST-query-sc.xml"}) +public class RunTest { +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/step_definitions/query/system_metadata/Steps.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/step_definitions/query/system_metadata/Steps.java new file mode 100644 index 0000000000000000000000000000000000000000..b1982cf400e31f1bafb3950a742c2d8bc6ae448d --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/step_definitions/query/system_metadata/Steps.java @@ -0,0 +1,79 @@ +/* + * Copyright 2020-2022 Google LLC + * Copyright 2020-2022 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.query.system_metadata; + + +import cucumber.api.DataTable; +import cucumber.api.Scenario; +import cucumber.api.java.Before; +import cucumber.api.java.en.Given; +import cucumber.api.java.en.Then; +import cucumber.api.java.en.When; +import org.opengroup.osdu.common.query.singlecluster.QuerySteps; +import org.opengroup.osdu.util.HTTPClient; +import org.opengroup.osdu.util.Config; + +public class Steps extends QuerySteps { + + public Steps() { + super(new HTTPClient()); + } + + @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); + } + + @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); + } + + @Before + public void before(Scenario scenario) { + this.scenario = scenario; + this.httpClient = new HTTPClient(); + } + + /******************Inputs being set**************/ + @When("^I send \"(.*?)\" with \"(.*?)\"$") + public void i_send_with(String query, String kind) { + super.i_send_with(query, kind); + } + + @When("^I want to aggregate by \"(.*?)\"$") + public void i_aggregate_by(String aggField) throws Throwable { + super.i_aggregate_by(aggField); + } + + /******************Assert final response**************/ + @Then("^I should get \"(.*?)\" and should not get \"(.*?)\" from aggregations$") + public void i_should_get_included_kinds_and_should_not_get_excluded_kinds_from_aggregation(String includedKinds, String excludedKinds) { + super.i_should_get_included_kinds_and_should_not_get_excluded_kinds_from_aggregation(includedKinds, excludedKinds); + } + + @Override + protected String getHttpMethod() { + return "POST"; + } + + @Override + protected String getApi() { + return Config.getSearchBaseURL() + "query"; + } +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/step_definitions/querybycursor/singlecluster/RunTest.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/step_definitions/querybycursor/singlecluster/RunTest.java new file mode 100644 index 0000000000000000000000000000000000000000..4d35243fb05b4e94988d1593ae1457e9fd0ae194 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/step_definitions/querybycursor/singlecluster/RunTest.java @@ -0,0 +1,31 @@ +/* + * Copyright 2020-2022 Google LLC + * Copyright 2020-2022 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.querybycursor.singlecluster; + +import cucumber.api.CucumberOptions; +import cucumber.api.junit.Cucumber; +import org.junit.runner.RunWith; + +@RunWith(Cucumber.class) +@CucumberOptions( + features = "classpath:features/querybycursor/singlecluster/QueryByCursor.feature", + glue = {"classpath:org.opengroup.osdu.step_definitions.querybycursor.singlecluster"}, + plugin = {"pretty", "junit:target/cucumber-reports/TEST-querybycursor-sc.xml"}) +public class RunTest { + +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/step_definitions/querybycursor/singlecluster/Steps.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/step_definitions/querybycursor/singlecluster/Steps.java new file mode 100644 index 0000000000000000000000000000000000000000..6b35b6649dd806f4e994ec39fb23d956a6daf201 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/step_definitions/querybycursor/singlecluster/Steps.java @@ -0,0 +1,155 @@ +/* + * Copyright 2020-2022 Google LLC + * Copyright 2020-2022 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.querybycursor.singlecluster; + +import cucumber.api.DataTable; +import cucumber.api.Scenario; +import cucumber.api.java.Before; +import cucumber.api.java.en.Given; +import cucumber.api.java.en.Then; +import cucumber.api.java.en.When; +import java.util.List; +import org.opengroup.osdu.common.querybycursor.singlecluster.QueryByCursorSteps; +import org.opengroup.osdu.util.HTTPClient; +import org.opengroup.osdu.util.Config; +import org.opengroup.osdu.util.conf.AnthosConfig; + +public class Steps extends QueryByCursorSteps { + + public Steps() { + super(new HTTPClient()); + } + + @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); + } + + @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); + } + + @Before + public void before(Scenario scenario) { + AnthosConfig.updateEntitlementsDomainVariable(); + this.scenario = scenario; + this.httpClient = new HTTPClient(); + } + + /******************Inputs being set**************/ + + @When("^I limit the count of returned results to (-?\\d+)$") + public void i_limit_the_count_of_returned_results_to(int limit) { + super.i_limit_the_count_of_returned_results_to(limit); + } + + @When("^I send None with \"(.*?)\"$") + public void i_send_None_with(String kind) { + super.i_send_None_with(kind); + } + + @When("^I send \"(.*?)\" with \"(.*?)\"$") + public void i_send_with(String query, String kind) { + super.i_send_with(query, kind); + } + + @When("^I want the results sorted by (.*?)$") + public void i_sort_with(String sortJson) { + super.i_sort_with(sortJson); + } + + @When("^I want to search as owner (.*?)$") + public void i_search_as(String isOwner) { + super.i_search_as(isOwner); + } + + @When("^I set the fields I want in response as ([\"(a-zA-Z0-9)\",?]*)$") + public void i_set_the_fields_I_want_in_response_as(List<String> returnedFileds) { + super.i_set_the_fields_I_want_in_response_as(returnedFileds); + } + + @When("^I set autocomplete phrase to (.*?)$") + public void i_set_autocomplete_phrase(String autocompletePhrase) { + super.i_set_autocomplete_phrase(autocompletePhrase); + } + + @When("^I limit the count of returned results to None$$") + public void offset_of_starting_point_as_None() { + super.offset_of_starting_point_as_None(); + } + + @When("^I set an invalid cursor$") + public void i_set_an_invalid_cursor() { + super.i_set_an_invalid_cursor(); + } + + @When("^I send request to tenant \"(.*?)\"$") + public void i_send_request_to_tenant(String tenant) { + super.i_send_request_to_tenant(tenant); + } + + @When("^I apply geographical query on field \"(.*?)\"$") + public void i_apply_geographical_query_on_field(String field) { + super.i_apply_geographical_query_on_field(field); + } + + @When("^define bounding box with points \\((-?\\d+), (-?\\d+)\\) and \\((-?\\d+), (-?\\d+)\\)$") + public void define_bounding_box_with_points_and(Double topLatitude, Double topLongitude, Double bottomLatitude, Double + bottomLongitude) { + super.define_bounding_box_with_points_and(topLatitude, topLongitude, bottomLatitude, bottomLongitude); + } + + /******************Assert final response**************/ + + @Then("^I should get in response (\\d+) records along with a cursor$") + public void i_should_get_in_response_records_along_with_a_cursor(int resultCount) { + super.i_should_get_in_response_records_along_with_a_cursor(resultCount); + } + + @Then("^I should get in response (\\d+) records$") + public void i_should_get_in_response_records(int resultCount) { + super.i_should_get_in_response_records(resultCount); + } + + @Then("^I should get records in right order first record id: \"(.*?)\", last record id: \"(.*?)\"$") + public void i_should_get_records_in_right_order(String firstRecId, String lastRecId) { + super.i_should_get_records_in_right_order(firstRecId, lastRecId); + } + + @Then("^I should get ([^\"]*) response with reason: \"(.*?)\", message: \"(.*?)\" and errors: \"(.*?)\"$") + public void i_should_get_response_with_reason_message_and_errors(List<Integer> codes, String type, String msg, + String error) { + super.i_should_get_response_with_reason_message_and_errors(codes, type, msg, error); + } + + @Then("^I should get following autocomplete suggesstions (.*)") + public void i_should_get_following_autocomplete_suggestions(String autocompleteOptions) { + super.i_should_get_following_autocomplete_suggestions(autocompleteOptions); + } + + @Override + protected String getHttpMethod() { + return "POST"; + } + + @Override + protected String getApi() { + return Config.getSearchBaseURL() + "query_with_cursor"; + } +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/util/Config.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/util/Config.java new file mode 100644 index 0000000000000000000000000000000000000000..d7821766f61697c765b337ec8c59a73689014e6c --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/util/Config.java @@ -0,0 +1,113 @@ +package org.opengroup.osdu.util; + +public class Config { + + private static final String DEFAULT_ELASTIC_HOST = ""; + private static final String DEFAULT_ELASTIC_USER_NAME = ""; + private static final String DEFAULT_ELASTIC_PASSWORD = ""; + private static final String DEFAULT_ELASTIC_PORT = "9243"; + private static final String DEFAULT_ELASTIC_SSL_ENABLED = "true"; + private static final String SCHEMA_PATH = "/api/schema-service/v1"; + private static final String DEFAULT_INDEXER_HOST = ""; + private static final String DEFAULT_SEARCH_HOST = ""; + private static final String DEFAULT_STORAGE_HOST = ""; + private static final String DEFAULT_HOST = ""; + private static final String DEFAULT_DATA_PARTITION_ID_TENANT1 = "opendes"; + private static final String DEFAULT_DATA_PARTITION_ID_TENANT2 = ""; + private static final String DEFAULT_SEARCH_INTEGRATION_TESTER = ""; + + private static final String DEFAULT_LEGAL_TAG = ""; + private static final String DEFAULT_OTHER_RELEVANT_DATA_COUNTRIES = ""; + + private static final String DEFAULT_ENTITLEMENTS_DOMAIN = ""; + private static final String DEFAULT_USER_EMAIL = "user"; + + private static final String DEFAULT_SECURITY_HTTPS_CERTIFICATE_TRUST = "false"; + + public static final String QUERY_WITH_CURSOR_PATH_PROP = "query_with_cursor_path"; + public static final String SCROLL_CURSOR_PATH_VALUE = "query_with_cursor"; + public static final String SEARCH_AFTER_PATH_VALUE = "query_with_cursor?search_after=true"; + + + public static String getOtherRelevantDataCountries() { + return getEnvironmentVariableOrDefaultValue("OTHER_RELEVANT_DATA_COUNTRIES", DEFAULT_OTHER_RELEVANT_DATA_COUNTRIES); + } + + public static String getLegalTag() { + return getEnvironmentVariableOrDefaultValue("LEGAL_TAG", DEFAULT_LEGAL_TAG); + } + + + public static String getKeyValue() { + return getEnvironmentVariableOrDefaultValue("SEARCH_INTEGRATION_TESTER", DEFAULT_SEARCH_INTEGRATION_TESTER); + } + + public static String getDataPartitionIdTenant1() { + return getEnvironmentVariableOrDefaultValue("DEFAULT_DATA_PARTITION_ID_TENANT1", DEFAULT_DATA_PARTITION_ID_TENANT1); + } + + public static String getDataPartitionIdTenant2() { + return getEnvironmentVariableOrDefaultValue("DEFAULT_DATA_PARTITION_ID_TENANT2", DEFAULT_DATA_PARTITION_ID_TENANT2); + } + + public static String getUserName() { + return getEnvironmentVariableOrDefaultValue("ELASTIC_USER_NAME", DEFAULT_ELASTIC_USER_NAME); + } + + public static String getPassword() { + return getEnvironmentVariableOrDefaultValue("ELASTIC_PASSWORD", DEFAULT_ELASTIC_PASSWORD); + } + + public static String getElasticHost() { + return getEnvironmentVariableOrDefaultValue("ELASTIC_HOST", DEFAULT_ELASTIC_HOST); + } + + public static boolean isElasticSslEnabled() { + return Boolean.parseBoolean(getEnvironmentVariableOrDefaultValue("ELASTIC_SSL_ENABLED", DEFAULT_ELASTIC_SSL_ENABLED)); + } + + public static int getElasticPort() { + return Integer.parseInt(getEnvironmentVariableOrDefaultValue("ELASTIC_PORT", DEFAULT_ELASTIC_PORT)); + } + + public static String getIndexerBaseURL() { + return getEnvironmentVariableOrDefaultValue("INDEXER_HOST", DEFAULT_INDEXER_HOST); + } + + public static String getSearchBaseURL() { + return getEnvironmentVariableOrDefaultValue("SEARCH_HOST", DEFAULT_SEARCH_HOST); + } + + public static String getStorageBaseURL() { + return getEnvironmentVariableOrDefaultValue("STORAGE_HOST", DEFAULT_STORAGE_HOST); + } + + public static String getEntitlementsDomain() { + return getEnvironmentVariableOrDefaultValue("ENTITLEMENTS_DOMAIN", DEFAULT_ENTITLEMENTS_DOMAIN); + } + + public static String getUserEmail() { + return getEnvironmentVariableOrDefaultValue("USER_EMAIL", DEFAULT_USER_EMAIL); + } + + public static boolean isSecurityHttpsCertificateTrust() { + return Boolean.parseBoolean( + getEnvironmentVariableOrDefaultValue("SECURITY_HTTPS_CERTIFICATE_TRUST", + DEFAULT_SECURITY_HTTPS_CERTIFICATE_TRUST)); + } + + private static String getEnvironmentVariableOrDefaultValue(String key, String defaultValue) { + String environmentVariable = getEnvironmentVariable(key); + if (environmentVariable == null) { + environmentVariable = defaultValue; + } + return environmentVariable; + } + + private static String getEnvironmentVariable(String propertyKey) { + return System.getProperty(propertyKey, System.getenv(propertyKey)); + } + public static String getSchemaBaseURL() { + return getEnvironmentVariableOrDefaultValue("HOST", DEFAULT_HOST) + SCHEMA_PATH; + } +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/util/FileHandler.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/util/FileHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..01ca9f4322a41acecc74e53ee6765c2e78ac3639 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/util/FileHandler.java @@ -0,0 +1,37 @@ +package org.opengroup.osdu.util; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; + +public class FileHandler { + + private static final ObjectMapper mapper = new ObjectMapper(); + + public static String readFile(String fileName) throws IOException { + InputStream inputStream = FileHandler.class.getResourceAsStream(String.format("/testData/%s",fileName)); + if(inputStream == null) { + throw new IOException(); + } + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + byte[] buffer = new byte[1024]; + int length; + while ((length = inputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, length); + } + return outputStream.toString(StandardCharsets.UTF_8.toString()); + } + + public static <T> T readFile(String fileName, Class<T> targetClass) throws IOException { + InputStream is = getFileStream(fileName); + return mapper.readValue(is, targetClass); + } + + private static InputStream getFileStream(String fileName) { + return FileHandler.class.getResourceAsStream(String.format("/testData/%s", fileName)); + } + +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/util/HTTPClient.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/util/HTTPClient.java new file mode 100644 index 0000000000000000000000000000000000000000..a022c553a447ad6f39e43c6e741fb6ffef8dd5b0 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/util/HTTPClient.java @@ -0,0 +1,122 @@ +package org.opengroup.osdu.util; + +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.WebResource; +import lombok.ToString; +import lombok.extern.java.Log; + +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; +import javax.ws.rs.core.MediaType; +import java.security.SecureRandom; +import java.security.cert.X509Certificate; +import java.util.HashMap; +import java.util.Map; +import java.util.Random; + +import com.google.api.client.util.Strings; + +@Log +@ToString +public class HTTPClient { + + private static Random random = new Random(); + private final int MAX_ID_SIZE = 50; + + protected static final String HEADER_CORRELATION_ID = "correlation-id"; + public static final String INTEGRATION_TESTER_TOKEN = "PRIVILEGED_USER_TOKEN"; + + private static String token = null; + + private OpenIDTokenProvider jwtTokenUtil; + + public HTTPClient() { + token = System.getProperty(INTEGRATION_TESTER_TOKEN, System.getenv(INTEGRATION_TESTER_TOKEN)); + if (token == null || Strings.isNullOrEmpty(token)) { + jwtTokenUtil = new OpenIDTokenProvider(); + token = jwtTokenUtil.getToken(); + } + } + + public synchronized String getAccessToken() { + token = System.getProperty(INTEGRATION_TESTER_TOKEN, System.getenv(INTEGRATION_TESTER_TOKEN)); + + if (token == null || Strings.isNullOrEmpty(token)) { + jwtTokenUtil = new OpenIDTokenProvider(); + token = jwtTokenUtil.getToken(); + } + return "Bearer " + token; + } + + protected static Client getClient() { + TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() { + @Override + public X509Certificate[] getAcceptedIssuers() { + return null; + } + + @Override + public void checkClientTrusted(X509Certificate[] certs, String authType) { + } + + @Override + public void checkServerTrusted(X509Certificate[] certs, String authType) { + } + }}; + + try { + SSLContext sc = SSLContext.getInstance("TLS"); + sc.init(null, trustAllCerts, new SecureRandom()); + HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); + } catch (Exception ignored) { + } + return Client.create(); + } + + public ClientResponse send(String httpMethod, String url, String payLoad, Map<String, String> headers, String token) { + ClientResponse response; + try { + String correlationId = java.util.UUID.randomUUID().toString(); + log.info(String.format("Request correlation id: %s", correlationId)); + headers.put(HEADER_CORRELATION_ID, correlationId); + Client client = getClient(); + client.setReadTimeout(300000); + client.setConnectTimeout(300000); + log.info(String.format("URL: %s", url)); + WebResource webResource = client.resource(url); + response = this.getClientResponse(httpMethod, payLoad, webResource, headers, token); + } catch (Exception e) { + e.printStackTrace(); + throw new AssertionError("Error: Send request error", e); + } + log.info("waiting on response"); + return response; + } + + protected ClientResponse getClientResponse(String httpMethod, String requestBody, WebResource webResource, Map<String, String> headers, String token) { + final WebResource.Builder builder = webResource.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON).header("Authorization", token); + headers.forEach(builder::header); + log.info("making request to datalake api"); + return builder.method(httpMethod, ClientResponse.class, requestBody); + } + + public Map<String, String> getCommonHeader() { + Map<String, String> headers = new HashMap<>(); + headers.put("data-partition-id", Config.getDataPartitionIdTenant1()); + return headers; + } + + public static Map<String, String> overrideHeader(Map<String, String> currentHeaders, String... partitions) { + String value = String.join(",", partitions); + currentHeaders.put("data-partition-id", value); + return currentHeaders; + } + + public static Map<String, String> addHeader(Map<String, String> currentHeaders, String headerKey, String headerValue) { + currentHeaders.put(headerKey, headerValue); + return currentHeaders; + } +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/util/NotFoundIgnoringResponseErrorHandler.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/util/NotFoundIgnoringResponseErrorHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..6520c7c0cba10fc8cbc589b39e6b7ebfdcf3c191 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/util/NotFoundIgnoringResponseErrorHandler.java @@ -0,0 +1,34 @@ +// Copyright © Microsoft Corporation +// +// 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 org.springframework.http.HttpStatus; +import org.springframework.http.client.ClientHttpResponse; +import org.springframework.web.client.DefaultResponseErrorHandler; + +import java.io.IOException; + +public class NotFoundIgnoringResponseErrorHandler extends DefaultResponseErrorHandler { + + @Override + public boolean hasError(ClientHttpResponse response) throws IOException { + return super.hasError(response) && response.getRawStatusCode() != HttpStatus.NOT_FOUND.value(); + } + + @Override + protected boolean hasError(HttpStatus statusCode) { + return super.hasError(statusCode) && statusCode != HttpStatus.NOT_FOUND; + } +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/util/OpenIDTokenProvider.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/util/OpenIDTokenProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..829d1a8bcc5feedf02817a1e6a537a8463c66e37 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/util/OpenIDTokenProvider.java @@ -0,0 +1,79 @@ +/* + * Copyright 2020-2022 Google LLC + * Copyright 2020-2022 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.nimbusds.oauth2.sdk.AuthorizationGrant; +import com.nimbusds.oauth2.sdk.ClientCredentialsGrant; +import com.nimbusds.oauth2.sdk.ParseException; +import com.nimbusds.oauth2.sdk.Scope; +import com.nimbusds.oauth2.sdk.TokenRequest; +import com.nimbusds.oauth2.sdk.TokenResponse; +import com.nimbusds.oauth2.sdk.auth.ClientAuthentication; +import com.nimbusds.oauth2.sdk.auth.ClientSecretBasic; +import com.nimbusds.oauth2.sdk.auth.Secret; +import com.nimbusds.oauth2.sdk.id.ClientID; +import com.nimbusds.openid.connect.sdk.OIDCTokenResponseParser; +import java.io.IOException; +import java.net.URI; +import java.util.Objects; +import net.minidev.json.JSONObject; +import org.opengroup.osdu.util.conf.OpenIDProviderConfig; + +public class OpenIDTokenProvider { + + private static final OpenIDProviderConfig openIDProviderConfig = OpenIDProviderConfig.Instance(); + private static final String ID_TOKEN = "id_token"; + private final AuthorizationGrant clientGrant = new ClientCredentialsGrant(); + private final URI tokenEndpointURI; + private final Scope scope; + private final ClientAuthentication clientAuthentication; + + public OpenIDTokenProvider() { + this.tokenEndpointURI = openIDProviderConfig.getProviderMetadata().getTokenEndpointURI(); + this.scope = new Scope(openIDProviderConfig.getScopes()); + this.clientAuthentication = + new ClientSecretBasic( + new ClientID(openIDProviderConfig.getClientId()), + new Secret(openIDProviderConfig.getClientSecret()) + ); + } + + public String getToken() { + try { + return requestToken(); + } catch (ParseException | IOException e) { + throw new RuntimeException("Unable get credentials from INTEGRATION_TESTER variables", e); + } + } + + private String requestToken() throws ParseException, IOException { + TokenRequest request = new TokenRequest(this.tokenEndpointURI, this.clientAuthentication, this.clientGrant, this.scope); + TokenResponse parse = OIDCTokenResponseParser.parse(request.toHTTPRequest().send()); + + if (!parse.indicatesSuccess()) { + throw new RuntimeException("Unable get credentials from INTEGRATION_TESTER variables"); + } + + JSONObject jsonObject = parse.toSuccessResponse().toJSONObject(); + String idTokenValue = jsonObject.getAsString(ID_TOKEN); + if (Objects.isNull(idTokenValue) || idTokenValue.isEmpty()) { + throw new RuntimeException("Unable get credentials from INTEGRATION_TESTER variables"); + } + return idTokenValue; + } +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/util/SchemaServiceClient.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/util/SchemaServiceClient.java new file mode 100644 index 0000000000000000000000000000000000000000..5b0a2f078607c3bb59f12f9379731b4248f634f7 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/util/SchemaServiceClient.java @@ -0,0 +1,91 @@ +// Copyright © Microsoft Corporation +// +// 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 org.opengroup.osdu.models.schema.SchemaIdentity; +import org.opengroup.osdu.models.schema.SchemaModel; +import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.util.UriComponentsBuilder; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import static java.util.Collections.singletonList; + + +public class SchemaServiceClient { + + private static final Logger LOGGER = Logger.getLogger(SchemaServiceClient.class.getName()); + + private final RestTemplate template; + private final String schemaBaseUrl; + + public SchemaServiceClient(HTTPClient client) { + template = new RestTemplateBuilder() + .errorHandler(new NotFoundIgnoringResponseErrorHandler()) + .additionalInterceptors((request, body, execution) -> { + request.getHeaders().add(HttpHeaders.AUTHORIZATION, client.getAccessToken()); + request.getHeaders().put(HttpHeaders.ACCEPT, singletonList(MediaType.APPLICATION_JSON_VALUE)); + request.getHeaders().add("data-partition-id", Config.getDataPartitionIdTenant1()); + return execution.execute(request, body); + }) + .build(); + schemaBaseUrl = Config.getSchemaBaseURL(); + } + + public boolean exists(SchemaIdentity identity) { + String uri = buildSchemaUri(identity.getId()); + LOGGER.log(Level.INFO, "Checking whether the schema exists with url={0}", uri); + ResponseEntity<?> response = template.exchange(uri, HttpMethod.GET, null, Object.class); + LOGGER.log(Level.INFO, "Finished checking whether the schema exists having identity={0}, response={1}", new Object[]{identity, response}); + return response.getStatusCode() == HttpStatus.OK; + } + + public void create(SchemaModel schema) { + String uri = buildSchemaUri(); + LOGGER.log(Level.INFO, "Creating the schema={0}", schema); + HttpHeaders headers = new HttpHeaders(); + headers.put(HttpHeaders.CONTENT_TYPE, singletonList(MediaType.APPLICATION_JSON_VALUE)); + HttpEntity<SchemaModel> httpEntity = new HttpEntity<>(schema, headers); + ResponseEntity<Object> responseEntity = template.exchange(uri, HttpMethod.PUT, httpEntity, Object.class); + LOGGER.log(Level.INFO, "Finished creating the schema, response={0}", responseEntity); + } + + public void createIfNotExist(SchemaModel schema) { + if (!exists(schema.getSchemaInfo().getSchemaIdentity())) { + create(schema); + } + } + + private String buildSchemaUri(String id) { + return UriComponentsBuilder.fromHttpUrl(schemaBaseUrl) + .path("/schema/{schema-id}") + .buildAndExpand(id).toUriString(); + } + + private String buildSchemaUri() { + return UriComponentsBuilder.fromHttpUrl(schemaBaseUrl) + .path("/schema") + .build().toUriString(); + } + +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/util/Utility.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/util/Utility.java new file mode 100644 index 0000000000000000000000000000000000000000..6858d6b31fce4f786fd3b9c342e128b01b4f4caf --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/util/Utility.java @@ -0,0 +1,18 @@ +package org.opengroup.osdu.util; + +import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; + +public class Utility { + + public static String beautifyJsonString(String payload){ + JsonParser jsonParser = new JsonParser(); + if(payload!=null){ + JsonElement jsonElement = jsonParser.parse(payload); + String beautifiedJson = new GsonBuilder().setPrettyPrinting().create().toJson(jsonElement); + return beautifiedJson; + } + return payload; + } +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/util/conf/AnthosConfig.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/util/conf/AnthosConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..028d670cc53f95aba257b9b61978e8803eaf6b4e --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/util/conf/AnthosConfig.java @@ -0,0 +1,15 @@ +package org.opengroup.osdu.util.conf; + +import java.util.Optional; + +public class AnthosConfig { + + private static final String GROUP_ID_VARIABLE = "GROUP_ID"; + private static final String ENTITLEMENTS_DOMAIN_VARIABLE = "ENTITLEMENTS_DOMAIN"; + + public static void updateEntitlementsDomainVariable() { + String groupId = Optional.ofNullable(System.getProperty(GROUP_ID_VARIABLE, System.getenv(GROUP_ID_VARIABLE))) + .orElse(""); + System.setProperty(ENTITLEMENTS_DOMAIN_VARIABLE, groupId); + } +} diff --git a/search-acceptance-test/src/test/java/org/opengroup/osdu/util/conf/OpenIDProviderConfig.java b/search-acceptance-test/src/test/java/org/opengroup/osdu/util/conf/OpenIDProviderConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..9abbc07ccaee37a68a66329d4bc50cb2980da766 --- /dev/null +++ b/search-acceptance-test/src/test/java/org/opengroup/osdu/util/conf/OpenIDProviderConfig.java @@ -0,0 +1,74 @@ +/* + * Copyright 2020-2022 Google LLC + * Copyright 2020-2022 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.conf; + +import com.nimbusds.oauth2.sdk.http.HTTPRequest; +import com.nimbusds.oauth2.sdk.http.HTTPResponse; +import com.nimbusds.oauth2.sdk.id.Issuer; +import com.nimbusds.openid.connect.sdk.op.OIDCProviderConfigurationRequest; +import com.nimbusds.openid.connect.sdk.op.OIDCProviderMetadata; + +public class OpenIDProviderConfig { + + public static final String TEST_OPENID_PROVIDER_CLIENT_ID = "PRIVILEGED_USER_OPENID_PROVIDER_CLIENT_ID"; + public static final String TEST_OPENID_PROVIDER_CLIENT_SECRET = "PRIVILEGED_USER_OPENID_PROVIDER_CLIENT_SECRET"; + public static final String TEST_OPENID_PROVIDER_URL = "TEST_OPENID_PROVIDER_URL"; + + private String clientId; + private String url; + private String clientSecret; + private final String[] scopes = {"openid"}; + private static final OpenIDProviderConfig openIDProviderConfig = new OpenIDProviderConfig(); + private static OIDCProviderMetadata providerMetadata; + + public static OpenIDProviderConfig Instance() { + try { + openIDProviderConfig.clientId = System.getProperty(TEST_OPENID_PROVIDER_CLIENT_ID, + System.getenv(TEST_OPENID_PROVIDER_CLIENT_ID)); + openIDProviderConfig.url = System.getProperty(TEST_OPENID_PROVIDER_URL, + System.getenv(TEST_OPENID_PROVIDER_URL)); + openIDProviderConfig.clientSecret = System.getProperty(TEST_OPENID_PROVIDER_CLIENT_SECRET, + System.getenv(TEST_OPENID_PROVIDER_CLIENT_SECRET)); + + Issuer issuer = new Issuer(openIDProviderConfig.url); + OIDCProviderConfigurationRequest request = new OIDCProviderConfigurationRequest(issuer); + HTTPRequest httpRequest = request.toHTTPRequest(); + HTTPResponse httpResponse = httpRequest.send(); + providerMetadata = OIDCProviderMetadata.parse(httpResponse.getContentAsJSONObject()); + } catch (Exception e) { + throw new RuntimeException("Malformed token provider configuration", e); + } + return openIDProviderConfig; + } + + public String getClientId() { + return clientId; + } + + public String getClientSecret() { + return clientSecret; + } + + public String[] getScopes() { + return scopes; + } + + public OIDCProviderMetadata getProviderMetadata() { + return providerMetadata; + } +} diff --git a/search-acceptance-test/src/test/resources/cucumber.properties b/search-acceptance-test/src/test/resources/cucumber.properties new file mode 100644 index 0000000000000000000000000000000000000000..8e0e1c6c4f9f4f614deeb00ff72efe063b25889f --- /dev/null +++ b/search-acceptance-test/src/test/resources/cucumber.properties @@ -0,0 +1,2 @@ +# tag autocomplete disabled by default +cucumber.options=--tags '@default,@health,@autocomplete,@SpatialLongitudeStandardRange' diff --git a/search-acceptance-test/src/test/resources/features/health/Health.feature b/search-acceptance-test/src/test/resources/features/health/Health.feature new file mode 100644 index 0000000000000000000000000000000000000000..0b88dd55ce770f4c0f19eeb5a776fdf191b12d31 --- /dev/null +++ b/search-acceptance-test/src/test/resources/features/health/Health.feature @@ -0,0 +1,11 @@ +Feature: To verify health api endpoints content + + @health + Scenario: Verify liveness check endpoint content + Given I send get request to liveness check endpoint + Then service should respond back with 200 in response + + @health + Scenario: Verify readiness check endpoint content + Given I send get request to readiness check endpoint + Then service should respond back with 200 in response diff --git a/search-acceptance-test/src/test/resources/features/info/Info.feature b/search-acceptance-test/src/test/resources/features/info/Info.feature new file mode 100644 index 0000000000000000000000000000000000000000..92a5e03726dd2f968d6445b5bd7e10fa183b4c40 --- /dev/null +++ b/search-acceptance-test/src/test/resources/features/info/Info.feature @@ -0,0 +1,11 @@ +Feature: Fetch info about maven build and git repository. + + @default + Scenario: Verify version info endpoint content + When I send get request to version info endpoint + Then I should get version info in response + + @default + Scenario: Verify version info endpoint content for request with trailing slash + When I send get request to version info endpoint with trailing slash + Then I should get version info in response diff --git a/search-acceptance-test/src/test/resources/features/query/collaboration/QueryCollaboration.feature b/search-acceptance-test/src/test/resources/features/query/collaboration/QueryCollaboration.feature new file mode 100644 index 0000000000000000000000000000000000000000..b705bcb4e0065994b365d00ac930c235cb7e554b --- /dev/null +++ b/search-acceptance-test/src/test/resources/features/query/collaboration/QueryCollaboration.feature @@ -0,0 +1,51 @@ +Feature: Search with collaboration header different queries + To allow a user to find his data quickly, search should offer multiple ways to search data. + + Background: + Given the schema is created with the following kind + | kind | schemaFile | + | tenant1:search-collab<timestamp>:test-data--Integration:1.0.6 | records_6 | + | tenant1:search-collab<timestamp>:test-data--Integration:1.0.7 | records_7 | + | tenant1:search-collab<timestamp>:test-data--Integration:1.0.8 | records_8 | + + @xcollab + Scenario Outline: Ingest records for the given kind with xcollaboration header + When I ingest records with the <recordFile> with <acl> for a given <kind> with <xcollaboration> header + Examples: + | kind | recordFile | acl | xcollaboration | + | "tenant1:search-collab<timestamp>:test-data--Integration:1.0.6" | "records_6" | "data.default.viewers@tenant1" | "id=96d5550e-2b5e-4b84-825c-646339ee5fc7,application=pws" | + | "tenant1:search-collab<timestamp>:test-data--Integration:1.0.7" | "records_7" | "data.default.viewers@tenant1" | "" | + + @xcollab + Scenario Outline: Search data in a given kind with xcollaboration header + When I send <query> with <kind> + And I send request with <xcollaboration> header + Then I should get in response <count> records with <returned_fields> + + Examples: + | kind | query | returned_fields | count | xcollaboration | + | "tenant1:search-collab<timestamp>:test-data--Integration:1.0.6" | None | All | 3 | "id=96d5550e-2b5e-4b84-825c-646339ee5fc7,application=pws" | + | "tenant1:search-collab<timestamp>:test-data--Integration:1.0.6" | None | All | 0 | "" | + | "tenant1:search-collab<timestamp>:test-data--Integration:1.0.7" | None | All | 3 | "" | + | "tenant1:search-collab<timestamp>:test-data--Integration:1.0.7" | None | All | 0 | "id=96d5550e-2b5e-4b84-825c-646339ee5fc7,application=pws" | + + @xcollab + Scenario Outline: Ingest records for the given kind with xcollaboration header + When I ingest records with the <recordFile> with <acl> for a given <kind> with <xcollaboration> header + Examples: + | kind | recordFile | acl | xcollaboration | + | "tenant1:search-collab<timestamp>:test-data--Integration:1.0.8" | "records_8" | "data.default.viewers@tenant1" | "" | + | "tenant1:search-collab<timestamp>:test-data--Integration:1.0.8" | "records_9" | "data.default.viewers@tenant1" | "id=96d5550e-2b5e-4b84-825c-646339ee5fc7,application=pws" | + + @xcollab + Scenario Outline: Search data in a given kind with xcollaboration header + When I send <query> with <kind> + And I send request with <xcollaboration> header + Then I should get in response <count> records with <returned_fields> + + Examples: + | kind | query | returned_fields | count | xcollaboration | + | "tenant1:search-collab<timestamp>:test-data--Integration:1.0.8" | "data.Field:SOR" | All | 3 | "" | + | "tenant1:search-collab<timestamp>:test-data--Integration:1.0.8" | "data.Field:SOR" | All | 0 | "id=96d5550e-2b5e-4b84-825c-646339ee5fc7,application=pws" | + | "tenant1:search-collab<timestamp>:test-data--Integration:1.0.8" | "data.Field:Namespace" | All | 0 | "" | + | "tenant1:search-collab<timestamp>:test-data--Integration:1.0.8" | "data.Field:Namespace" | All | 3 | "id=96d5550e-2b5e-4b84-825c-646339ee5fc7,application=pws" | diff --git a/search-acceptance-test/src/test/resources/features/query/singlecluster/Query.feature b/search-acceptance-test/src/test/resources/features/query/singlecluster/Query.feature new file mode 100644 index 0000000000000000000000000000000000000000..21079e6ef31db806162c5ecfa5ab6ca0e251a2a3 --- /dev/null +++ b/search-acceptance-test/src/test/resources/features/query/singlecluster/Query.feature @@ -0,0 +1,326 @@ +Feature: Search with different queries + To allow a user to find his data quickly, search should offer multiple ways to search data. + + Background: + Given the schema is created with the following kind + | kind | schemaFile | + | tenant1:search<timestamp>:test-data--Integration:1.0.1 | records_1 | + | tenant1:search<timestamp>:test-data2--Integration:1.0.2 | records_2 | + | tenant1:well<timestamp>:test-data3--Integration:1.0.3 | records_4 | + | tenant1:search-collab<timestamp>:test-data--Integration:1.0.6 | records_6 | + | tenant1:search-collab<timestamp>:test-data--Integration:1.0.7 | records_7 | + | tenant1:search-collab<timestamp>:test-data--Integration:1.0.8 | records_8 | + + @default + Scenario Outline: Ingest records for the given kind + When I ingest records with the <recordFile> with <acl> for a given <kind> + Examples: + | kind | recordFile | acl | + | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | "records_1" | "data.default.viewers@tenant1"| + | "tenant1:search<timestamp>:test-data2--Integration:1.0.2" | "records_2" | "data.default.viewers@tenant1"| + | "tenant1:well<timestamp>:test-data3--Integration:1.0.3" | "records_4" | "data.default.viewers@tenant1" | + + @default + Scenario Outline: Search data in a given kind + When I send <query> with <kind> + And I limit the count of returned results to <limit> + And I set the offset of starting point as <offset> + And I set the fields I want in response as <returned_fields> + And I send request to tenant <tenant> + Then I should get in response <count> records with <returned_fields> + + Examples: + | tenant | kind | query | limit | offset | returned_fields | count | + | "tenant1" | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | "data.OriginalOperator:OFFICE4" | None | None | All | 1 | + | "tenant1" | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | None | 0 | None | NULL | 3 | + | "tenant1" | "tenant1:search<timestamp>:test-data2--Integration:1.0.2" | None | 0 | None | NULL | 3 | + | "tenant1" | "tenant1:search<timestamp>:test-data--Integration:1.0.1,tenant1:search<timestamp>:test-data2--Integration:1.0.2" | None | 0 | None | NULL | 6 | + | "tenant1" | ["tenant1:search<timestamp>:test-data--Integration:1.0.1", "tenant1:search<timestamp>:test-data2--Integration:1.0.2"] | None | 0 | None | NULL | 6 | + ######################################Range Query test cases########################################################################## + | "tenant1" | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | "data.Rank:{1 TO 3}" | None | None | id,index | 1 | + | "tenant1" | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | "data.Rank:[10 TO 20]" | None | None | All | 1 | + | "tenant1" | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | "data.Rank:>=2" | None | None | All | 2 | + | "tenant1" | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | "data.Established:{* TO 2012-01-01}" | None | None | All | 2 | + #####################################Text Query test cases########################################################################### + | "tenant1" | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | "OSDU" | None | None | All | 3 | + | "tenant1" | "tenant1:search<timestamp>:test-data2--Integration:1.0.2" | "data.OriginalOperator:OFFICE6" | None | None | All | 1 | + | "tenant1" | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | ""data.OriginalOperator:OFFICE2" \| data.OriginalOperator:OFFICE3" | None | None | All | 1 | + | "tenant1" | "tenant1:search<timestamp>:test-data2--Integration:1.0.2" | "data.Well\*:(Data Lake Cloud)" | None | None | All | 3 | + + @default + Scenario Outline: Search data in a given singe kind or multi-kinds that index (indices) of one or more kinds do not exist + When I send <query> with <kind> + And I limit the count of returned results to <limit> + And I set the offset of starting point as <offset> + And I set the fields I want in response as <returned_fields> + And I send request to tenant <tenant> + Then I should get in response <count> records with <returned_fields> + + Examples: + | tenant | kind | query | limit | offset | returned_fields | count | + | "tenant1" | "tenant1:search<timestamp>:test-data--non-existing:1.0.1" | None | None | None | NULL | 0 | + | "tenant1" | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | None | 0 | None | NULL | 3 | + | "tenant1" | "tenant1:search<timestamp>:test-data--non-existing:1.0.1,tenant1:search<timestamp>:test-data--Integration:1.0.1" | None | 0 | None | NULL | 3 | + + @default + Scenario Outline: Search data in a given kind with hundreds of copies + When I send <query> with <number> copies of <kind> + And I limit the count of returned results to <limit> + And I set the offset of starting point as <offset> + And I set the fields I want in response as <returned_fields> + And I send request to tenant <tenant> + Then I should get in response <count> records with <returned_fields> + + Examples: + | tenant | kind | number | query | limit | offset | returned_fields | count | + | "tenant1" | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | 295 | "data.OriginalOperator:OFFICE4" | None | None | All | 1 | + | "tenant1" | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | 295 | None | 0 | None | NULL | 3 | + | "tenant1" | "tenant1:search<timestamp>:test-data2--Integration:1.0.2" | 295 | None | 0 | None | NULL | 3 | + + @default + Scenario Outline: Search data in a given a kind with invalid inputs + When I send <query> with <kind> + And I limit the count of returned results to <limit> + And I set the offset of starting point as <offset> + And I send request to tenant <tenant> + Then I should get <response_code> response with reason: <reponse_type>, message: <response_message> and errors: <errors> + + Examples: + | tenant | kind | query | limit | offset | response_code | reponse_type | response_message | errors | + | "tenant1" | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | None | -1 | None | 400 | "Bad Request" | "Invalid parameters were given on search request" | "'limit' must be equal or greater than 0" | + | "tenant1" | "invalid" | None | 1 | None | 400 | "Bad Request" | "Invalid parameters were given on search request" | "Not a valid record kind format. Found: invalid" | + | "tenant1" | "tenant1:search<timestamp>:test-data--Integration:1.0.1,,tenant1:search<timestamp>:test-data2--Integration:1.0.2" | None | 1 | None | 400 | "Bad Request" | "Invalid parameters were given on search request" | "Not a valid record kind format. Found: tenant1:search<timestamp>:test-data--Integration:1.0.1,,tenant1:search<timestamp>:test-data2--Integration:1.0.2" | + | "tenant1" | 123456789 | None | 1 | None | 400 | "Bad Request" | "Invalid parameters were given on search request" | "Not a valid record kind type. Found: 123456789" | + | "tenant1" | [] | None | 1 | None | 400 | "Bad Request" | "Invalid parameters were given on search request" | "Record kind can't be null or empty. Found: []" | + | "tenant1" | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | None | 1 | -1 | 400 | "Bad Request" | "Invalid parameters were given on search request" | "'offset' must be equal or greater than 0" | + | "tenant2" | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | None | None | None | 401 | "Access denied" | "The user is not authorized to perform this action" | "" | + + @default + Scenario Outline: Search data across the kinds with bounding box inputs + When I send <query> with <kind> + And I apply geographical query on field <field> + And define bounding box with points (<top_left_latitude>, <top_left_longitude>) and (<bottom_right_latitude>, <bottom_right_longitude>) + Then I should get in response <count> records + + Examples: + | kind | query | field | top_left_latitude | top_left_longitude | bottom_right_latitude | bottom_right_longitude | count | + | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | None | "data.Location" | 45 | -100 | 0 | 0 | 2 | + | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | None | "data.Location" | 45 | -80 | 0 | 0 | 0 | + | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | "data.OriginalOperator:OFFICE4" | "data.Location" | 45 | -100 | 0 | 0 | 1 | + | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | "data.OriginalOperator:OFFICE4" | "data.Location" | 10 | -100 | 0 | 0 | 0 | + + @default + Scenario Outline: Search data across the kinds with invalid bounding box inputs + When I send <query> with <kind> + And I apply geographical query on field <field> + And define bounding box with points (<top_left_latitude>, <top_left_longitude>) and (<bottom_right_latitude>, <bottom_right_longitude>) + Then I should get <response_code> response with reason: <reponse_type>, message: <response_message> and errors: <errors> + + Examples: + | kind | query | field | top_left_latitude | top_left_longitude | bottom_right_latitude | bottom_right_longitude | response_code | reponse_type | response_message | errors | + | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | "data.OriginalOperator:OFFICE4" | "data.Location" | 0 | 0 | 0 | 0 | 400 | "Bad Request" | "Invalid parameters were given on search request" | "top latitude cannot be the same as bottom latitude: 0.0 == 0.0" | + | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | "data.OriginalOperator:OFFICE4" | "data.Location" | 0 | -100 | -10 | -100 | 400 | "Bad Request" | "Invalid parameters were given on search request" | "left longitude cannot be the same as right longitude: -100.0 == -100.0" | + | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | "data.OriginalOperator:OFFICE4" | "data.Location" | 10 | -100 | 10 | 0 | 400 | "Bad Request" | "Invalid parameters were given on search request" | "top latitude cannot be the same as bottom latitude: 10.0 == 10.0" | + | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | "data.OriginalOperator:OFFICE4" | "data.Location" | 45 | -100 | -95 | 0 | 400 | "Bad Request" | "Invalid parameters were given on search request" | "'latitude' value is out of the range [-90, 90]" | + | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | "data.OriginalOperator:OFFICE4" | "data.Location" | 0 | -100 | 10 | 0 | 400 | "Bad Request" | "Invalid parameters were given on search request" | "top corner is below bottom corner: 0.0 vs. 10.0" | + | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | "data.OriginalOperator:OFFICE4" | "data.Location" | None | None | 0 | 0 | 400 | "Bad Request" | "Invalid parameters were given on search request" | "Invalid payload" | + + @default + Scenario Outline: Search data across the kinds with distance inputs + When I send <query> with <kind> + And I apply geographical query on field <field> + And define focus coordinates as (<latitude>, <longitude>) and search in a <distance> radius + Then I should get in response <count> records + + Examples: + | kind | query | field | latitude | longitude | distance | count | + | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | "Under development" | "data.Location" | 0 | 0 | 20000000 | 3 | + | "tenant1:search<timestamp>:*:*" | "TEXAS OR TX" | "data.Location" | 45 | -100 | 20000000 | 2 | + + @SpatialLongitudeStandardRange + Scenario Outline: Search data across the kinds with invalid distance inputs + When I send <query> with <kind> + And I apply geographical query on field <field> + And define focus coordinates as (<latitude>, <longitude>) and search in a <distance> radius + Then I should get <response_code> response with reason: <reponse_type>, message: <response_message> and errors: <errors> + + Examples: + | kind | query | field | latitude | longitude | distance | response_code | reponse_type | response_message | errors | + | "tenant1:search<timestamp>:*:*" | "OFFICE - 2" | "data.Location" | -45 | -200 | 1000 | 400 | "Bad Request" | "Invalid parameters were given on search request" | "'longitude' value is out of the range [-180, 180]" | + | "tenant1:search<timestamp>:*:*" | "TEXAS OR USA" | "data.Location" | -95 | -100 | 1000 | 400 | "Bad Request" | "Invalid parameters were given on search request" | "'latitude' value is out of the range [-90, 90]" | + | "tenant1:search<timestamp>:*:*" | "Harris" | "ZipCode" | -45 | -200 | 1000 | 400 | "Bad Request" | "Invalid parameters were given on search request" | "'longitude' value is out of the range [-180, 180]" | + | "tenant1:search<timestamp>:*:*" | "Harris" | "ZipCode" | 4 | 2 | 0 | 400 | "Bad Request" | "Invalid parameters were given on search request" | "'distance' must be greater than 0" | + + @SpatialLongitudeExtendedRange + Scenario Outline: Search data across the kinds with invalid distance inputs + When I send <query> with <kind> + And I apply geographical query on field <field> + And define focus coordinates as (<latitude>, <longitude>) and search in a <distance> radius + Then I should get <response_code> response with reason: <reponse_type>, message: <response_message> and errors: <errors> + + Examples: + | kind | query | field | latitude | longitude | distance | response_code | reponse_type | response_message | errors | + | "tenant1:search<timestamp>:*:*" | "OFFICE - 2" | "data.Location" | -45 | -400 | 1000 | 400 | "Bad Request" | "Invalid parameters were given on search request" | "'longitude' value is out of the range [-360, 360]" | + | "tenant1:search<timestamp>:*:*" | "TEXAS OR USA" | "data.Location" | -95 | -100 | 1000 | 400 | "Bad Request" | "Invalid parameters were given on search request" | "'latitude' value is out of the range [-90, 90]" | + | "tenant1:search<timestamp>:*:*" | "Harris" | "ZipCode" | -45 | -400 | 1000 | 400 | "Bad Request" | "Invalid parameters were given on search request" | "'longitude' value is out of the range [-360, 360]" | + | "tenant1:search<timestamp>:*:*" | "Harris" | "ZipCode" | 4 | 2 | 0 | 400 | "Bad Request" | "Invalid parameters were given on search request" | "'distance' must be greater than 0" | + + @default + Scenario Outline: Search data across the kinds with intersection polygon inputs + When I send <query> with <kind> + And I apply geographical query on field <field> + And define intersection polygon with points (<lat1>, <lon1>) and (<lat2>, <lon2>) and (<lat3>, <lon3>) and (<lat4>, <lon4>) and (<lat5>, <lon5>) + Then I should get in response <count> records + Examples: + | kind | query | field | lat1 | lon1 | lat2 | lon2 | lat3 | lon3 | lat4 | lon4 | lat5 | lon5 | count | + | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | None | "data.Location" | 90 | -180 | 90 | 180 | -90 | 180 | -90 | -180 | 90 | -180 | 3 | + + @default + Scenario Outline: Search data across the kinds + When I send <query> with <kind> + And I limit the count of returned results to <limit> + And I set the offset of starting point as <offset> + And I set the fields I want in response as <returned_fields> + And I send request to tenant <tenant> + Then I should get in response <count> records + + Examples: + | tenant | kind | query | limit | offset | returned_fields | count | + | "tenant1" | "tenant1:search<timestamp>:*:*" | None | 1 | None | All | 1 | + | "tenant1" | "tenant1:search<timestamp>:*:*" | None | None | 2 | All | 4 | + | "tenant1" | "tenant1:search<timestamp>:*:*" | None | None | None | Country | 6 | + | "tenant1" | "tenant1:search<timestamp>:*:*" | "OSDU OFFICE*" | None | None | All | 6 | + | "tenant1" | "tenant1:search<timestamp>:*:*" | "SCHLUM OFFICE" | None | None | All | 6 | + | "tenant1" | "tenant1:search<timestamp>:*:*" | ""SCHLUM OFFICE"" | None | None | All | 0 | + | "tenant1" | "tenant1:search<timestamp>:*:*" | "data.Country:USA" | None | None | All | 2 | + | "tenant1" | "tenant1:search<timestamp>:*:*" | "TEXAS AND OFFICE3" | None | None | All | 1 | + | "tenant1" | "tenant1:search<timestamp>:*:*" | "data.OriginalOperator:(OFFICE5 OR OFFICE2)" | None | None | All | 2 | + | "tenant1" | "tenant1:search<timestamp>:*:*" | "data.OriginalOperator:STI OR HT" | None | None | All | 0 | + | "tenant1" | "tenant1:search<timestamp>:*:*" | "_exists_:data.Basin" | None | None | All | 4 | + | "tenant1" | "tenant1:search<timestamp>:*:*" | "data.Well\*:"Data Lake Cloud"" | None | None | All | 5 | + + @default + Scenario Outline: Search data across the kinds with bounding box inputs + When I send <query> with <kind> + And I apply geographical query on field <field> + And define bounding box with points (<top_left_latitude>, <top_left_longitude>) and (<bottom_right_latitude>, <bottom_right_longitude>) + Then I should get in response <count> records + + Examples: + | kind | query | field | top_left_latitude | top_left_longitude | bottom_right_latitude | bottom_right_longitude | count | + | "tenant1:search<timestamp>:*:*" | None | "data.Location" | 45 | -100 | 0 | 0 | 3 | + | "tenant1:search<timestamp>:*:*" | None | "data.Location" | 10 | -100 | 0 | 0 | 0 | + + @default + Scenario Outline: Search data across the kinds with geo polygon inputs + When I send <query> with <kind> + And define geo polygon with following points <points_list> + And I apply geographical query on field <field> + Then I should get in response <count> records + Examples: + | kind | query | field | points_list | count | + | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | None | "data.Location" | (26.12362;-112.226716) , (26.595873;-68.457186) , (52.273184;-93.593904) | 2 | + | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | None | "data.Location" | (33.201112;-113.282863) , (33.456305;-98.269744) , (52.273184;-93.593904) | 0 | + | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | "data.OriginalOperator:OFFICE4" | "data.Location" | (26.12362;-112.226716) , (26.595873;-68.457186) , (52.273184;-93.593904) | 1 | + | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | None | "data.Location" | (14.29056;72.18936) , (22.13762;72.18936) , (22.13762;77.18936) , (14.29056;77.18936) , (14.29056;72.18936) | 1 | + + @default + Scenario Outline: Search data across the kinds with invalid geo polygon inputs + When I send <query> with <kind> + And define geo polygon with following points <points_list> + And I apply geographical query on field <field> + Then I should get <response_code> response with reason: <response_type>, message: <response_message> and errors: <errors> + + Examples: + | kind | query | field | points_list | response_code | response_type | response_message | errors | + | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | None | "data.Location" | (26.595873;-68.457186) , (52.273184;-93.593904) | 400 | "Bad Request" | "Invalid parameters were given on search request" | "too few points defined for geo polygon query" | + | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | None | "data.Location" | (516.595873;-68.457186) , (52.273184;-94.593904) , (95.273184;-93.593904) | 400 | "Bad Request" | "Invalid parameters were given on search request" | "'latitude' value is out of the range [-90, 90]" | + + @default + Scenario Outline: Search data and sort the results with the given sort fields and order + When I send <query> with <kind> + And I want the results sorted by <sort> + Then I should get records in right order first record id: <first_record_id>, last record id: <last_record_id> + Examples: + | kind | query | sort | first_record_id | last_record_id | + | "tenant1:search<timestamp>:*:*" | None | {"field":["data.OriginalOperator","data.WellType"],"order":["ASC", "ASC"]} | "tenant1:search<timestamp>:1" | "tenant1:search<timestamp>:2.0.0:3" | + | "tenant1:search<timestamp>:*:*" | None | {"field":["id"],"order":["DESC"]} | "tenant1:search<timestamp>:3" | "tenant1:search<timestamp>:1" | + | "tenant1:search<timestamp>:*:*" | None | {"field":["namespace","data.Rank"],"order":["ASC","DESC"]} | "tenant1:search<timestamp>:3" | "tenant1:search<timestamp>:2.0.0:1" | + | "tenant1:well<timestamp>:test-data3--Integration:1.0.3" | None | {"field":["nested(data.VerticalMeasurements, VerticalMeasurement, min)"],"order":["ASC"]} | "tenant1:well<timestamp>:2" | "tenant1:well<timestamp>:1" | + | "tenant1:well<timestamp>:test-data3--Integration:1.0.3" | None | {"field":["nested(data.FacilityOperators, TerminationDateTime, min)"],"order":["DESC"]} | "tenant1:well<timestamp>:2" | "tenant1:well<timestamp>:1" | + | "tenant1:well<timestamp>:test-data3--Integration:1.0.3" | None | {"field":["nested(data.VerticalMeasurements, VerticalMeasurement, min)"],"order":["ASC"], "filter": ["nested(data.VerticalMeasurements, (VerticalMeasurement:(>30)))"]} | "tenant1:well<timestamp>:1" | "tenant1:well<timestamp>:2" | + + @default + Scenario Outline: Search data in a given kind with invalid sort field + When I send <query> with <kind> + And I want the results sorted by <sort> + Then I should get <response_code> response with reason: <response_type>, message: <response_message> and errors: <errors> + + Examples: + | kind | query | sort | response_code | response_type | response_message | errors | + | "tenant1:search<timestamp>:*:*" | None | {"field":[],"order":["ASC"]} | 400 | "Bad Request" | "Invalid parameters were given on search request" | "'sort.field' can not be null or empty" | + | "tenant1:search<timestamp>:*:*" | None | {"field":["id"],"order":[]} | 400 | "Bad Request" | "Invalid parameters were given on search request" | "'sort.order' can not be null or empty" | + | "tenant1:search<timestamp>:*:*" | None | {"field":["id","data.Rank"],"order":["DESC"]} | 400 | "Bad Request" | "Invalid parameters were given on search request" | "'sort.field' and 'sort.order' size do not match" | + | "tenant1:search<timestamp>:*:*" | None | {"field":["id"],"order":[null]} | 400 | "Bad Request" | "Invalid parameters were given on search request" | "Not a valid order option. It can only be either 'ASC' or 'DESC'" | + + @default + Scenario Outline: Search data in a given kind with different searchAs modes + When I send <query> with <kind> + And I want to search as owner <is_owner> + Then I should get in response <count> records when searchAs owner is <is_owner> + + Examples: + | kind | query | is_owner | count | + | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | None | true | 3 | + | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | None | false | 3 | + | "tenant1:search<timestamp>:test-data2--Integration:1.0.2" | None | false | 3 | + | "tenant1:search<timestamp>:*:*" | None | false | 6 | + | "tenant1:search<timestamp>:*:*" | "OFFICE4" | true | 1 | + | "tenant1:search<timestamp>:*:*" | None | None | 6 | + + @default + Scenario Outline: Search data in a given kind with aggregateBy field + When I send <query> with <kind> + And I want to aggregate by <aggregateBy> + Then I should get <count> unique values + + Examples: + | kind | query | aggregateBy | count | + | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | None | "namespace" | 1 | + | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | None | "type" | 1 | + | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | "data.OriginalOperator:OFFICE4" | "data.Rank" | 1 | + | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | None | "data.Rank" | 3 | + | "tenant1:well<timestamp>:test-data3--Integration:1.0.3" | None | "nested(data.VerticalMeasurements, VerticalMeasurement)" | 2 | + | "tenant1:well<timestamp>:test-data3--Integration:1.0.3" | nested(data.VerticalMeasurements, (VerticalMeasurement:(<15))) | "nested(data.VerticalMeasurements, VerticalMeasurement)" | 1 | + + @default + Scenario Outline: Search data in a given kind with nested queries + When I send <query> with <kind> + And I send request to tenant <tenant> + Then I should get in response <count> records + + Examples: + | tenant | kind | query | count | + | "tenant1" | "tenant1:well<timestamp>:test-data3--Integration:1.0.3" | "nested(data.VerticalMeasurements, (VerticalMeasurement:(>15.0) AND EffectiveDateTime:[2010-02-13T09:13:15.55+0000 TO 2021-02-13T09:13:15.55+0000]))" | 1 | + | "tenant1" | "tenant1:well<timestamp>:test-data3--Integration:1.0.3" | "nested(data.VerticalMeasurements, (VerticalMeasurement:(>15.0) OR EffectiveDateTime:[2010-02-13T09:13:15.55+0000 TO 2021-02-13T09:13:15.55+0000]))" | 2 | + | "tenant1" | "tenant1:well<timestamp>:test-data3--Integration:1.0.3" | "data.Source:"Example*" AND nested(data.VerticalMeasurements, (VerticalMeasurementDescription:"Example*"))" | 2 | + | "tenant1" | "tenant1:well<timestamp>:test-data3--Integration:1.0.3" | "data.Source:"Example*" AND nested(data.VerticalMeasurements, (VerticalMeasurementDescription:"Example*")) AND data.FacilityName:"NOT EXISTING NAME"" | 0 | + | "tenant1" | "tenant1:well<timestamp>:test-data3--Integration:1.0.3" | "nested(data.VerticalMeasurements, (VerticalMeasurement:(<15)))" | 1 | + | "tenant1" | "tenant1:well<timestamp>:test-data3--Integration:1.0.3" | "nested(data.FacilityOperators, (TerminationDateTime:[2023 TO 2026] AND EffectiveDateTime:[* TO 2021])) NOT nested(data.VerticalMeasurements, (VerticalMeasurement:(>20000)))" | 1 | + | "tenant1" | "tenant1:well<timestamp>:test-data3--Integration:1.0.3" | "nested(data.FacilityOperators, (TerminationDateTime:[2023 TO 2026])) OR nested(data.VerticalMeasurements, (VerticalMeasurement:(>15)))" | 2 | + | "tenant1" | "tenant1:well<timestamp>:test-data3--Integration:1.0.3" | "nested(data.VerticalMeasurements, (VerticalMeasurementID:"Other*" AND VerticalMeasurement:(<30)))" | 1 | + + @autocomplete + Scenario Outline: Autocomplete for given phrases is returned + When I send <query> with <kind> + And I limit the count of returned results to <limit> + And I set the offset of starting point as <offset> + And I set the fields I want in response as <returned_fields> + And I set autocomplete phrase to <autocomplete_phrase> + And I send request to tenant <tenant> + Then I should get in response <count> records with <returned_fields> + And I should get following autocomplete suggesstions <suggestions> + + Examples: + | tenant | kind | query | limit | offset | returned_fields | count | autocomplete_phrase | suggestions | + | "tenant1" | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | "data.OriginalOperator:OFFICE4" | None | None | All | 1 | data | Data Lake Cloud | diff --git a/search-acceptance-test/src/test/resources/features/query/singlecluster/SystemMetadata.feature b/search-acceptance-test/src/test/resources/features/query/singlecluster/SystemMetadata.feature new file mode 100644 index 0000000000000000000000000000000000000000..48e959d7acd9b0740064638fc92ed4a2dc579085 --- /dev/null +++ b/search-acceptance-test/src/test/resources/features/query/singlecluster/SystemMetadata.feature @@ -0,0 +1,45 @@ +Feature: Search with different queries + To allow a user to exclude indices of the system/meta data from the search results unless the indices (kinds) of the system/meta data are explicitly specified in the search query. + + Background: + Given the schema is created with the following kind + | kind | schemaFile | + | tenant1:normal<timestamp>:test-data--Integration:2.0.0 | metadata_test_records_1 | + | tenant1:normal<timestamp>:test-data--Integration:2.1.0 | metadata_test_records_2 | + | .opendes:dot<timestamp>:test-data--Integration:2.0.0 | metadata_test_records_3 | + | .opendes:dot<timestamp>:test-data--Integration:2.1.0 | metadata_test_records_4 | + | system-meta-data:system<timestamp>:test-data--Integration:2.0.0 | metadata_test_records_5 | + | system-meta-data:system<timestamp>:test-data--Integration:2.1.0 | metadata_test_records_6 | + + @default + Scenario Outline: Ingest records for the given kind + When I ingest records with the <recordFile> with <acl> for a given <kind> + Examples: + | kind | recordFile | acl | + | "tenant1:normal<timestamp>:test-data--Integration:2.0.0" | "metadata_test_records_1" | "data.default.viewers@tenant1" | + | "tenant1:normal<timestamp>:test-data--Integration:2.1.0" | "metadata_test_records_2" | "data.default.viewers@tenant1" | + | ".opendes:dot<timestamp>:test-data--Integration:2.0.0" | "metadata_test_records_3" | "data.default.viewers@tenant1" | + | ".opendes:dot<timestamp>:test-data--Integration:2.1.0" | "metadata_test_records_4" | "data.default.viewers@tenant1" | + | "system-meta-data:system<timestamp>:test-data--Integration:2.0.0" | "metadata_test_records_5" | "data.default.viewers@tenant1" | + | "system-meta-data:system<timestamp>:test-data--Integration:2.1.0" | "metadata_test_records_6" | "data.default.viewers@tenant1" | + + @default + Scenario Outline: Search data in a given kind with aggregateBy field + When I send <query> with <kind> + And I want to aggregate by <aggregateBy> + Then I should get <includedKinds> and should not get <excludedKinds> from aggregations + Examples: + | kind | query | aggregateBy | includedKinds | excludedKinds | + | "*:*:*:*" | "" | "kind" | "tenant1:normal<timestamp>:test-data--Integration:2.0.0,tenant1:normal<timestamp>:test-data--Integration:2.1.0" | ".opendes:dot<timestamp>:test-data--Integration:2.0.0,system-meta-data:system<timestamp>:test-data--Integration:2.0.0" | + | "*:*:*:2.0.0" | "" | "kind" | "tenant1:normal<timestamp>:test-data--Integration:2.0.0" | ".opendes:dot<timestamp>:test-data--Integration:2.0.0,system-meta-data:system<timestamp>:test-data--Integration:2.0.0,tenant1:normal<timestamp>:test-data--Integration:2.1.0" | + | "*:*:*:2.0.0,tenant1:normal<timestamp>:test-data--Integration:2.1.0" | "" | "kind" | "tenant1:normal<timestamp>:test-data--Integration:2.0.0,tenant1:normal<timestamp>:test-data--Integration:2.1.0" | ".opendes:dot<timestamp>:test-data--Integration:2.0.0,system-meta-data:system<timestamp>:test-data--Integration:2.0.0" | + | ".opendes:dot<timestamp>:test-data--Integration:2.1.0" | "" | "kind" | ".opendes:dot<timestamp>:test-data--Integration:2.1.0" | ".opendes:dot<timestamp>:test-data--Integration:2.0.0,system-meta-data:system<timestamp>:test-data--Integration:2.0.0" | + | "system-meta-data:system<timestamp>:test-data--Integration:2.1.0" | "" | "kind" | "system-meta-data:system<timestamp>:test-data--Integration:2.1.0" | ".opendes:dot<timestamp>:test-data--Integration:2.0.0,system-meta-data:system<timestamp>:test-data--Integration:2.0.0" | + | ".opendes:dot<timestamp>:test-data--Integration:2.1.0,tenant1:normal<timestamp>:*:*" | "" | "kind" | ".opendes:dot<timestamp>:test-data--Integration:2.1.0,tenant1:normal<timestamp>:test-data--Integration:2.0.0,tenant1:normal<timestamp>:test-data--Integration:2.1.0" | ".opendes:dot<timestamp>:test-data--Integration:2.0.0,system-meta-data:system<timestamp>:test-data--Integration:2.0.0" | + | "system-meta-data:system<timestamp>:test-data--Integration:2.1.0,tenant1:normal<timestamp>:*:*" | "" | "kind" | "system-meta-data:system<timestamp>:test-data--Integration:2.1.0,tenant1:normal<timestamp>:test-data--Integration:2.0.0,tenant1:normal<timestamp>:test-data--Integration:2.1.0" | ".opendes:dot<timestamp>:test-data--Integration:2.0.0,system-meta-data:system<timestamp>:test-data--Integration:2.0.0" | + + + + + + diff --git a/search-acceptance-test/src/test/resources/features/querybycursor/singlecluster/QueryByCursor.feature b/search-acceptance-test/src/test/resources/features/querybycursor/singlecluster/QueryByCursor.feature new file mode 100644 index 0000000000000000000000000000000000000000..11ea0ab008a4fb26130a20882cb9344d682ab32f --- /dev/null +++ b/search-acceptance-test/src/test/resources/features/querybycursor/singlecluster/QueryByCursor.feature @@ -0,0 +1,97 @@ +Feature: Search recursively on cursor with different queries + To allow a user to find his data quickly, search should offer multiple ways to search data and iterate over all the results. + + Background: + Given the schema is created with the following kind + | kind | schemaFile | + | tenant1:search<timestamp>:test-data--Integration:1.0.1 | records_1 | + | tenant1:search<timestamp>:test-data2--Integration:1.0.2 | records_2 | + + @default + Scenario Outline: Ingest records for the given kind + When I ingest records with the <recordFile> with <acl> for a given <kind> + Examples: + | kind | recordFile | acl | + | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | "records_1" | "data.default.viewers@tenant1" | + | "tenant1:search<timestamp>:test-data2--Integration:1.0.2" | "records_2" | "data.default.viewers@tenant1" | + + @default + Scenario Outline: Search recursively page by page data across the kinds + When I send <query> with <kind> + And I limit the count of returned results to <limit> + And I set the fields I want in response as <returned_fields> + And I send request to tenant <q1_tenant> + Then I should get in response <first_count> records along with a cursor + And I send request to tenant <q2_tenant> + Then I should get in response <final_count> records + + Examples: + | q1_tenant | q2_tenant | kind | query | limit | returned_fields | first_count | final_count | + | "tenant1" | "tenant1" | "tenant1:search<timestamp>:*:*" | None | 4 | All | 4 | 2 | + | "tenant1" | "tenant1" | "tenant1:search<timestamp>:*:*" | None | None | All | 6 | 0 | + | "tenant1" | "tenant1" | "tenant1:search<timestamp>:*:*" | "TX OR TEXAS OR FRANCE" | 1 | All | 1 | 1 | + | "tenant1" | "tenant1" | "tenant1:search<timestamp>:*:*" | "XdQQ6GCSNSBLTESTFAIL" | 1 | All | 0 | 0 | + | "tenant1" | "tenant1" | "tenant1:search<timestamp>:*:*" | "\"OFFICE2\" \| OFFICE3 \| OFFICE5" | 1 | All | 1 | 1 | + + @default + Scenario Outline: Search recursively page by page data across the kinds with invalid inputs + When I send <query> with <kind> + And I limit the count of returned results to <limit> + And I set an invalid cursor + And I send request to tenant <tenant> + Then I should get <response_code> response with reason: <reponse_type>, message: <response_message> and errors: <errors> + + Examples: + | tenant | kind | query | limit | response_code | reponse_type | response_message | errors | + | "tenant1" | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | None | None | 400 | "Can't find the given cursor" | "The given cursor is invalid or expired" | "" | + | "tenant1" | "*:*:*" | None | 0 | 400 | "Bad Request" | "Invalid parameters were given on search request" | "Not a valid record kind format. Found: *:*:*" | + | "tenant1" | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | None | -1 | 400 | "Bad Request" | "Invalid parameters were given on search request" | "'limit' must be equal or greater than 0" | + + @default + Scenario Outline: Search recursively page by page data across the kinds with invalid inputs and headers + When I send <query> with <kind> + And I limit the count of returned results to <limit> + And I set the fields I want in response as <returned_fields> + And I send request to tenant <q1_tenant> + Then I should get in response <first_count> records along with a cursor + And I send request to tenant <q2_tenant> + Then I should get <response_code> response with reason: <reponse_type>, message: <response_message> and errors: <errors> + + Examples: + | q1_tenant | q2_tenant | kind | query | limit | returned_fields | first_count | response_code | reponse_type | response_message | errors | + | "tenant1" | "tenant2" | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | None | 1 | All | 1 | 401 | "Access denied" | "The user is not authorized to perform this action" | "" | + + @default + Scenario Outline: Search data across the kinds with bounding box inputs + When I send <query> with <kind> + And I apply geographical query on field <field> + And define bounding box with points (<top_left_latitude>, <top_left_longitude>) and (<bottom_right_latitude>, <bottom_right_longitude>) + And I limit the count of returned results to <limit> + And I send request to tenant <q1_tenant> + Then I should get in response <first_count> records along with a cursor + And I send request to tenant <q2_tenant> + Then I should get in response <final_count> records + + Examples: + | q1_tenant | q2_tenant | kind | query | limit | field | top_left_latitude | top_left_longitude | bottom_right_latitude | bottom_right_longitude | first_count | final_count | + | "tenant1" | "tenant1" | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | None | None | "data.Location" | 45 | -100 | 0 | 0 | 2 | 0 | + | "tenant1" | "tenant1" | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | "data.OriginalOperator:OFFICE4" | 1 | "data.Location" | 45 | -110 | 0 | 0 | 1 | 0 | + + @default + Scenario Outline: Search data and sort the results with the given sort fields and order + When I send <query> with <kind> + And I want the results sorted by <sort> + Then I should get records in right order first record id: <first_record_id>, last record id: <last_record_id> + Examples: + | kind | query | sort | first_record_id | last_record_id | + | "tenant1:search<timestamp>:*:*" | None | {"field":["data.OriginalOperator"],"order":["ASC"]} | "tenant1:search<timestamp>:1" | "tenant1:search<timestamp>:2.0.0:3" | + | "tenant1:search<timestamp>:*:*" | None | {"field":["id"],"order":["DESC"]} | "tenant1:search<timestamp>:3" | "tenant1:search<timestamp>:1" | + | "tenant1:search<timestamp>:*:*" | None | {"field":["namespace","data.Rank"],"order":["ASC","DESC"]} | "tenant1:search<timestamp>:3" | "tenant1:search<timestamp>:2.0.0:1" | + + @default + Scenario Outline: Verify that the query with cursor functions correctly when there is no result + When I send <query> with <kind> + Then I should get in response <final_count> records + Examples: + | kind | query | final_count | + | "tenant1:not-existing-kind<timestamp>:*:*" | None | 0 | diff --git a/search-acceptance-test/src/test/resources/features/swagger/Swagger.feature b/search-acceptance-test/src/test/resources/features/swagger/Swagger.feature new file mode 100644 index 0000000000000000000000000000000000000000..3652e08dc58882a82475864ea644b389c9b07cba --- /dev/null +++ b/search-acceptance-test/src/test/resources/features/swagger/Swagger.feature @@ -0,0 +1,6 @@ +Feature: Fetch OpenAPI specification. + + @default + Scenario: Verify swagger endpoint content + When I send get request to swagger endpoint + Then I should get openapi spec in response diff --git a/search-acceptance-test/src/test/resources/logback.xml b/search-acceptance-test/src/test/resources/logback.xml new file mode 100644 index 0000000000000000000000000000000000000000..2ff72973a2088552d2eeadc52cdb4adf23d20027 --- /dev/null +++ b/search-acceptance-test/src/test/resources/logback.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<configuration> + <logger name="org.apache.http" level="ERROR" /> + <logger name="httpclient" level="ERROR" /> +</configuration> \ No newline at end of file diff --git a/search-acceptance-test/src/test/resources/testData/metadata_test_records_1.json b/search-acceptance-test/src/test/resources/testData/metadata_test_records_1.json new file mode 100644 index 0000000000000000000000000000000000000000..b6b8a84491eb1fecde5b43b05e8c739d6faae322 --- /dev/null +++ b/search-acceptance-test/src/test/resources/testData/metadata_test_records_1.json @@ -0,0 +1,71 @@ +[ + { + "id": "tenant1:normal<timestamp>:1", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "OSDU OFFICE - 1", + "Location": { + "lat":18.5204, + "lon":73.8567 + }, + "Basin": "India", + "State": "Maharashtra", + "Country": "India", + "WellStatus": "Under development", + "OriginalOperator": "OFFICE1", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 1, + "Score": 10, + "Established": "1990-03-27T23:38:48Z" + } + }, + { + "id": "tenant1:normal<timestamp>:2", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "OSDU OFFICE - 3", + "Location": { + "lat": 29.749655, + "lon": -95.473476 + }, + "Basin": "KATY", + "County": "Waller", + "State": "TEXAS", + "Country": "United States", + "WellStatus": "Under development", + "OriginalOperator": "OFFICE3", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 2, + "Score": 12, + "Established": "2010-03-27T20:38:48Z" + } + }, + { + "id": "tenant1:normal<timestamp>:3", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "OSDU OFFICE - 4", + "Location": { + "lat":29.6197, + "lon":-95.6349 + }, + "WellStatus": "Under development", + "OriginalOperator": "OFFICE4", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 20, + "Established": "2018-03-27T23:38:48Z" + } + } +] diff --git a/search-acceptance-test/src/test/resources/testData/metadata_test_records_1.schema.json b/search-acceptance-test/src/test/resources/testData/metadata_test_records_1.schema.json new file mode 100644 index 0000000000000000000000000000000000000000..b78c37e5ba5e439180762437132a4a22a91560a2 --- /dev/null +++ b/search-acceptance-test/src/test/resources/testData/metadata_test_records_1.schema.json @@ -0,0 +1,124 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "tenant1", + "source": "normal<timestamp>", + "entityType": "test-data--Integration", + "schemaVersionMajor": "2", + "schemaVersionMinor": "0", + "schemaVersionPatch": "0" + }, + "status": "DEVELOPMENT" + }, + "schema": { + "properties": { + "data": { + "allOf": [ + { + "type": "object", + "properties": { + "Field": { + "type": "string" + }, + "Location": { + "$ref": "#/definitions/opendes:wks:core_dl_geopoint:1.0.0", + "description": "The wellbore's position .", + "format": "core:dl:geopoint:1.0.0", + "title": "WGS 84 Position", + "type": "object" + }, + "Basin": { + "type": "string" + }, + "County": { + "type": "string" + } + } + } + ], + "anyOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "Country": { + "type": "string" + }, + "WellStatus": { + "type": "string" + }, + "OriginalOperator": { + "type": "string" + }, + "WellName": { + "type": "string" + }, + "WellType": { + "type": "string" + }, + "EmptyAttribute": { + "type": "string" + }, + "Center": { + "type": "string" + } + } + } + ], + "oneOf": [ + { + "type": "object", + "properties": { + "Rank": { + "type": "integer" + }, + "Score": { + "type": "integer" + }, + "Established": { + "type": "date-time" + }, + "DblArray": { + "description": "The name of the host [cloud environment] region(s) for this OSDU resource object.", + "title": "Resource Host Region ID", + "type": "array", + "items": { + "type": "number" + } + } + } + } + ] + } + }, + "definitions": { + "opendes:wks:core_dl_geopoint:1.0.0": { + "description": "A 2D point location in latitude and longitude referenced to WGS 84 if not specified otherwise.", + "properties": { + "latitude": { + "description": "The latitude value in degrees of arc (dega). Value range [-90, 90].", + "maximum": 90, + "minimum": -90, + "title": "Latitude", + "type": "number" + }, + "longitude": { + "description": "The longitude value in degrees of arc (dega). Value range [-180, 180]", + "maximum": 180, + "minimum": -180, + "title": "Longitude", + "type": "number" + } + }, + "required": [ + "latitude", + "longitude" + ], + "title": "2D Map Location", + "type": "object" + } + } + } +} \ No newline at end of file diff --git a/search-acceptance-test/src/test/resources/testData/metadata_test_records_2.json b/search-acceptance-test/src/test/resources/testData/metadata_test_records_2.json new file mode 100644 index 0000000000000000000000000000000000000000..21b5f5eca894956d2e455f780f0f758a6d64d5b9 --- /dev/null +++ b/search-acceptance-test/src/test/resources/testData/metadata_test_records_2.json @@ -0,0 +1,71 @@ +[ + { + "id": "tenant1:normal<timestamp>:4", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "OSDU OFFICE - 1", + "Location": { + "lat":18.5204, + "lon":73.8567 + }, + "Basin": "India", + "State": "Maharashtra", + "Country": "India", + "WellStatus": "Under development", + "OriginalOperator": "OFFICE1", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 1, + "Score": 10, + "Established": "1990-03-27T23:38:48Z" + } + }, + { + "id": "tenant1:normal<timestamp>:5", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "OSDU OFFICE - 3", + "Location": { + "lat": 29.749655, + "lon": -95.473476 + }, + "Basin": "KATY", + "County": "Waller", + "State": "TEXAS", + "Country": "United States", + "WellStatus": "Under development", + "OriginalOperator": "OFFICE3", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 2, + "Score": 12, + "Established": "2010-03-27T20:38:48Z" + } + }, + { + "id": "tenant1:normal<timestamp>:6", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "OSDU OFFICE - 4", + "Location": { + "lat":29.6197, + "lon":-95.6349 + }, + "WellStatus": "Under development", + "OriginalOperator": "OFFICE4", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 20, + "Established": "2018-03-27T23:38:48Z" + } + } +] diff --git a/search-acceptance-test/src/test/resources/testData/metadata_test_records_2.schema.json b/search-acceptance-test/src/test/resources/testData/metadata_test_records_2.schema.json new file mode 100644 index 0000000000000000000000000000000000000000..edb518de812a8f5a638c6b1d6091431ffdde1376 --- /dev/null +++ b/search-acceptance-test/src/test/resources/testData/metadata_test_records_2.schema.json @@ -0,0 +1,124 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "tenant1", + "source": "normal<timestamp>", + "entityType": "test-data--Integration", + "schemaVersionMajor": "2", + "schemaVersionMinor": "1", + "schemaVersionPatch": "0" + }, + "status": "DEVELOPMENT" + }, + "schema": { + "properties": { + "data": { + "allOf": [ + { + "type": "object", + "properties": { + "Field": { + "type": "string" + }, + "Location": { + "$ref": "#/definitions/opendes:wks:core_dl_geopoint:1.0.0", + "description": "The wellbore's position .", + "format": "core:dl:geopoint:1.0.0", + "title": "WGS 84 Position", + "type": "object" + }, + "Basin": { + "type": "string" + }, + "County": { + "type": "string" + } + } + } + ], + "anyOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "Country": { + "type": "string" + }, + "WellStatus": { + "type": "string" + }, + "OriginalOperator": { + "type": "string" + }, + "WellName": { + "type": "string" + }, + "WellType": { + "type": "string" + }, + "EmptyAttribute": { + "type": "string" + }, + "Center": { + "type": "string" + } + } + } + ], + "oneOf": [ + { + "type": "object", + "properties": { + "Rank": { + "type": "integer" + }, + "Score": { + "type": "integer" + }, + "Established": { + "type": "date-time" + }, + "DblArray": { + "description": "The name of the host [cloud environment] region(s) for this OSDU resource object.", + "title": "Resource Host Region ID", + "type": "array", + "items": { + "type": "number" + } + } + } + } + ] + } + }, + "definitions": { + "opendes:wks:core_dl_geopoint:1.0.0": { + "description": "A 2D point location in latitude and longitude referenced to WGS 84 if not specified otherwise.", + "properties": { + "latitude": { + "description": "The latitude value in degrees of arc (dega). Value range [-90, 90].", + "maximum": 90, + "minimum": -90, + "title": "Latitude", + "type": "number" + }, + "longitude": { + "description": "The longitude value in degrees of arc (dega). Value range [-180, 180]", + "maximum": 180, + "minimum": -180, + "title": "Longitude", + "type": "number" + } + }, + "required": [ + "latitude", + "longitude" + ], + "title": "2D Map Location", + "type": "object" + } + } + } +} \ No newline at end of file diff --git a/search-acceptance-test/src/test/resources/testData/metadata_test_records_3.json b/search-acceptance-test/src/test/resources/testData/metadata_test_records_3.json new file mode 100644 index 0000000000000000000000000000000000000000..960730493320172048ecde90fc087633d0d85c75 --- /dev/null +++ b/search-acceptance-test/src/test/resources/testData/metadata_test_records_3.json @@ -0,0 +1,71 @@ +[ + { + "id": "tenant1:dot<timestamp>:1", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "OSDU OFFICE - 1", + "Location": { + "lat":18.5204, + "lon":73.8567 + }, + "Basin": "India", + "State": "Maharashtra", + "Country": "India", + "WellStatus": "Under development", + "OriginalOperator": "OFFICE1", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 1, + "Score": 10, + "Established": "1990-03-27T23:38:48Z" + } + }, + { + "id": "tenant1:dot<timestamp>:2", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "OSDU OFFICE - 3", + "Location": { + "lat": 29.749655, + "lon": -95.473476 + }, + "Basin": "KATY", + "County": "Waller", + "State": "TEXAS", + "Country": "United States", + "WellStatus": "Under development", + "OriginalOperator": "OFFICE3", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 2, + "Score": 12, + "Established": "2010-03-27T20:38:48Z" + } + }, + { + "id": "tenant1:dot<timestamp>:3", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "OSDU OFFICE - 4", + "Location": { + "lat":29.6197, + "lon":-95.6349 + }, + "WellStatus": "Under development", + "OriginalOperator": "OFFICE4", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 20, + "Established": "2018-03-27T23:38:48Z" + } + } +] diff --git a/search-acceptance-test/src/test/resources/testData/metadata_test_records_3.schema.json b/search-acceptance-test/src/test/resources/testData/metadata_test_records_3.schema.json new file mode 100644 index 0000000000000000000000000000000000000000..9bfa02ee1b5c7a80625a66ca2c3a6aaf9f026702 --- /dev/null +++ b/search-acceptance-test/src/test/resources/testData/metadata_test_records_3.schema.json @@ -0,0 +1,124 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": ".opendes", + "source": "dot<timestamp>", + "entityType": "test-data--Integration", + "schemaVersionMajor": "2", + "schemaVersionMinor": "0", + "schemaVersionPatch": "0" + }, + "status": "DEVELOPMENT" + }, + "schema": { + "properties": { + "data": { + "allOf": [ + { + "type": "object", + "properties": { + "Field": { + "type": "string" + }, + "Location": { + "$ref": "#/definitions/opendes:wks:core_dl_geopoint:1.0.0", + "description": "The wellbore's position .", + "format": "core:dl:geopoint:1.0.0", + "title": "WGS 84 Position", + "type": "object" + }, + "Basin": { + "type": "string" + }, + "County": { + "type": "string" + } + } + } + ], + "anyOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "Country": { + "type": "string" + }, + "WellStatus": { + "type": "string" + }, + "OriginalOperator": { + "type": "string" + }, + "WellName": { + "type": "string" + }, + "WellType": { + "type": "string" + }, + "EmptyAttribute": { + "type": "string" + }, + "Center": { + "type": "string" + } + } + } + ], + "oneOf": [ + { + "type": "object", + "properties": { + "Rank": { + "type": "integer" + }, + "Score": { + "type": "integer" + }, + "Established": { + "type": "date-time" + }, + "DblArray": { + "description": "The name of the host [cloud environment] region(s) for this OSDU resource object.", + "title": "Resource Host Region ID", + "type": "array", + "items": { + "type": "number" + } + } + } + } + ] + } + }, + "definitions": { + "opendes:wks:core_dl_geopoint:1.0.0": { + "description": "A 2D point location in latitude and longitude referenced to WGS 84 if not specified otherwise.", + "properties": { + "latitude": { + "description": "The latitude value in degrees of arc (dega). Value range [-90, 90].", + "maximum": 90, + "minimum": -90, + "title": "Latitude", + "type": "number" + }, + "longitude": { + "description": "The longitude value in degrees of arc (dega). Value range [-180, 180]", + "maximum": 180, + "minimum": -180, + "title": "Longitude", + "type": "number" + } + }, + "required": [ + "latitude", + "longitude" + ], + "title": "2D Map Location", + "type": "object" + } + } + } +} \ No newline at end of file diff --git a/search-acceptance-test/src/test/resources/testData/metadata_test_records_4.json b/search-acceptance-test/src/test/resources/testData/metadata_test_records_4.json new file mode 100644 index 0000000000000000000000000000000000000000..d364d77396da6242bccea781d29864b8861adeb3 --- /dev/null +++ b/search-acceptance-test/src/test/resources/testData/metadata_test_records_4.json @@ -0,0 +1,71 @@ +[ + { + "id": "tenant1:dot<timestamp>:4", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "OSDU OFFICE - 1", + "Location": { + "lat":18.5204, + "lon":73.8567 + }, + "Basin": "India", + "State": "Maharashtra", + "Country": "India", + "WellStatus": "Under development", + "OriginalOperator": "OFFICE1", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 1, + "Score": 10, + "Established": "1990-03-27T23:38:48Z" + } + }, + { + "id": "tenant1:dot<timestamp>:5", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "OSDU OFFICE - 3", + "Location": { + "lat": 29.749655, + "lon": -95.473476 + }, + "Basin": "KATY", + "County": "Waller", + "State": "TEXAS", + "Country": "United States", + "WellStatus": "Under development", + "OriginalOperator": "OFFICE3", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 2, + "Score": 12, + "Established": "2010-03-27T20:38:48Z" + } + }, + { + "id": "tenant1:dot<timestamp>:6", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "OSDU OFFICE - 4", + "Location": { + "lat":29.6197, + "lon":-95.6349 + }, + "WellStatus": "Under development", + "OriginalOperator": "OFFICE4", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 20, + "Established": "2018-03-27T23:38:48Z" + } + } +] diff --git a/search-acceptance-test/src/test/resources/testData/metadata_test_records_4.schema.json b/search-acceptance-test/src/test/resources/testData/metadata_test_records_4.schema.json new file mode 100644 index 0000000000000000000000000000000000000000..5bb0c2315d4ee38c18badd6d1ba6bea795feceb1 --- /dev/null +++ b/search-acceptance-test/src/test/resources/testData/metadata_test_records_4.schema.json @@ -0,0 +1,124 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": ".opendes", + "source": "dot<timestamp>", + "entityType": "test-data--Integration", + "schemaVersionMajor": "2", + "schemaVersionMinor": "1", + "schemaVersionPatch": "0" + }, + "status": "DEVELOPMENT" + }, + "schema": { + "properties": { + "data": { + "allOf": [ + { + "type": "object", + "properties": { + "Field": { + "type": "string" + }, + "Location": { + "$ref": "#/definitions/opendes:wks:core_dl_geopoint:1.0.0", + "description": "The wellbore's position .", + "format": "core:dl:geopoint:1.0.0", + "title": "WGS 84 Position", + "type": "object" + }, + "Basin": { + "type": "string" + }, + "County": { + "type": "string" + } + } + } + ], + "anyOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "Country": { + "type": "string" + }, + "WellStatus": { + "type": "string" + }, + "OriginalOperator": { + "type": "string" + }, + "WellName": { + "type": "string" + }, + "WellType": { + "type": "string" + }, + "EmptyAttribute": { + "type": "string" + }, + "Center": { + "type": "string" + } + } + } + ], + "oneOf": [ + { + "type": "object", + "properties": { + "Rank": { + "type": "integer" + }, + "Score": { + "type": "integer" + }, + "Established": { + "type": "date-time" + }, + "DblArray": { + "description": "The name of the host [cloud environment] region(s) for this OSDU resource object.", + "title": "Resource Host Region ID", + "type": "array", + "items": { + "type": "number" + } + } + } + } + ] + } + }, + "definitions": { + "opendes:wks:core_dl_geopoint:1.0.0": { + "description": "A 2D point location in latitude and longitude referenced to WGS 84 if not specified otherwise.", + "properties": { + "latitude": { + "description": "The latitude value in degrees of arc (dega). Value range [-90, 90].", + "maximum": 90, + "minimum": -90, + "title": "Latitude", + "type": "number" + }, + "longitude": { + "description": "The longitude value in degrees of arc (dega). Value range [-180, 180]", + "maximum": 180, + "minimum": -180, + "title": "Longitude", + "type": "number" + } + }, + "required": [ + "latitude", + "longitude" + ], + "title": "2D Map Location", + "type": "object" + } + } + } +} \ No newline at end of file diff --git a/search-acceptance-test/src/test/resources/testData/metadata_test_records_5.json b/search-acceptance-test/src/test/resources/testData/metadata_test_records_5.json new file mode 100644 index 0000000000000000000000000000000000000000..07f8999b1a209d0d98347eaf365979b3c73994c3 --- /dev/null +++ b/search-acceptance-test/src/test/resources/testData/metadata_test_records_5.json @@ -0,0 +1,71 @@ +[ + { + "id": "tenant1:system<timestamp>:1", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "OSDU OFFICE - 1", + "Location": { + "lat":18.5204, + "lon":73.8567 + }, + "Basin": "India", + "State": "Maharashtra", + "Country": "India", + "WellStatus": "Under development", + "OriginalOperator": "OFFICE1", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 1, + "Score": 10, + "Established": "1990-03-27T23:38:48Z" + } + }, + { + "id": "tenant1:system<timestamp>:2", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "OSDU OFFICE - 3", + "Location": { + "lat": 29.749655, + "lon": -95.473476 + }, + "Basin": "KATY", + "County": "Waller", + "State": "TEXAS", + "Country": "United States", + "WellStatus": "Under development", + "OriginalOperator": "OFFICE3", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 2, + "Score": 12, + "Established": "2010-03-27T20:38:48Z" + } + }, + { + "id": "tenant1:system<timestamp>:3", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "OSDU OFFICE - 4", + "Location": { + "lat":29.6197, + "lon":-95.6349 + }, + "WellStatus": "Under development", + "OriginalOperator": "OFFICE4", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 20, + "Established": "2018-03-27T23:38:48Z" + } + } +] diff --git a/search-acceptance-test/src/test/resources/testData/metadata_test_records_5.schema.json b/search-acceptance-test/src/test/resources/testData/metadata_test_records_5.schema.json new file mode 100644 index 0000000000000000000000000000000000000000..4bc2a010a2d8967b744b6a755cbe420be9fd3fc7 --- /dev/null +++ b/search-acceptance-test/src/test/resources/testData/metadata_test_records_5.schema.json @@ -0,0 +1,124 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "system-meta-data", + "source": "system<timestamp>", + "entityType": "test-data--Integration", + "schemaVersionMajor": "2", + "schemaVersionMinor": "0", + "schemaVersionPatch": "0" + }, + "status": "DEVELOPMENT" + }, + "schema": { + "properties": { + "data": { + "allOf": [ + { + "type": "object", + "properties": { + "Field": { + "type": "string" + }, + "Location": { + "$ref": "#/definitions/opendes:wks:core_dl_geopoint:1.0.0", + "description": "The wellbore's position .", + "format": "core:dl:geopoint:1.0.0", + "title": "WGS 84 Position", + "type": "object" + }, + "Basin": { + "type": "string" + }, + "County": { + "type": "string" + } + } + } + ], + "anyOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "Country": { + "type": "string" + }, + "WellStatus": { + "type": "string" + }, + "OriginalOperator": { + "type": "string" + }, + "WellName": { + "type": "string" + }, + "WellType": { + "type": "string" + }, + "EmptyAttribute": { + "type": "string" + }, + "Center": { + "type": "string" + } + } + } + ], + "oneOf": [ + { + "type": "object", + "properties": { + "Rank": { + "type": "integer" + }, + "Score": { + "type": "integer" + }, + "Established": { + "type": "date-time" + }, + "DblArray": { + "description": "The name of the host [cloud environment] region(s) for this OSDU resource object.", + "title": "Resource Host Region ID", + "type": "array", + "items": { + "type": "number" + } + } + } + } + ] + } + }, + "definitions": { + "opendes:wks:core_dl_geopoint:1.0.0": { + "description": "A 2D point location in latitude and longitude referenced to WGS 84 if not specified otherwise.", + "properties": { + "latitude": { + "description": "The latitude value in degrees of arc (dega). Value range [-90, 90].", + "maximum": 90, + "minimum": -90, + "title": "Latitude", + "type": "number" + }, + "longitude": { + "description": "The longitude value in degrees of arc (dega). Value range [-180, 180]", + "maximum": 180, + "minimum": -180, + "title": "Longitude", + "type": "number" + } + }, + "required": [ + "latitude", + "longitude" + ], + "title": "2D Map Location", + "type": "object" + } + } + } +} \ No newline at end of file diff --git a/search-acceptance-test/src/test/resources/testData/metadata_test_records_6.json b/search-acceptance-test/src/test/resources/testData/metadata_test_records_6.json new file mode 100644 index 0000000000000000000000000000000000000000..f0c41749d5e3e08f7a63716eb9f70fc80d5b789a --- /dev/null +++ b/search-acceptance-test/src/test/resources/testData/metadata_test_records_6.json @@ -0,0 +1,71 @@ +[ + { + "id": "tenant1:system<timestamp>:4", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "OSDU OFFICE - 1", + "Location": { + "lat":18.5204, + "lon":73.8567 + }, + "Basin": "India", + "State": "Maharashtra", + "Country": "India", + "WellStatus": "Under development", + "OriginalOperator": "OFFICE1", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 1, + "Score": 10, + "Established": "1990-03-27T23:38:48Z" + } + }, + { + "id": "tenant1:system<timestamp>:5", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "OSDU OFFICE - 3", + "Location": { + "lat": 29.749655, + "lon": -95.473476 + }, + "Basin": "KATY", + "County": "Waller", + "State": "TEXAS", + "Country": "United States", + "WellStatus": "Under development", + "OriginalOperator": "OFFICE3", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 2, + "Score": 12, + "Established": "2010-03-27T20:38:48Z" + } + }, + { + "id": "tenant1:system<timestamp>:6", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "OSDU OFFICE - 4", + "Location": { + "lat":29.6197, + "lon":-95.6349 + }, + "WellStatus": "Under development", + "OriginalOperator": "OFFICE4", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 20, + "Established": "2018-03-27T23:38:48Z" + } + } +] diff --git a/search-acceptance-test/src/test/resources/testData/metadata_test_records_6.schema.json b/search-acceptance-test/src/test/resources/testData/metadata_test_records_6.schema.json new file mode 100644 index 0000000000000000000000000000000000000000..e200b878622339f02c197c04239fe9d61c7ddba6 --- /dev/null +++ b/search-acceptance-test/src/test/resources/testData/metadata_test_records_6.schema.json @@ -0,0 +1,124 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "system-meta-data", + "source": "system<timestamp>", + "entityType": "test-data--Integration", + "schemaVersionMajor": "2", + "schemaVersionMinor": "1", + "schemaVersionPatch": "0" + }, + "status": "DEVELOPMENT" + }, + "schema": { + "properties": { + "data": { + "allOf": [ + { + "type": "object", + "properties": { + "Field": { + "type": "string" + }, + "Location": { + "$ref": "#/definitions/opendes:wks:core_dl_geopoint:1.0.0", + "description": "The wellbore's position .", + "format": "core:dl:geopoint:1.0.0", + "title": "WGS 84 Position", + "type": "object" + }, + "Basin": { + "type": "string" + }, + "County": { + "type": "string" + } + } + } + ], + "anyOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "Country": { + "type": "string" + }, + "WellStatus": { + "type": "string" + }, + "OriginalOperator": { + "type": "string" + }, + "WellName": { + "type": "string" + }, + "WellType": { + "type": "string" + }, + "EmptyAttribute": { + "type": "string" + }, + "Center": { + "type": "string" + } + } + } + ], + "oneOf": [ + { + "type": "object", + "properties": { + "Rank": { + "type": "integer" + }, + "Score": { + "type": "integer" + }, + "Established": { + "type": "date-time" + }, + "DblArray": { + "description": "The name of the host [cloud environment] region(s) for this OSDU resource object.", + "title": "Resource Host Region ID", + "type": "array", + "items": { + "type": "number" + } + } + } + } + ] + } + }, + "definitions": { + "opendes:wks:core_dl_geopoint:1.0.0": { + "description": "A 2D point location in latitude and longitude referenced to WGS 84 if not specified otherwise.", + "properties": { + "latitude": { + "description": "The latitude value in degrees of arc (dega). Value range [-90, 90].", + "maximum": 90, + "minimum": -90, + "title": "Latitude", + "type": "number" + }, + "longitude": { + "description": "The longitude value in degrees of arc (dega). Value range [-180, 180]", + "maximum": 180, + "minimum": -180, + "title": "Longitude", + "type": "number" + } + }, + "required": [ + "latitude", + "longitude" + ], + "title": "2D Map Location", + "type": "object" + } + } + } +} \ No newline at end of file diff --git a/search-acceptance-test/src/test/resources/testData/records_1.json b/search-acceptance-test/src/test/resources/testData/records_1.json new file mode 100644 index 0000000000000000000000000000000000000000..627c488fd4b3704ee94e1cb077cfbb06eb4c0c8a --- /dev/null +++ b/search-acceptance-test/src/test/resources/testData/records_1.json @@ -0,0 +1,71 @@ +[ + { + "id": "tenant1:search<timestamp>:1", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "OSDU OFFICE - 1", + "Location": { + "lat":18.5204, + "lon":73.8567 + }, + "Basin": "India", + "State": "Maharashtra", + "Country": "India", + "WellStatus": "Under development", + "OriginalOperator": "OFFICE1", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 1, + "Score": 10, + "Established": "1990-03-27T23:38:48Z" + } + }, + { + "id": "tenant1:search<timestamp>:2", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "OSDU OFFICE - 3", + "Location": { + "lat": 29.749655, + "lon": -95.473476 + }, + "Basin": "KATY", + "County": "Waller", + "State": "TEXAS", + "Country": "United States", + "WellStatus": "Under development", + "OriginalOperator": "OFFICE3", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 2, + "Score": 12, + "Established": "2010-03-27T20:38:48Z" + } + }, + { + "id": "tenant1:search<timestamp>:3", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "OSDU OFFICE - 4", + "Location": { + "lat":29.6197, + "lon":-95.6349 + }, + "WellStatus": "Under development", + "OriginalOperator": "OFFICE4", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 20, + "Established": "2018-03-27T23:38:48Z" + } + } +] diff --git a/search-acceptance-test/src/test/resources/testData/records_1.mapping b/search-acceptance-test/src/test/resources/testData/records_1.mapping new file mode 100644 index 0000000000000000000000000000000000000000..6039de8691cedf913c75633fb1eccc8fa2b40a7b --- /dev/null +++ b/search-acceptance-test/src/test/resources/testData/records_1.mapping @@ -0,0 +1,178 @@ +{ + "dynamic":false, + "properties":{ + "id":{ + "type":"keyword" + }, + "kind":{ + "type":"keyword" + }, + "namespace":{ + "type":"keyword" + }, + "type":{ + "type":"keyword" + }, + "version":{ + "type":"keyword" + }, + "x-acl":{ + "type":"keyword" + }, + "acl":{ + "properties":{ + "owners":{ + "type":"keyword" + }, + "viewers":{ + "type":"keyword" + } + } + }, + "legal":{ + "properties":{ + "legaltags":{ + "type":"keyword" + }, + "otherRelevantDataCountries":{ + "type":"keyword" + }, + "status":{ + "type":"keyword" + } + } + }, + "index":{ + "properties":{ + "lastUpdateTime":{ + "type":"date" + }, + "statusCode":{ + "type":"integer" + }, + "trace":{ + "type":"text" + } + } + }, + "data":{ + "properties":{ + "Field":{ + "type":"text", + "fields":{ + "keyword":{ + "type":"keyword", + "null_value":"null", + "ignore_above":256 + } + } + }, + "Location":{ + "type":"geo_point" + }, + "LocationGeoShape":{ + "type":"geo_shape" + }, + "Basin":{ + "type":"text", + "fields":{ + "keyword":{ + "type":"keyword", + "null_value":"null", + "ignore_above":256 + } + } + }, + "County":{ + "type":"text", + "fields":{ + "keyword":{ + "type":"keyword", + "null_value":"null", + "ignore_above":256 + } + } + }, + "State":{ + "type":"text", + "fields":{ + "keyword":{ + "type":"keyword", + "null_value":"null", + "ignore_above":256 + } + } + }, + "Country":{ + "type":"text", + "fields":{ + "keyword":{ + "type":"keyword", + "null_value":"null", + "ignore_above":256 + } + } + }, + "WellStatus":{ + "type":"text", + "fields":{ + "keyword":{ + "type":"keyword", + "null_value":"null", + "ignore_above":256 + } + } + }, + "OriginalOperator":{ + "type":"text", + "fields":{ + "keyword":{ + "type":"keyword", + "null_value":"null", + "ignore_above":256 + } + } + }, + "WellName":{ + "type":"text", + "fields":{ + "keyword":{ + "type":"keyword", + "null_value":"null", + "ignore_above":256 + } + } + }, + "WellType":{ + "type":"text", + "fields":{ + "keyword":{ + "type":"keyword", + "null_value":"null", + "ignore_above":256 + } + } + }, + "EmptyAttribute":{ + "type":"text", + "fields":{ + "keyword":{ + "type":"keyword", + "null_value":"null", + "ignore_above":256 + } + } + }, + "Rank":{ + "type":"integer" + }, + "Score":{ + "type":"integer" + }, + "Established":{ + "type":"date" + } + } + } + } +} \ No newline at end of file diff --git a/search-acceptance-test/src/test/resources/testData/records_1.schema.json b/search-acceptance-test/src/test/resources/testData/records_1.schema.json new file mode 100644 index 0000000000000000000000000000000000000000..32e763483d3adf5ce4dd90ab4d39a3e2b41dfb06 --- /dev/null +++ b/search-acceptance-test/src/test/resources/testData/records_1.schema.json @@ -0,0 +1,124 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "tenant1", + "source": "search<timestamp>", + "entityType": "test-data--Integration", + "schemaVersionMajor": "1", + "schemaVersionMinor": "0", + "schemaVersionPatch": "1" + }, + "status": "DEVELOPMENT" + }, + "schema": { + "properties": { + "data": { + "allOf": [ + { + "type": "object", + "properties": { + "Field": { + "type": "string" + }, + "Location": { + "$ref": "#/definitions/opendes:wks:core_dl_geopoint:1.0.0", + "description": "The wellbore's position .", + "format": "core:dl:geopoint:1.0.0", + "title": "WGS 84 Position", + "type": "object" + }, + "Basin": { + "type": "string" + }, + "County": { + "type": "string" + } + } + } + ], + "anyOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "Country": { + "type": "string" + }, + "WellStatus": { + "type": "string" + }, + "OriginalOperator": { + "type": "string" + }, + "WellName": { + "type": "string" + }, + "WellType": { + "type": "string" + }, + "EmptyAttribute": { + "type": "string" + }, + "Center": { + "type": "string" + } + } + } + ], + "oneOf": [ + { + "type": "object", + "properties": { + "Rank": { + "type": "integer" + }, + "Score": { + "type": "integer" + }, + "Established": { + "type": "date-time" + }, + "DblArray": { + "description": "The name of the host [cloud environment] region(s) for this OSDU resource object.", + "title": "Resource Host Region ID", + "type": "array", + "items": { + "type": "number" + } + } + } + } + ] + } + }, + "definitions": { + "opendes:wks:core_dl_geopoint:1.0.0": { + "description": "A 2D point location in latitude and longitude referenced to WGS 84 if not specified otherwise.", + "properties": { + "latitude": { + "description": "The latitude value in degrees of arc (dega). Value range [-90, 90].", + "maximum": 90, + "minimum": -90, + "title": "Latitude", + "type": "number" + }, + "longitude": { + "description": "The longitude value in degrees of arc (dega). Value range [-180, 180]", + "maximum": 180, + "minimum": -180, + "title": "Longitude", + "type": "number" + } + }, + "required": [ + "latitude", + "longitude" + ], + "title": "2D Map Location", + "type": "object" + } + } + } +} \ No newline at end of file diff --git a/search-acceptance-test/src/test/resources/testData/records_2.json b/search-acceptance-test/src/test/resources/testData/records_2.json new file mode 100644 index 0000000000000000000000000000000000000000..1b8485ad8672cc284be8d90705dbb120c8049b47 --- /dev/null +++ b/search-acceptance-test/src/test/resources/testData/records_2.json @@ -0,0 +1,73 @@ +[ + { + "id": "tenant1:search<timestamp>:2.0.0:1", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "OSDU OFFICE - 2", + "Location": { + "lat":29.7604, + "lon":-95.3698 + }, + "Basin": "Houston", + "County": "Harris", + "State": "TX", + "Country": "USA", + "WellStatus": "Under development", + "OriginalOperator": "OFFICE2", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 1, + "Score": 10, + "Established": "2000-03-27T23:38:48Z" + } + }, + { + "id": "tenant1:search<timestamp>:2.0.0:2", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "OSDU OFFICE - 5", + "Location": { + "lat":37.3861, + "lon":-122.0839 + }, + "Basin": "Mountain View", + "County": "Orange", + "State": "CA", + "Country": "USA", + "WellStatus": "Under development", + "OriginalOperator": "OFFICE5", + "WellName": "Data Platform Services", + "WellType": "Lake Cloud", + "EmptyAttribute": "", + "Rank": 2, + "Score": 5, + "Established": "1980-03-27T20:38:48Z" + } + }, + { + "id": "tenant1:search<timestamp>:2.0.0:3", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "OSDU OFFICE - 6", + "Location": { + "lat":43.6108, + "lon":3.8767 + }, + "WellStatus": "Under development", + "OriginalOperator": "OFFICE6", + "Country": "France", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 20, + "Established": "2005-03-27T23:38:48Z" + } + } +] diff --git a/search-acceptance-test/src/test/resources/testData/records_2.mapping b/search-acceptance-test/src/test/resources/testData/records_2.mapping new file mode 100644 index 0000000000000000000000000000000000000000..0ea347a7a9835b73de12aad1bca3c88e1169e9f9 --- /dev/null +++ b/search-acceptance-test/src/test/resources/testData/records_2.mapping @@ -0,0 +1,175 @@ +{ + "dynamic":false, + "properties":{ + "id":{ + "type":"keyword" + }, + "kind":{ + "type":"keyword" + }, + "namespace":{ + "type":"keyword" + }, + "type":{ + "type":"keyword" + }, + "version":{ + "type":"keyword" + }, + "x-acl":{ + "type":"keyword" + }, + "acl":{ + "properties":{ + "owners":{ + "type":"keyword" + }, + "viewers":{ + "type":"keyword" + } + } + }, + "legal":{ + "properties":{ + "legaltags":{ + "type":"keyword" + }, + "otherRelevantDataCountries":{ + "type":"keyword" + }, + "status":{ + "type":"keyword" + } + } + }, + "index":{ + "properties":{ + "lastUpdateTime":{ + "type":"date" + }, + "statusCode":{ + "type":"integer" + }, + "trace":{ + "type":"text" + } + } + }, + "data":{ + "properties":{ + "Field":{ + "type":"text", + "fields":{ + "keyword":{ + "type":"keyword", + "null_value":"null", + "ignore_above":256 + } + } + }, + "Location":{ + "type":"geo_point" + }, + "LocationGeoShape":{ + "type":"geo_shape" + }, + "Basin":{ + "type":"text", + "fields":{ + "keyword":{ + "type":"keyword", + "null_value":"null", + "ignore_above":256 + } + } + }, + "County":{ + "type":"text", + "fields":{ + "keyword":{ + "type":"keyword", + "null_value":"null", + "ignore_above":256 + } + } + }, + "State":{ + "type":"text", + "fields":{ + "keyword":{ + "type":"keyword", + "null_value":"null", + "ignore_above":256 + } + } + }, + "Country":{ + "type":"text", + "fields":{ + "keyword":{ + "type":"keyword", + "null_value":"null", + "ignore_above":256 + } + } + }, + "WellStatus":{ + "type":"text", + "fields":{ + "keyword":{ + "type":"keyword", + "null_value":"null", + "ignore_above":256 + } + } + }, + "OriginalOperator":{ + "type":"text", + "fields":{ + "keyword":{ + "type":"keyword", + "null_value":"null", + "ignore_above":256 + } + } + }, + "WellName":{ + "type":"text", + "fields":{ + "keyword":{ + "type":"keyword", + "null_value":"null", + "ignore_above":256 + } + } + }, + "WellType":{ + "type":"text", + "fields":{ + "keyword":{ + "type":"keyword", + "null_value":"null", + "ignore_above":256 + } + } + }, + "EmptyAttribute":{ + "type":"text", + "fields":{ + "keyword":{ + "type":"keyword", + "null_value":"null", + "ignore_above":256 + } + } + }, + "Rank":{ + "type":"integer" + }, + "Established":{ + "type":"date" + } + } + } + } +} \ No newline at end of file diff --git a/search-acceptance-test/src/test/resources/testData/records_2.schema.json b/search-acceptance-test/src/test/resources/testData/records_2.schema.json new file mode 100644 index 0000000000000000000000000000000000000000..1ce55e2d412bbd83e84c557c1e96e6aea0f6743a --- /dev/null +++ b/search-acceptance-test/src/test/resources/testData/records_2.schema.json @@ -0,0 +1,124 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "tenant1", + "source": "search<timestamp>", + "entityType": "test-data2--Integration", + "schemaVersionMajor": "1", + "schemaVersionMinor": "0", + "schemaVersionPatch": "2" + }, + "status": "DEVELOPMENT" + }, + "schema": { + "properties": { + "data": { + "allOf": [ + { + "type": "object", + "properties": { + "Location": { + "format": "core:dl:geopoint:1.0.0", + "description": "The wellbore's position .", + "title": "WGS 84 Position", + "type": "object", + "$ref": "#/definitions/opendes:wks:core_dl_geopoint:1.0.0" + }, + "Field": { + "type": "string" + } + } + } + ], + "anyOf": [ + { + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "State": { + "type": "string" + }, + "Basin": { + "type": "string" + }, + "Country": { + "type": "string" + }, + "WellStatus": { + "type": "string" + }, + "OriginalOperator": { + "type": "string" + }, + "WellName": { + "type": "string" + }, + "WellType": { + "type": "string" + }, + "EmptyAttribute": { + "type": "string" + }, + "Center": { + "type": "string" + }, + "Score": { + "type": "integer" + }, + "Established": { + "type": "date-time" + } + } + } + ], + "oneOf": [ + { + "type": "object", + "properties": { + "Rank": { + "type": "integer" + }, + "DblArray": { + "description": "The name of the host [cloud environment] region(s) for this OSDU resource object.", + "title": "Resource Host Region ID", + "type": "array", + "items": { + "type": "number" + } + } + } + } + ] + } + }, + "definitions": { + "opendes:wks:core_dl_geopoint:1.0.0": { + "description": "A 2D point location in latitude and longitude referenced to WGS 84 if not specified otherwise.", + "properties": { + "latitude": { + "description": "The latitude value in degrees of arc (dega). Value range [-90, 90].", + "maximum": 90, + "minimum": -90, + "title": "Latitude", + "type": "number" + }, + "longitude": { + "description": "The longitude value in degrees of arc (dega). Value range [-180, 180]", + "maximum": 180, + "minimum": -180, + "title": "Longitude", + "type": "number" + } + }, + "required": [ + "latitude", + "longitude" + ], + "title": "2D Map Location", + "type": "object" + } + } + } +} \ No newline at end of file diff --git a/search-acceptance-test/src/test/resources/testData/records_4.json b/search-acceptance-test/src/test/resources/testData/records_4.json new file mode 100644 index 0000000000000000000000000000000000000000..f60031bc1bac866b20a24382c9ebb9bf1662cfe9 --- /dev/null +++ b/search-acceptance-test/src/test/resources/testData/records_4.json @@ -0,0 +1,67 @@ +[{ + "id": "tenant1:well<timestamp>:1", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Source": "Example Data Source", + "FacilityName": "Example FacilityName", + "VerticalMeasurements": [ + { + "WellboreTVDTrajectoryID": "namespace:work-product-component--WellboreTrajectory:WellboreTrajectory-911bb71f-06ab-4deb-8e68-b8c9229dc76b:", + "VerticalCRSID": "namespace:reference-data--CoordinateReferenceSystem:SomeUniqueCoordinateReferenceSystemID:", + "VerticalMeasurementSourceID": "namespace:reference-data--VerticalMeasurementSource:SomeUniqueVerticalMeasurementSourceID:", + "VerticalReferenceID": "Example VerticalReferenceID", + "TerminationDateTime": "2020-02-13T04:25:50.688Z", + "VerticalMeasurementID": "Example VerticalMeasurementID", + "VerticalMeasurementPathID": "namespace:reference-data--VerticalMeasurementPath:SomeUniqueVerticalMeasurementPathID:", + "EffectiveDateTime": "2020-02-13T04:25:50.688Z", + "VerticalMeasurement": 12345.6, + "VerticalMeasurementTypeID": "namespace:reference-data--VerticalMeasurementType:Plug%20Back%20depth:", + "VerticalMeasurementDescription": "Example VerticalMeasurementDescription", + "VerticalMeasurementUnitOfMeasureID": "namespace:reference-data--UnitOfMeasure:m:" + } + ], + "FacilityOperators": [ + { + "FacilityOperatorID": "Example Facility Operator ID", + "TerminationDateTime": "2020-02-13T04:25:50.688Z", + "EffectiveDateTime": "2020-02-13T04:25:50.688Z", + "FacilityOperatorOrganisationID": "namespace:master-data--Organisation:SomeUniqueOrganisationID:" + } + ] + } + +}, + { + "id": "tenant1:well<timestamp>:2", + "data": { + "Source": "Example Data Source", + "FacilityName": "Example FacilityName", + "VerticalMeasurements": [ + { + "WellboreTVDTrajectoryID": "namespace:work-product-component--WellboreTrajectory:WellboreTrajectory-911bb71f-06ab-4deb-8e68-b8c9229dc76b:", + "VerticalCRSID": "namespace:reference-data--CoordinateReferenceSystem:SomeUniqueCoordinateReferenceSystemID:", + "VerticalMeasurementSourceID": "namespace:reference-data--VerticalMeasurementSource:SomeUniqueVerticalMeasurementSourceID:", + "VerticalReferenceID": "Example VerticalReferenceID", + "TerminationDateTime": "2020-02-13T04:25:50.688Z", + "VerticalMeasurementID": "Other Example VerticalMeasurementID", + "VerticalMeasurementPathID": "namespace:reference-data--VerticalMeasurementPath:SomeUniqueVerticalMeasurementPathID:", + "EffectiveDateTime": "2020-02-13T04:25:50.688Z", + "VerticalMeasurement": 12.3, + "VerticalMeasurementTypeID": "namespace:reference-data--VerticalMeasurementType:Plug%20Back%20depth:", + "VerticalMeasurementDescription": "Example VerticalMeasurementDescription", + "VerticalMeasurementUnitOfMeasureID": "namespace:reference-data--UnitOfMeasure:m:" + } + ], + "FacilityOperators": [ + { + "FacilityOperatorID": "Example Facility Operator ID", + "TerminationDateTime": "2025-02-13T04:25:50.688Z", + "EffectiveDateTime": "2020-02-13T04:25:50.688Z", + "FacilityOperatorOrganisationID": "namespace:master-data--Organisation:SomeUniqueOrganisationID:" + } + ] + } + } +] diff --git a/search-acceptance-test/src/test/resources/testData/records_4.mapping b/search-acceptance-test/src/test/resources/testData/records_4.mapping new file mode 100644 index 0000000000000000000000000000000000000000..8250e6f4cab561d78746c631f2096b89577966da --- /dev/null +++ b/search-acceptance-test/src/test/resources/testData/records_4.mapping @@ -0,0 +1,391 @@ +{ + "dynamic": "false", + "properties": { + "acl": { + "properties": { + "owners": { + "type": "keyword" + }, + "viewers": { + "type": "keyword" + } + } + }, + "ancestry": { + "properties": { + "parents": { + "type": "keyword" + } + } + }, + "data": { + "properties": { + "CurrentOperatorID": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "DataSourceOrganisationID": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "DefaultVerticalCRSID": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "DefaultVerticalMeasurementID": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "ExistenceKind": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "FacilityEvents": { + "type": "flattened" + }, + "FacilityID": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "FacilityName": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "FacilityNameAliases": { + "type": "object" + }, + "FacilityOperators": { + "type": "nested", + "properties": { + "EffectiveDateTime": { + "type": "date" + }, + "FacilityOperatorID": { + "type": "text" + }, + "FacilityOperatorOrganisationID": { + "type": "text" + }, + "TerminationDateTime": { + "type": "date" + } + } + }, + "FacilitySpecifications": { + "type": "flattened" + }, + "FacilityStates": { + "type": "flattened" + }, + "FacilityTypeID": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "GeoContexts": { + "type": "flattened" + }, + "InitialOperatorID": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "InterestTypeID": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "NameAliases": { + "type": "flattened" + }, + "OperatingEnvironmentID": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "ResourceCurationStatus": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "ResourceHomeRegionID": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "ResourceHostRegionIDs": { + "type": "text" + }, + "ResourceLifecycleStatus": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "ResourceSecurityClassification": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "Source": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "SpatialLocation": { + "properties": { + "AppliedOperations": { + "type": "text" + }, + "CoordinateQualityCheckDateTime": { + "type": "date" + }, + "CoordinateQualityCheckPerformedBy": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "CoordinateQualityCheckRemarks": { + "type": "text" + }, + "QualitativeSpatialAccuracyTypeID": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "QuantitativeAccuracyBandID": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "SpatialGeometryTypeID": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "SpatialLocationCoordinatesDate": { + "type": "date" + }, + "SpatialParameterTypeID": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "Wgs84Coordinates": { + "type": "geo_shape" + } + } + }, + "VersionCreationReason": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "VerticalMeasurements": { + "type": "nested", + "properties": { + "EffectiveDateTime": { + "type": "date" + }, + "TerminationDateTime": { + "type": "date" + }, + "VerticalCRSID": { + "type": "text" + }, + "VerticalMeasurement": { + "type": "double" + }, + "VerticalMeasurementDescription": { + "type": "text" + }, + "VerticalMeasurementID": { + "type": "text" + }, + "VerticalMeasurementPathID": { + "type": "text" + }, + "VerticalMeasurementSourceID": { + "type": "text" + }, + "VerticalMeasurementTypeID": { + "type": "text" + }, + "VerticalMeasurementUnitOfMeasureID": { + "type": "text" + }, + "VerticalReferenceID": { + "type": "text" + }, + "WellboreTVDTrajectoryID": { + "type": "text" + } + } + } + } + }, + "id": { + "type": "keyword" + }, + "index": { + "properties": { + "lastUpdateTime": { + "type": "date" + }, + "statusCode": { + "type": "integer" + }, + "trace": { + "type": "text" + } + } + }, + "kind": { + "type": "keyword" + }, + "legal": { + "properties": { + "legaltags": { + "type": "keyword" + }, + "otherRelevantDataCountries": { + "type": "keyword" + }, + "status": { + "type": "keyword" + } + } + }, + "namespace": { + "type": "keyword" + }, + "tags": { + "type": "object" + }, + "type": { + "type": "keyword" + }, + "version": { + "type": "long" + }, + "x-acl": { + "type": "keyword" + } + } +} diff --git a/search-acceptance-test/src/test/resources/testData/records_4.schema.json b/search-acceptance-test/src/test/resources/testData/records_4.schema.json new file mode 100644 index 0000000000000000000000000000000000000000..4dee10fe765795c3e0671caad352119ef3651260 --- /dev/null +++ b/search-acceptance-test/src/test/resources/testData/records_4.schema.json @@ -0,0 +1,186 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "tenant1", + "source": "well<timestamp>", + "entityType": "test-data3--Integration", + "schemaVersionMajor": "1", + "schemaVersionMinor": "0", + "schemaVersionPatch": "3" + }, + "status": "DEVELOPMENT" + }, + "schema": { + "properties": { + "data": { + "anyOf": [ + { + "type": "object", + "properties": { + "FacilityOperators": { + "x-osdu-indexing": { + "type": "nested" + }, + "type": "array", + "items": { + "allOf": [ + { + "$ref": "#/definitions/osdu:wks:AbstractFacilityOperator:1.0.0" + } + ] + } + }, + "FacilityName": { + "type": "string" + }, + "Source": { + "type": "string" + }, + "VerticalMeasurements": { + "x-osdu-indexing": { + "type": "nested" + }, + "description": "List of all depths and elevations pertaining to the wellbore, like, plug back measured depth, total measured depth, KB elevation", + "type": "array", + "items": { + "allOf": [ + { + "type": "object", + "title": "Vertical Measurement ID", + "properties": { + "VerticalMeasurementID": { + "description": "The ID for a distinct vertical measurement within the Wellbore VerticalMeasurements array so that it may be referenced by other vertical measurements if necessary.", + "type": "string" + } + } + }, + { + "$ref": "#/definitions/osdu:wks:AbstractFacilityVerticalMeasurement:1.0.0" + } + ] + } + }, + "DefaultVerticalMeasurementID": { + "description": "The default datum reference point, or zero depth point, used to determine other points vertically in a wellbore. References an entry in the Vertical Measurements array of this wellbore.", + "type": "string" + } + } + } + ] + } + }, + "definitions": { + "osdu:wks:AbstractFacilityVerticalMeasurement:1.0.0": { + "x-osdu-inheriting-from-kind": [], + "x-osdu-license": "Copyright 2021, The Open Group \\nLicensed 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.", + "$schema": "http://json-schema.org/draft-07/schema#", + "x-osdu-schema-source": "osdu:wks:AbstractFacilityVerticalMeasurement:1.0.0", + "description": "A location along a wellbore, _usually_ associated with some aspect of the drilling of the wellbore, but not with any intersecting _subsurface_ natural surfaces.", + "title": "AbstractFacilityVerticalMeasurement", + "type": "object", + "properties": { + "VerticalMeasurementSourceID": { + "x-osdu-relationship": [ + { + "EntityType": "VerticalMeasurementSource", + "GroupType": "reference-data" + } + ], + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-VerticalMeasurementSource:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "description": "Specifies Driller vs Logger.", + "type": "string" + }, + "VerticalReferenceID": { + "description": "The reference point from which the relative vertical measurement is made. This is only populated if the measurement has no VerticalCRSID specified. The value entered must be the VerticalMeasurementID for another vertical measurement array element in this resource or its parent facility, and as a chain of measurements, they must resolve ultimately to a Vertical CRS. It is expected that a VerticalCRSID or a VerticalReferenceID is provided in a given vertical measurement array object, but not both.", + "type": "string" + }, + "TerminationDateTime": { + "format": "date-time", + "description": "The date and time at which a vertical measurement instance is no longer in effect.", + "x-osdu-frame-of-reference": "DateTime", + "type": "string" + }, + "EffectiveDateTime": { + "format": "date-time", + "description": "The date and time at which a vertical measurement instance becomes effective.", + "x-osdu-frame-of-reference": "DateTime", + "type": "string" + }, + "VerticalMeasurement": { + "description": "The value of the elevation or depth. Depth is positive downwards from a vertical reference or geodetic datum along a path, which can be vertical; elevation is positive upwards from a geodetic datum along a vertical path. Either can be negative.", + "x-osdu-frame-of-reference": "UOM_via_property:VerticalMeasurementUnitOfMeasureID", + "type": "number" + }, + "VerticalMeasurementTypeID": { + "x-osdu-relationship": [ + { + "EntityType": "VerticalMeasurementType", + "GroupType": "reference-data" + } + ], + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-VerticalMeasurementType:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "description": "Specifies the type of vertical measurement (TD, Plugback, Kickoff, Drill Floor, Rotary Table...).", + "type": "string" + }, + "VerticalMeasurementDescription": { + "description": "Text which describes a vertical measurement in detail.", + "type": "string" + }, + "VerticalMeasurementUnitOfMeasureID": { + "x-osdu-relationship": [ + { + "EntityType": "UnitOfMeasure", + "GroupType": "reference-data" + } + ], + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-UnitOfMeasure:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "description": "The unit of measure for the vertical measurement. If a unit of measure and a vertical CRS are provided, the unit of measure provided is taken over the unit of measure from the CRS.", + "type": "string" + } + }, + "$id": "https://schema.osdu.opengroup.org/json/abstract/AbstractFacilityVerticalMeasurement.1.0.0.json" + }, + "osdu:wks:AbstractFacilityOperator:1.0.0": { + "x-osdu-inheriting-from-kind": [], + "x-osdu-license": "Copyright 2021, The Open Group \\nLicensed 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.", + "$schema": "http://json-schema.org/draft-07/schema#", + "x-osdu-schema-source": "osdu:wks:AbstractFacilityOperator:1.0.0", + "description": "The organisation that was responsible for a facility at some point in time.", + "title": "AbstractFacilityOperator", + "type": "object", + "properties": { + "FacilityOperatorID": { + "type": "string", + "title": "Facility Operator ID", + "description": "Internal, unique identifier for an item 'AbstractFacilityOperator'. This identifier is used by 'AbstractFacility.CurrentOperatorID' and 'AbstractFacility.InitialOperatorID'." + }, + "EffectiveDateTime": { + "format": "date-time", + "description": "The date and time at which the facility operator becomes effective.", + "x-osdu-frame-of-reference": "DateTime", + "type": "string" + }, + "FacilityOperatorOrganisationID": { + "pattern": "^[\\w\\-\\.]+:master-data\\-\\-Organisation:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "description": "The company that currently operates, or previously operated the facility", + "x-osdu-relationship": [ + { + "EntityType": "Organisation", + "GroupType": "master-data" + } + ], + "type": "string" + }, + "TerminationDateTime": { + "format": "date-time", + "description": "The date and time at which the facility operator is no longer in effect. If the operator is still effective, the 'TerminationDateTime' is left absent.", + "x-osdu-frame-of-reference": "DateTime", + "type": "string" + } + }, + "$id": "https://schema.osdu.opengroup.org/json/abstract/AbstractFacilityOperator.1.0.0.json" + } + } + } +} + diff --git a/search-acceptance-test/src/test/resources/testData/records_5.json b/search-acceptance-test/src/test/resources/testData/records_5.json new file mode 100644 index 0000000000000000000000000000000000000000..03c62a3fa635f3539ce7040bcdb424d51d53a00f --- /dev/null +++ b/search-acceptance-test/src/test/resources/testData/records_5.json @@ -0,0 +1,143 @@ +[{ + "id": "test:well:1.0.0:1", + "kind": "<Kind>", + "namespace": "tenant1:testdatasource", + "type": "well", + "acl": "{viewers=[<Data-Group>], owners=[<Data-Group>]}", + "x-acl": [ + "<Data-Group>" + ], + "legal": { + "legaltags": [ + "<Legal-Tag>" + ], + "otherRelevantDataCountries": [ + "<Country>" + ], + "status": "compliant" + }, + "data": { + "Code": "4143", + "CodeAsNumber": 4143, + "CodeSpace": "EPSG", + "CoordinateReferenceSystemType": "GeodeticCRS", + "CoordinateSystem": { + "AuthorityCode": { + "Authority": "EPSG", + "Code": 6422 + }, + "Name": "Ellipsoidal 2D CS. Axes: latitude, longitude. Orientations: north, east. UoM: degree", + "HorizontalAxisUnitID": "{{NAMESPACE}}:reference-data--UnitOfMeasure:dega:" + }, + "Datum": { + "AuthorityCode": { + "Authority": "EPSG", + "Code": 6143 + }, + "Name": "Abidjan 1987" + }, + "Description": "Replaces Locodjo 1965 (EPSG code 4142).", + "ID": "Geographic2D:EPSG::4143", + "Kind": "geographic 2D", + "Name": "Abidjan 1987", + "PersistableReference": "{\"authCode\":{\"auth\":\"EPSG\",\"code\":\"4143\"},\"name\":\"GCS_Abidjan_1987\",\"type\":\"LBC\",\"ver\":\"PE_10_9_1\",\"wkt\":\"GEOGCS[\\\"GCS_Abidjan_1987\\\",DATUM[\\\"D_Abidjan_1987\\\",SPHEROID[\\\"Clarke_1880_RGS\\\",6378249.145,293.465]],PRIMEM[\\\"Greenwich\\\",0.0],UNIT[\\\"Degree\\\",0.0174532925199433],AUTHORITY[\\\"EPSG\\\",4143]]\"}", + "PreferredUsage": { + "AuthorityCode": { + "Authority": "EPSG", + "Code": 3028 + }, + "Extent": { + "AuthorityCode": { + "Authority": "EPSG", + "Code": 1075 + }, + "BoundingBoxEastBoundLongitude": -2.48, + "BoundingBoxNorthBoundLatitude": 10.74, + "BoundingBoxSouthBoundLatitude": 1.02, + "BoundingBoxWestBoundLongitude": -8.61, + "Description": "C\u00f4te d'Ivoire (Ivory Coast) - onshore and offshore.", + "Name": "Cote d'Ivoire (Ivory Coast)" + }, + "Name": "Cote d'Ivoire (Ivory Coast)", + "Scope": { + "AuthorityCode": { + "Authority": "EPSG", + "Code": 1027 + }, + "Name": "Geodesy." + } + }, + "RevisionDate": "2016-12-15T00:00:00+00:00", + "Usages": [ + { + "AuthorityCode": { + "Authority": "EPSG", + "Code": 3028 + }, + "Extent": { + "AuthorityCode": { + "Authority": "EPSG", + "Code": 1075 + }, + "BoundingBoxEastBoundLongitude": -2.48, + "BoundingBoxNorthBoundLatitude": 10.74, + "BoundingBoxSouthBoundLatitude": 1.02, + "BoundingBoxWestBoundLongitude": -8.61, + "Description": "C\u00f4te d'Ivoire (Ivory Coast) - onshore and offshore.", + "Name": "Cote d'Ivoire (Ivory Coast)" + }, + "Name": "Cote d'Ivoire (Ivory Coast)", + "Scope": { + "AuthorityCode": { + "Authority": "EPSG", + "Code": 1027 + }, + "Name": "Geodesy." + } + } + ], + "Wgs84Coordinates": { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -8.61, + 1.02 + ], + [ + -2.48, + 1.02 + ], + [ + -2.48, + 10.74 + ], + [ + -8.61, + 10.74 + ], + [ + -8.61, + 1.02 + ] + ] + ] + } + } + ] + }, + "Source": "Workbook Resources/IOGP/Manifests/reference-data/CoordinateReferenceSystem.1.1.0.json; commit SHA a046fbd2.", + "CommitDate": "2022-04-02T14:45:12+02:00" + }, + "index": { + "statusCode": 200, + "lastUpdateTime": "2018-10-04T10:11:22.303000" + } +} +] diff --git a/search-acceptance-test/src/test/resources/testData/records_5.mapping b/search-acceptance-test/src/test/resources/testData/records_5.mapping new file mode 100644 index 0000000000000000000000000000000000000000..a405ab76aec7f29a271fee96df9592e99eb0a290 --- /dev/null +++ b/search-acceptance-test/src/test/resources/testData/records_5.mapping @@ -0,0 +1,214 @@ +{ + "dynamic": "false", + "properties": { + "acl": { + "properties": { + "owners": { + "type": "keyword" + }, + "viewers": { + "type": "keyword" + } + } + }, + "ancestry": { + "properties": { + "parents": { + "type": "keyword" + } + } + }, + "data": { + "properties": { + "Code": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "CodeAsNumber": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "CodeSpace": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "CoordinateReferenceSystemType": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "CoordinateSystem": { + "type": "object" + }, + "Datum": { + "type": "object" + }, + "Description": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "ID": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "Kind": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "Name": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "PersistableReference": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "PreferredUsage": { + "type": "object" + }, + "RevisionDate": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "Usages": { + "type": "object" + }, + "Wgs84Coordinates": { + "type": "geometrycollection", + "geometries": [ + { + "type": "Polygon", + "coordinates": [[[-8.61, 1.02], [-2.48, 1.02], [-2.48, 10.74], [-8.61, 10.74], [-8.61, 1.02]]] + } + ] + }, + "Source": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + }, + "CommitDate": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword", + "null_value": "null", + "ignore_above": 256 + } + } + } + } + }, + "id": { + "type": "keyword" + }, + "index": { + "properties": { + "lastUpdateTime": { + "type": "date" + }, + "statusCode": { + "type": "integer" + }, + "trace": { + "type": "text" + } + } + }, + "kind": { + "type": "keyword" + }, + "legal": { + "properties": { + "legaltags": { + "type": "keyword" + }, + "otherRelevantDataCountries": { + "type": "keyword" + }, + "status": { + "type": "keyword" + } + } + }, + "namespace": { + "type": "keyword" + }, + "tags": { + "type": "object" + }, + "type": { + "type": "keyword" + }, + "version": { + "type": "long" + }, + "x-acl": { + "type": "keyword" + } + } +} diff --git a/search-acceptance-test/src/test/resources/testData/records_6.json b/search-acceptance-test/src/test/resources/testData/records_6.json new file mode 100644 index 0000000000000000000000000000000000000000..0ae86dc71057a6d628d07b65a1a8180053431b3f --- /dev/null +++ b/search-acceptance-test/src/test/resources/testData/records_6.json @@ -0,0 +1,71 @@ +[ + { + "id": "tenant1:search-collab<timestamp>:1", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "OSDU OFFICE - 1", + "Location": { + "lat":18.5204, + "lon":73.8567 + }, + "Basin": "India", + "State": "Maharashtra", + "Country": "India", + "WellStatus": "Under development", + "OriginalOperator": "OFFICE1", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 1, + "Score": 10, + "Established": "1990-03-27T23:38:48Z" + } + }, + { + "id": "tenant1:search-collab<timestamp>:2", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "OSDU OFFICE - 3", + "Location": { + "lat": 29.749655, + "lon": -95.473476 + }, + "Basin": "KATY", + "County": "Waller", + "State": "TEXAS", + "Country": "United States", + "WellStatus": "Under development", + "OriginalOperator": "OFFICE3", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 2, + "Score": 12, + "Established": "2010-03-27T20:38:48Z" + } + }, + { + "id": "tenant1:search-collab<timestamp>:3", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "OSDU OFFICE - 4", + "Location": { + "lat":29.6197, + "lon":-95.6349 + }, + "WellStatus": "Under development", + "OriginalOperator": "OFFICE4", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 20, + "Established": "2018-03-27T23:38:48Z" + } + } +] diff --git a/search-acceptance-test/src/test/resources/testData/records_6.schema.json b/search-acceptance-test/src/test/resources/testData/records_6.schema.json new file mode 100644 index 0000000000000000000000000000000000000000..cf4b68dd971c09aba1ce98267534147056c8b5ae --- /dev/null +++ b/search-acceptance-test/src/test/resources/testData/records_6.schema.json @@ -0,0 +1,124 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "tenant1", + "source": "search-collab<timestamp>", + "entityType": "test-data--Integration", + "schemaVersionMajor": "1", + "schemaVersionMinor": "0", + "schemaVersionPatch": "6" + }, + "status": "DEVELOPMENT" + }, + "schema": { + "properties": { + "data": { + "allOf": [ + { + "type": "object", + "properties": { + "Field": { + "type": "string" + }, + "Location": { + "$ref": "#/definitions/opendes:wks:core_dl_geopoint:1.0.0", + "description": "The wellbore's position .", + "format": "core:dl:geopoint:1.0.0", + "title": "WGS 84 Position", + "type": "object" + }, + "Basin": { + "type": "string" + }, + "County": { + "type": "string" + } + } + } + ], + "anyOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "Country": { + "type": "string" + }, + "WellStatus": { + "type": "string" + }, + "OriginalOperator": { + "type": "string" + }, + "WellName": { + "type": "string" + }, + "WellType": { + "type": "string" + }, + "EmptyAttribute": { + "type": "string" + }, + "Center": { + "type": "string" + } + } + } + ], + "oneOf": [ + { + "type": "object", + "properties": { + "Rank": { + "type": "integer" + }, + "Score": { + "type": "integer" + }, + "Established": { + "type": "date-time" + }, + "DblArray": { + "description": "The name of the host [cloud environment] region(s) for this OSDU resource object.", + "title": "Resource Host Region ID", + "type": "array", + "items": { + "type": "number" + } + } + } + } + ] + } + }, + "definitions": { + "opendes:wks:core_dl_geopoint:1.0.0": { + "description": "A 2D point location in latitude and longitude referenced to WGS 84 if not specified otherwise.", + "properties": { + "latitude": { + "description": "The latitude value in degrees of arc (dega). Value range [-90, 90].", + "maximum": 90, + "minimum": -90, + "title": "Latitude", + "type": "number" + }, + "longitude": { + "description": "The longitude value in degrees of arc (dega). Value range [-180, 180]", + "maximum": 180, + "minimum": -180, + "title": "Longitude", + "type": "number" + } + }, + "required": [ + "latitude", + "longitude" + ], + "title": "2D Map Location", + "type": "object" + } + } + } +} diff --git a/search-acceptance-test/src/test/resources/testData/records_7.json b/search-acceptance-test/src/test/resources/testData/records_7.json new file mode 100644 index 0000000000000000000000000000000000000000..0ae86dc71057a6d628d07b65a1a8180053431b3f --- /dev/null +++ b/search-acceptance-test/src/test/resources/testData/records_7.json @@ -0,0 +1,71 @@ +[ + { + "id": "tenant1:search-collab<timestamp>:1", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "OSDU OFFICE - 1", + "Location": { + "lat":18.5204, + "lon":73.8567 + }, + "Basin": "India", + "State": "Maharashtra", + "Country": "India", + "WellStatus": "Under development", + "OriginalOperator": "OFFICE1", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 1, + "Score": 10, + "Established": "1990-03-27T23:38:48Z" + } + }, + { + "id": "tenant1:search-collab<timestamp>:2", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "OSDU OFFICE - 3", + "Location": { + "lat": 29.749655, + "lon": -95.473476 + }, + "Basin": "KATY", + "County": "Waller", + "State": "TEXAS", + "Country": "United States", + "WellStatus": "Under development", + "OriginalOperator": "OFFICE3", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 2, + "Score": 12, + "Established": "2010-03-27T20:38:48Z" + } + }, + { + "id": "tenant1:search-collab<timestamp>:3", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "OSDU OFFICE - 4", + "Location": { + "lat":29.6197, + "lon":-95.6349 + }, + "WellStatus": "Under development", + "OriginalOperator": "OFFICE4", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 20, + "Established": "2018-03-27T23:38:48Z" + } + } +] diff --git a/search-acceptance-test/src/test/resources/testData/records_7.schema.json b/search-acceptance-test/src/test/resources/testData/records_7.schema.json new file mode 100644 index 0000000000000000000000000000000000000000..7739212e179bf0baf90f3d4b89429a7fa85147f6 --- /dev/null +++ b/search-acceptance-test/src/test/resources/testData/records_7.schema.json @@ -0,0 +1,124 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "tenant1", + "source": "search-collab<timestamp>", + "entityType": "test-data--Integration", + "schemaVersionMajor": "1", + "schemaVersionMinor": "0", + "schemaVersionPatch": "7" + }, + "status": "DEVELOPMENT" + }, + "schema": { + "properties": { + "data": { + "allOf": [ + { + "type": "object", + "properties": { + "Field": { + "type": "string" + }, + "Location": { + "$ref": "#/definitions/opendes:wks:core_dl_geopoint:1.0.0", + "description": "The wellbore's position .", + "format": "core:dl:geopoint:1.0.0", + "title": "WGS 84 Position", + "type": "object" + }, + "Basin": { + "type": "string" + }, + "County": { + "type": "string" + } + } + } + ], + "anyOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "Country": { + "type": "string" + }, + "WellStatus": { + "type": "string" + }, + "OriginalOperator": { + "type": "string" + }, + "WellName": { + "type": "string" + }, + "WellType": { + "type": "string" + }, + "EmptyAttribute": { + "type": "string" + }, + "Center": { + "type": "string" + } + } + } + ], + "oneOf": [ + { + "type": "object", + "properties": { + "Rank": { + "type": "integer" + }, + "Score": { + "type": "integer" + }, + "Established": { + "type": "date-time" + }, + "DblArray": { + "description": "The name of the host [cloud environment] region(s) for this OSDU resource object.", + "title": "Resource Host Region ID", + "type": "array", + "items": { + "type": "number" + } + } + } + } + ] + } + }, + "definitions": { + "opendes:wks:core_dl_geopoint:1.0.0": { + "description": "A 2D point location in latitude and longitude referenced to WGS 84 if not specified otherwise.", + "properties": { + "latitude": { + "description": "The latitude value in degrees of arc (dega). Value range [-90, 90].", + "maximum": 90, + "minimum": -90, + "title": "Latitude", + "type": "number" + }, + "longitude": { + "description": "The longitude value in degrees of arc (dega). Value range [-180, 180]", + "maximum": 180, + "minimum": -180, + "title": "Longitude", + "type": "number" + } + }, + "required": [ + "latitude", + "longitude" + ], + "title": "2D Map Location", + "type": "object" + } + } + } +} diff --git a/search-acceptance-test/src/test/resources/testData/records_8.json b/search-acceptance-test/src/test/resources/testData/records_8.json new file mode 100644 index 0000000000000000000000000000000000000000..4c84439bceb1de778e2865f073fe092a483d3134 --- /dev/null +++ b/search-acceptance-test/src/test/resources/testData/records_8.json @@ -0,0 +1,71 @@ +[ + { + "id": "tenant1:search-collab<timestamp>:1", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "SOR", + "Location": { + "lat":18.5204, + "lon":73.8567 + }, + "Basin": "India", + "State": "Maharashtra", + "Country": "India", + "WellStatus": "Under development", + "OriginalOperator": "OFFICE1", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 1, + "Score": 10, + "Established": "1990-03-27T23:38:48Z" + } + }, + { + "id": "tenant1:search-collab<timestamp>:2", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "SOR", + "Location": { + "lat": 29.749655, + "lon": -95.473476 + }, + "Basin": "KATY", + "County": "Waller", + "State": "TEXAS", + "Country": "United States", + "WellStatus": "Under development", + "OriginalOperator": "OFFICE3", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 2, + "Score": 12, + "Established": "2010-03-27T20:38:48Z" + } + }, + { + "id": "tenant1:search-collab<timestamp>:3", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "SOR", + "Location": { + "lat":29.6197, + "lon":-95.6349 + }, + "WellStatus": "Under development", + "OriginalOperator": "OFFICE4", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 20, + "Established": "2018-03-27T23:38:48Z" + } + } +] diff --git a/search-acceptance-test/src/test/resources/testData/records_8.schema.json b/search-acceptance-test/src/test/resources/testData/records_8.schema.json new file mode 100644 index 0000000000000000000000000000000000000000..9c77101b5461526d86428006eaf2617c2124b093 --- /dev/null +++ b/search-acceptance-test/src/test/resources/testData/records_8.schema.json @@ -0,0 +1,124 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "tenant1", + "source": "search-collab<timestamp>", + "entityType": "test-data--Integration", + "schemaVersionMajor": "1", + "schemaVersionMinor": "0", + "schemaVersionPatch": "8" + }, + "status": "DEVELOPMENT" + }, + "schema": { + "properties": { + "data": { + "allOf": [ + { + "type": "object", + "properties": { + "Field": { + "type": "string" + }, + "Location": { + "$ref": "#/definitions/opendes:wks:core_dl_geopoint:1.0.0", + "description": "The wellbore's position .", + "format": "core:dl:geopoint:1.0.0", + "title": "WGS 84 Position", + "type": "object" + }, + "Basin": { + "type": "string" + }, + "County": { + "type": "string" + } + } + } + ], + "anyOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "Country": { + "type": "string" + }, + "WellStatus": { + "type": "string" + }, + "OriginalOperator": { + "type": "string" + }, + "WellName": { + "type": "string" + }, + "WellType": { + "type": "string" + }, + "EmptyAttribute": { + "type": "string" + }, + "Center": { + "type": "string" + } + } + } + ], + "oneOf": [ + { + "type": "object", + "properties": { + "Rank": { + "type": "integer" + }, + "Score": { + "type": "integer" + }, + "Established": { + "type": "date-time" + }, + "DblArray": { + "description": "The name of the host [cloud environment] region(s) for this OSDU resource object.", + "title": "Resource Host Region ID", + "type": "array", + "items": { + "type": "number" + } + } + } + } + ] + } + }, + "definitions": { + "opendes:wks:core_dl_geopoint:1.0.0": { + "description": "A 2D point location in latitude and longitude referenced to WGS 84 if not specified otherwise.", + "properties": { + "latitude": { + "description": "The latitude value in degrees of arc (dega). Value range [-90, 90].", + "maximum": 90, + "minimum": -90, + "title": "Latitude", + "type": "number" + }, + "longitude": { + "description": "The longitude value in degrees of arc (dega). Value range [-180, 180]", + "maximum": 180, + "minimum": -180, + "title": "Longitude", + "type": "number" + } + }, + "required": [ + "latitude", + "longitude" + ], + "title": "2D Map Location", + "type": "object" + } + } + } +} diff --git a/search-acceptance-test/src/test/resources/testData/records_9.json b/search-acceptance-test/src/test/resources/testData/records_9.json new file mode 100644 index 0000000000000000000000000000000000000000..1f5667186312992de0c76fb1c3c7b28a9d2aa9fb --- /dev/null +++ b/search-acceptance-test/src/test/resources/testData/records_9.json @@ -0,0 +1,71 @@ +[ + { + "id": "tenant1:search-collab<timestamp>:1", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "Namespace", + "Location": { + "lat":18.5204, + "lon":73.8567 + }, + "Basin": "India", + "State": "Maharashtra", + "Country": "India", + "WellStatus": "Under development", + "OriginalOperator": "OFFICE1", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 1, + "Score": 10, + "Established": "1990-03-27T23:38:48Z" + } + }, + { + "id": "tenant1:search-collab<timestamp>:2", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "Namespace", + "Location": { + "lat": 29.749655, + "lon": -95.473476 + }, + "Basin": "KATY", + "County": "Waller", + "State": "TEXAS", + "Country": "United States", + "WellStatus": "Under development", + "OriginalOperator": "OFFICE3", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 2, + "Score": 12, + "Established": "2010-03-27T20:38:48Z" + } + }, + { + "id": "tenant1:search-collab<timestamp>:3", + "tags": { + "testtag": "testvalue" + }, + "data": { + "Field": "Namespace", + "Location": { + "lat":29.6197, + "lon":-95.6349 + }, + "WellStatus": "Under development", + "OriginalOperator": "OFFICE4", + "WellName": "Data Platform Services", + "WellType": "Data Lake Cloud", + "EmptyAttribute": "", + "Rank": 20, + "Established": "2018-03-27T23:38:48Z" + } + } +]