From af1cf0151eb268ef6450c193a2cfef46c7e20932 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 13 Sep 2023 16:41:16 +0000 Subject: [PATCH] Add integration test suite for the plugin (#42) Signed-off-by: Andriy Redko (cherry picked from commit 63c0cd5d633aaa3a04c733a8a75ef0c0b11e7eea) Signed-off-by: github-actions[bot] --- build.gradle | 43 ++++++++++++++++++- .../codec/rest/CreateIndexWithCodecIT.java | 38 ++++++++++++++++ 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 src/integrationTest/java/org/opensearch/index/codec/rest/CreateIndexWithCodecIT.java diff --git a/build.gradle b/build.gradle index 5618a69..bd02f9b 100644 --- a/build.gradle +++ b/build.gradle @@ -37,6 +37,7 @@ plugins { apply plugin: 'opensearch.opensearchplugin' apply plugin: 'opensearch.internal-cluster-test' apply plugin: 'opensearch.pluginzip' +apply plugin: 'opensearch.rest-test' repositories { mavenLocal() @@ -147,6 +148,46 @@ tasks.withType(Javadoc).configureEach { Javadoc javadoc -> javadoc.options.addStringOption("-release", java.targetCompatibility.majorVersion) } -testingConventions.enabled = false loggerUsageCheck.enabled = false validateNebulaPom.enabled = false + +sourceSets { + integTest { + java { + srcDirs file("src/integrationTest/java") + } + compileClasspath += sourceSets["main"].output + configurations["testRuntimeClasspath"] + runtimeClasspath += output + compileClasspath + } +} + +tasks.named("testingConventions").configure { + naming.clear() + naming { + Tests { + baseClass "org.apache.lucene.tests.util.LuceneTestCase" + } + IT { + baseClass "org.opensearch.test.OpenSearchIntegTestCase" + baseClass "org.opensearch.test.OpenSearchSingleNodeTestCase" + } + } +} + +integTest { + description = "Run tests against a cluster" + testClassesDirs = sourceSets.integTest.output.classesDirs + classpath = sourceSets.integTest.runtimeClasspath + + dependsOn "bundlePlugin" + systemProperty 'tests.security.manager', 'true' + + systemProperty "https", System.getProperty("https") + systemProperty "user", System.getProperty("user") + systemProperty "password", System.getProperty("password") +} + +testClusters.integTest { + testDistribution = "ARCHIVE" + plugin(project.tasks.bundlePlugin.archiveFile) +} \ No newline at end of file diff --git a/src/integrationTest/java/org/opensearch/index/codec/rest/CreateIndexWithCodecIT.java b/src/integrationTest/java/org/opensearch/index/codec/rest/CreateIndexWithCodecIT.java new file mode 100644 index 0000000..9585be9 --- /dev/null +++ b/src/integrationTest/java/org/opensearch/index/codec/rest/CreateIndexWithCodecIT.java @@ -0,0 +1,38 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.index.codec.rest; + +import org.opensearch.cluster.metadata.IndexMetadata; +import org.opensearch.common.settings.Settings; +import org.opensearch.test.rest.OpenSearchRestTestCase; + +import java.io.IOException; + +import static org.opensearch.index.codec.customcodecs.CustomCodecService.ZSTD_CODEC; +import static org.opensearch.index.codec.customcodecs.CustomCodecService.ZSTD_NO_DICT_CODEC; + +public class CreateIndexWithCodecIT extends OpenSearchRestTestCase { + + public void testCreateIndexWithZstdCodec() throws IOException { + final String index = "test-index"; + + // creating index + createIndex( + index, + Settings.builder() + .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) + .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) + .put("index.codec", randomFrom(ZSTD_CODEC, ZSTD_NO_DICT_CODEC)) + .put("index.codec.compression_level", randomIntBetween(1, 6)) + .build() + ); + + ensureGreen(index); + } +}