diff --git a/integ-test/build.gradle b/integ-test/build.gradle index 441508033e..d060e564f5 100644 --- a/integ-test/build.gradle +++ b/integ-test/build.gradle @@ -199,6 +199,9 @@ dependencies { // Needed for BWC tests zipArchive group: 'org.opensearch.plugin', name:'opensearch-job-scheduler', version: "${opensearch_build}" zipArchive group: 'org.opensearch.plugin', name:'opensearch-sql-plugin', version: "${bwcVersion}-SNAPSHOT" + + // For GeoIP PPL functions + zipArchive group: 'org.opensearch.plugin', name:'geospatial', version: "${opensearch_build}" } java { @@ -242,16 +245,27 @@ def getJobSchedulerPlugin() { }) } +def getGeoSpatialPlugin() { + provider { (RegularFile) (() -> + configurations.zipArchive.asFileTree.matching { + include '**/geospatia*' + }.singleFile ) + } +} + + testClusters { integTest { testDistribution = 'archive' plugin(getJobSchedulerPlugin()) + plugin(getGeoSpatialPlugin()) plugin ":opensearch-sql-plugin" setting "plugins.query.datasources.encryption.masterkey", "1234567812345678" } remoteCluster { testDistribution = 'archive' plugin(getJobSchedulerPlugin()) + plugin(getGeoSpatialPlugin()) plugin ":opensearch-sql-plugin" } integTestWithSecurity { diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/GeoIpFunctionsIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/GeoIpFunctionsIT.java new file mode 100644 index 0000000000..3eb17387ad --- /dev/null +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/GeoIpFunctionsIT.java @@ -0,0 +1,48 @@ +/* + * + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + * + */ + +package org.opensearch.sql.ppl; + +import static org.opensearch.sql.legacy.TestUtils.getResponseBody; + +import java.io.IOException; +import lombok.SneakyThrows; +import org.junit.Assert; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.opensearch.client.Request; +import org.opensearch.client.RequestOptions; +import org.opensearch.client.Response; + +/** IP enrichment PPL request with OpenSearch Geo-sptial plugin */ +public class GeoIpFunctionsIT extends PPLIntegTestCase { + + private static boolean initialized = false; + + private static String PLUGIN_NAME = "opensearch-geospatial"; + + @SneakyThrows + @BeforeEach + public void initialize() { + if (!initialized) { + setUpIndices(); + initialized = true; + } + } + + @Test + public void testGeoPluginInstallation() throws IOException { + + Request request = new Request("GET", "/_cat/plugins?v"); + RequestOptions.Builder restOptionsBuilder = RequestOptions.DEFAULT.toBuilder(); + restOptionsBuilder.addHeader("Content-Type", "application/json"); + request.setOptions(restOptionsBuilder); + Response response = client().performRequest(request); + Assert.assertEquals(200, response.getStatusLine().getStatusCode()); + Assert.assertTrue(getResponseBody(response, true).contains(PLUGIN_NAME)); + } +}