Skip to content

Commit

Permalink
CI: Geo-Spatial Plugin integration test (#3244)
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Kwok <[email protected]>
  • Loading branch information
andy-k-improving authored Jan 21, 2025
1 parent becf303 commit ef3d7b6
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
14 changes: 14 additions & 0 deletions integ-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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));
}
}

0 comments on commit ef3d7b6

Please sign in to comment.