From 5a1b96f56713b80e01f9d0641356846c7a659fb0 Mon Sep 17 00:00:00 2001 From: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> Date: Wed, 30 Mar 2022 11:27:47 -0700 Subject: [PATCH] Use OpenSearch 2.0.0-alpha1 (#370) * Use OpenSearch 2.0.0-alpha1 Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Remove use of mapping types Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Pass in alpha1 build qualifier when assembling/building in GitHub Actions Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> --- .github/workflows/bwc-test-workflow.yml | 2 +- .github/workflows/multi-node-test-workflow.yml | 2 +- .github/workflows/security-test-workflow.yml | 2 +- .github/workflows/test-workflow.yml | 2 +- alerting/build.gradle | 2 +- .../kotlin/org/opensearch/alerting/alerts/AlertIndices.kt | 7 ++----- .../bucketselectorext/BucketSelectorExtAggregatorTests.kt | 2 +- build.gradle | 2 +- .../org/opensearch/alerting/core/ScheduledJobIndices.kt | 3 +-- .../org/opensearch/alerting/core/model/ScheduledJob.kt | 8 -------- 10 files changed, 10 insertions(+), 22 deletions(-) diff --git a/.github/workflows/bwc-test-workflow.yml b/.github/workflows/bwc-test-workflow.yml index 423fd22ab..ea28b76c8 100644 --- a/.github/workflows/bwc-test-workflow.yml +++ b/.github/workflows/bwc-test-workflow.yml @@ -34,4 +34,4 @@ jobs: - name: Run Alerting Backwards Compatibility Tests run: | echo "Running backwards compatibility tests..." - ./gradlew bwcTestSuite + ./gradlew bwcTestSuite -Dbuild.qualifier=alpha1 diff --git a/.github/workflows/multi-node-test-workflow.yml b/.github/workflows/multi-node-test-workflow.yml index 683b992f1..4722b58a0 100644 --- a/.github/workflows/multi-node-test-workflow.yml +++ b/.github/workflows/multi-node-test-workflow.yml @@ -27,4 +27,4 @@ jobs: - name: Checkout Branch uses: actions/checkout@v2 - name: Run integration tests with multi node config - run: ./gradlew integTest -PnumNodes=3 + run: ./gradlew integTest -PnumNodes=3 -Dbuild.qualifier=alpha1 diff --git a/.github/workflows/security-test-workflow.yml b/.github/workflows/security-test-workflow.yml index f55f14bdd..8dfe68b5f 100644 --- a/.github/workflows/security-test-workflow.yml +++ b/.github/workflows/security-test-workflow.yml @@ -33,7 +33,7 @@ jobs: java-version: 11 - name: Build Alerting # Only assembling since the full build is governed by other workflows - run: ./gradlew assemble + run: ./gradlew assemble -Dbuild.qualifier=alpha1 - name: Pull and Run Docker run: | plugin=`ls alerting/build/distributions/*.zip` diff --git a/.github/workflows/test-workflow.yml b/.github/workflows/test-workflow.yml index 012c1534a..b764b39c7 100644 --- a/.github/workflows/test-workflow.yml +++ b/.github/workflows/test-workflow.yml @@ -27,7 +27,7 @@ jobs: with: java-version: ${{ matrix.java }} - name: Build and run with Gradle - run: ./gradlew build + run: ./gradlew build -Dbuild.qualifier=alpha1 - name: Create Artifact Path run: | mkdir -p alerting-artifacts diff --git a/alerting/build.gradle b/alerting/build.gradle index 40f5ab373..47d0026f5 100644 --- a/alerting/build.gradle +++ b/alerting/build.gradle @@ -161,7 +161,7 @@ String bwcFilePath = "src/test/resources/bwc" testClusters { "${baseName}$i" { testDistribution = "ARCHIVE" - versions = ["7.10.2","2.0.0-SNAPSHOT"] + versions = ["7.10.2","2.0.0-alpha1-SNAPSHOT"] numberOfNodes = 3 plugin(provider(new Callable(){ @Override diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/alerts/AlertIndices.kt b/alerting/src/main/kotlin/org/opensearch/alerting/alerts/AlertIndices.kt index 0c0faa5f4..85c20e0cc 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/alerts/AlertIndices.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/alerts/AlertIndices.kt @@ -79,9 +79,6 @@ class AlertIndices( /** The in progress alert history index. */ const val ALERT_INDEX = ".opendistro-alerting-alerts" - /** The Elastic mapping type */ - const val MAPPING_TYPE = "_doc" - /** The alias of the index in which to write alert history */ const val HISTORY_WRITE_INDEX = ".opendistro-alerting-alert-history-write" @@ -212,7 +209,7 @@ class AlertIndices( if (existsResponse.isExists) return true val request = CreateIndexRequest(index) - .mapping(MAPPING_TYPE, alertMapping(), XContentType.JSON) + .mapping(alertMapping()) .settings(Settings.builder().put("index.hidden", true).build()) if (alias != null) request.alias(Alias(alias)) @@ -267,7 +264,7 @@ class AlertIndices( // We have to pass null for newIndexName in order to get Elastic to increment the index count. val request = RolloverRequest(HISTORY_WRITE_INDEX, null) request.createIndexRequest.index(HISTORY_INDEX_PATTERN) - .mapping(MAPPING_TYPE, alertMapping(), XContentType.JSON) + .mapping(alertMapping()) .settings(Settings.builder().put("index.hidden", true).build()) request.addMaxIndexDocsCondition(historyMaxDocs) request.addMaxIndexAgeCondition(historyMaxAge) diff --git a/alerting/src/test/kotlin/org/opensearch/alerting/aggregation/bucketselectorext/BucketSelectorExtAggregatorTests.kt b/alerting/src/test/kotlin/org/opensearch/alerting/aggregation/bucketselectorext/BucketSelectorExtAggregatorTests.kt index 7b3e4857d..742cc2069 100644 --- a/alerting/src/test/kotlin/org/opensearch/alerting/aggregation/bucketselectorext/BucketSelectorExtAggregatorTests.kt +++ b/alerting/src/test/kotlin/org/opensearch/alerting/aggregation/bucketselectorext/BucketSelectorExtAggregatorTests.kt @@ -9,9 +9,9 @@ import org.apache.lucene.document.Document import org.apache.lucene.document.SortedNumericDocValuesField import org.apache.lucene.document.SortedSetDocValuesField import org.apache.lucene.index.DirectoryReader -import org.apache.lucene.index.RandomIndexWriter import org.apache.lucene.search.MatchAllDocsQuery import org.apache.lucene.search.Query +import org.apache.lucene.tests.index.RandomIndexWriter import org.apache.lucene.util.BytesRef import org.hamcrest.CoreMatchers import org.opensearch.common.CheckedConsumer diff --git a/build.gradle b/build.gradle index 87ebd4c6c..14baeec5a 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { apply from: 'build-tools/repositories.gradle' ext { - opensearch_version = System.getProperty("opensearch.version", "2.0.0-SNAPSHOT") + opensearch_version = System.getProperty("opensearch.version", "2.0.0-alpha1-SNAPSHOT") buildVersionQualifier = System.getProperty("build.version_qualifier") isSnapshot = "true" == System.getProperty("build.snapshot", "true") // 2.0.0-alpha1-SNAPSHOT -> 2.0.0.0-alpha1-SNAPSHOT diff --git a/core/src/main/kotlin/org/opensearch/alerting/core/ScheduledJobIndices.kt b/core/src/main/kotlin/org/opensearch/alerting/core/ScheduledJobIndices.kt index e11f25c3e..621e2361f 100644 --- a/core/src/main/kotlin/org/opensearch/alerting/core/ScheduledJobIndices.kt +++ b/core/src/main/kotlin/org/opensearch/alerting/core/ScheduledJobIndices.kt @@ -13,7 +13,6 @@ import org.opensearch.client.AdminClient import org.opensearch.cluster.health.ClusterIndexHealth import org.opensearch.cluster.service.ClusterService import org.opensearch.common.settings.Settings -import org.opensearch.common.xcontent.XContentType /** * Initialize the OpenSearch components required to run [ScheduledJobs]. @@ -38,7 +37,7 @@ class ScheduledJobIndices(private val client: AdminClient, private val clusterSe fun initScheduledJobIndex(actionListener: ActionListener) { if (!scheduledJobIndexExists()) { var indexRequest = CreateIndexRequest(ScheduledJob.SCHEDULED_JOBS_INDEX) - .mapping(ScheduledJob.SCHEDULED_JOB_TYPE, scheduledJobMappings(), XContentType.JSON) + .mapping(scheduledJobMappings()) .settings(Settings.builder().put("index.hidden", true).build()) client.indices().create(indexRequest, actionListener) } diff --git a/core/src/main/kotlin/org/opensearch/alerting/core/model/ScheduledJob.kt b/core/src/main/kotlin/org/opensearch/alerting/core/model/ScheduledJob.kt index 0cefed035..6b132ced6 100644 --- a/core/src/main/kotlin/org/opensearch/alerting/core/model/ScheduledJob.kt +++ b/core/src/main/kotlin/org/opensearch/alerting/core/model/ScheduledJob.kt @@ -37,14 +37,6 @@ interface ScheduledJob : Writeable, ToXContentObject { /** The name of the ElasticSearch index in which we store jobs */ const val SCHEDULED_JOBS_INDEX = ".opendistro-alerting-config" - /** - * The mapping type of [ScheduledJob]s in the OpenSearch index. Unrelated to [ScheduledJob.type]. - * - * This should go away starting ES 7. We use "_doc" for future compatibility as described here: - * https://www.elastic.co/guide/en/elasticsearch/reference/6.x/removal-of-types.html#_schedule_for_removal_of_mapping_types - */ - const val SCHEDULED_JOB_TYPE = "_doc" - const val NO_ID = "" const val NO_VERSION = 1L