Skip to content

Commit

Permalink
Use OpenSearch 2.0.0-alpha1 (opensearch-project#370)
Browse files Browse the repository at this point in the history
* 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>
Signed-off-by: Angie Zhang <langelzh@amazon.com>
  • Loading branch information
qreshi authored and Angie Zhang committed Jun 29, 2022
1 parent 5246e77 commit 9239a6d
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bwc-test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:
- name: Run Alerting Backwards Compatibility Tests
run: |
echo "Running backwards compatibility tests..."
./gradlew bwcTestSuite
./gradlew bwcTestSuite -Dbuild.qualifier=alpha1
2 changes: 1 addition & 1 deletion .github/workflows/multi-node-test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/security-test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion alerting/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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<RegularFile>(){
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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].
Expand All @@ -38,7 +37,7 @@ class ScheduledJobIndices(private val client: AdminClient, private val clusterSe
fun initScheduledJobIndex(actionListener: ActionListener<CreateIndexResponse>) {
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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9239a6d

Please sign in to comment.