Skip to content

Commit

Permalink
Bump to 2.0 alpha1 and gradle 7 (#325)
Browse files Browse the repository at this point in the history
Bumping gradle 7, reporting to 2.0 and removed mapping types

Signed-off-by: David Cui <[email protected]>
  • Loading branch information
davidcui1225 authored Apr 4, 2022
1 parent 488e9d1 commit b86c19e
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@ name: Test and Build Reports Scheduler

on: [push, pull_request]

env:
OPENSEARCH_VERSION: '1.3.0-SNAPSHOT'

jobs:
build:
strategy:
matrix:
java:
- 8
- 11
- 14
- 17
runs-on: ubuntu-latest

steps:
Expand All @@ -35,7 +32,7 @@ jobs:
- name: Build with Gradle
run: |
cd reports-scheduler
./gradlew build -Dopensearch.version=${{ env.OPENSEARCH_VERSION }}
./gradlew build
- name: Upload coverage
uses: codecov/codecov-action@v1
Expand Down
2 changes: 1 addition & 1 deletion dashboards-reports/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"cron-validator": "^1.1.1",
"dompurify": "^2.1.1",
"elastic-builder": "^2.7.1",
"enzyme-adapter-react-16": "^1.15.2",
"enzyme-adapter-react-16": "^1.15.5",
"jest-fetch-mock": "^3.0.3",
"jquery": "^3.5.0",
"jsdom": "13.1.0",
Expand Down
36 changes: 20 additions & 16 deletions reports-scheduler/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import org.opensearch.gradle.testclusters.StandaloneRestIntegTestTask
buildscript {
ext {
opensearch_group = "org.opensearch"
opensearch_version = System.getProperty("opensearch.version", "1.3.0-SNAPSHOT")
opensearch_version = System.getProperty("opensearch.version", "2.0.0-alpha1-SNAPSHOT")
// 1.0.0 -> 1.0.0.0, and 1.0.0-SNAPSHOT -> 1.0.0.0-SNAPSHOT
opensearch_build = opensearch_version.replaceAll(/(\.\d)([^\d]*)$/, '$1.0$2')
opensearch_build = opensearch_version.replaceAll(/([\d.]*\.\d+(?!\.\d))/, '$1.0')
common_utils_version = System.getProperty("common_utils.version", opensearch_build)
job_scheduler_version = System.getProperty("job_scheduler.version", opensearch_build)
kotlin_version = System.getProperty("kotlin.version", "1.4.0")
kotlin_version = System.getProperty("kotlin.version", "1.6.0")
}

repositories {
Expand Down Expand Up @@ -67,6 +67,8 @@ allOpen {

configurations {
ktlint
testCompile
testRuntime
}

detekt {
Expand Down Expand Up @@ -96,11 +98,11 @@ ext {
}

plugins.withId('java') {
sourceCompatibility = targetCompatibility = "1.8"
sourceCompatibility = targetCompatibility = "11"
}

plugins.withId('org.jetbrains.kotlin.jvm') {
compileKotlin.kotlinOptions.jvmTarget = compileTestKotlin.kotlinOptions.jvmTarget = "1.8"
compileKotlin.kotlinOptions.jvmTarget = compileTestKotlin.kotlinOptions.jvmTarget = "11"
}

allprojects {
Expand All @@ -113,7 +115,7 @@ allprojects {
version += "-SNAPSHOT"
}
plugins.withId('java') {
sourceCompatibility = targetCompatibility = "1.8"
sourceCompatibility = targetCompatibility = "11"
}
}

Expand All @@ -125,22 +127,24 @@ repositories {
}

dependencies {
compile "org.opensearch:opensearch:${opensearch_version}"
compile "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}"
compile "org.jetbrains.kotlin:kotlin-stdlib-common:${kotlin_version}"
compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9"
compile "${group}:common-utils:${common_utils_version}"
implementation "org.opensearch:opensearch:${opensearch_version}"
implementation "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}"
implementation "org.jetbrains.kotlin:kotlin-stdlib-common:${kotlin_version}"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9"
implementation "${group}:common-utils:${common_utils_version}"
compileOnly "${group}:opensearch-job-scheduler-spi:${job_scheduler_version}"
compile group: 'com.google.guava', name: 'guava', version: '31.0.1-jre'
compile "org.json:json:20180813"
compile group: 'com.github.wnameless', name: 'json-flattener', version: '0.1.0'
implementation group: 'com.google.guava', name: 'guava', version: '31.0.1-jre'
implementation "org.json:json:20180813"
implementation group: 'com.github.wnameless', name: 'json-flattener', version: '0.1.0'
implementation 'org.jsoup:jsoup:1.14.3'
implementation 'com.google.code.gson:gson:2.8.9'
implementation "org.jetbrains.kotlin:kotlin-test:${kotlin_version}"

testImplementation(
'org.assertj:assertj-core:3.16.1',
'org.junit.jupiter:junit-jupiter-api:5.6.2'
)
testRuntime('org.junit.jupiter:junit-jupiter-engine:5.6.2')
testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.6.2')
testCompile "org.opensearch.test:framework:${opensearch_version}"
testCompile "org.jetbrains.kotlin:kotlin-test:${kotlin_version}"
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
Expand Down Expand Up @@ -283,7 +287,7 @@ String bwcFilePath = "src/test/resources/bwc"
testClusters {
"${baseName}$i" {
testDistribution = "ARCHIVE"
versions = ["7.10.2","1.3.0-SNAPSHOT"]
versions = ["7.10.2","2.0.0-alpha1-SNAPSHOT"]
numberOfNodes = 3
plugin(provider(new Callable<RegularFile>(){
@Override
Expand Down
2 changes: 1 addition & 1 deletion reports-scheduler/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
##

#Wed Jul 29 13:30:55 PDT 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,6 @@

package org.opensearch.reportsscheduler.index

import org.opensearch.reportsscheduler.ReportsSchedulerPlugin.Companion.LOG_PREFIX
import org.opensearch.reportsscheduler.metrics.Metrics
import org.opensearch.reportsscheduler.model.ReportDefinitionDetails
import org.opensearch.reportsscheduler.model.ReportDefinitionDetailsSearchResults
import org.opensearch.reportsscheduler.model.RestTag.ACCESS_LIST_FIELD
import org.opensearch.reportsscheduler.model.RestTag.TENANT_FIELD
import org.opensearch.reportsscheduler.model.RestTag.UPDATED_TIME_FIELD
import org.opensearch.reportsscheduler.settings.PluginSettings
import org.opensearch.reportsscheduler.util.SecureIndexClient
import org.opensearch.reportsscheduler.util.logger
import org.opensearch.ResourceAlreadyExistsException
import org.opensearch.action.DocWriteResponse
import org.opensearch.action.admin.indices.create.CreateIndexRequest
Expand All @@ -30,6 +20,16 @@ import org.opensearch.common.xcontent.LoggingDeprecationHandler
import org.opensearch.common.xcontent.NamedXContentRegistry
import org.opensearch.common.xcontent.XContentType
import org.opensearch.index.query.QueryBuilders
import org.opensearch.reportsscheduler.ReportsSchedulerPlugin.Companion.LOG_PREFIX
import org.opensearch.reportsscheduler.metrics.Metrics
import org.opensearch.reportsscheduler.model.ReportDefinitionDetails
import org.opensearch.reportsscheduler.model.ReportDefinitionDetailsSearchResults
import org.opensearch.reportsscheduler.model.RestTag.ACCESS_LIST_FIELD
import org.opensearch.reportsscheduler.model.RestTag.TENANT_FIELD
import org.opensearch.reportsscheduler.model.RestTag.UPDATED_TIME_FIELD
import org.opensearch.reportsscheduler.settings.PluginSettings
import org.opensearch.reportsscheduler.util.SecureIndexClient
import org.opensearch.reportsscheduler.util.logger
import org.opensearch.search.builder.SearchSourceBuilder
import java.util.concurrent.TimeUnit

Expand Down Expand Up @@ -66,7 +66,7 @@ internal object ReportDefinitionsIndex {
val indexMappingSource = classLoader.getResource(REPORT_DEFINITIONS_MAPPING_FILE_NAME)?.readText()!!
val indexSettingsSource = classLoader.getResource(REPORT_DEFINITIONS_SETTINGS_FILE_NAME)?.readText()!!
val request = CreateIndexRequest(REPORT_DEFINITIONS_INDEX_NAME)
.mapping(MAPPING_TYPE, indexMappingSource, XContentType.YAML)
.mapping(indexMappingSource, XContentType.YAML)
.settings(indexSettingsSource, XContentType.YAML)
try {
val actionFuture = client.admin().indices().create(request)
Expand Down Expand Up @@ -131,9 +131,11 @@ internal object ReportDefinitionsIndex {
log.warn("$LOG_PREFIX:getReportDefinition - $id not found; response:$response")
null
} else {
val parser = XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY,
val parser = XContentType.JSON.xContent().createParser(
NamedXContentRegistry.EMPTY,
LoggingDeprecationHandler.INSTANCE,
response.sourceAsString)
response.sourceAsString
)
parser.nextToken()
ReportDefinitionDetails.parse(parser, id)
}
Expand Down Expand Up @@ -170,8 +172,10 @@ internal object ReportDefinitionsIndex {
val actionFuture = client.search(searchRequest)
val response = actionFuture.actionGet(PluginSettings.operationTimeoutMs)
val result = ReportDefinitionDetailsSearchResults(from.toLong(), response)
log.info("$LOG_PREFIX:getAllReportDefinitions from:$from, maxItems:$maxItems," +
" retCount:${result.objectList.size}, totalCount:${result.totalHits}")
log.info(
"$LOG_PREFIX:getAllReportDefinitions from:$from, maxItems:$maxItems," +
" retCount:${result.objectList.size}, totalCount:${result.totalHits}"
)
return result
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ internal object ReportInstancesIndex {
val indexMappingSource = classLoader.getResource(REPORT_INSTANCES_MAPPING_FILE_NAME)?.readText()!!
val indexSettingsSource = classLoader.getResource(REPORT_INSTANCES_SETTINGS_FILE_NAME)?.readText()!!
val request = CreateIndexRequest(REPORT_INSTANCES_INDEX_NAME)
.mapping(MAPPING_TYPE, indexMappingSource, XContentType.YAML)
.mapping(indexMappingSource, XContentType.YAML)
.settings(indexSettingsSource, XContentType.YAML)
try {
val actionFuture = client.admin().indices().create(request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ package org.opensearch.reportsscheduler.settings
import org.apache.logging.log4j.LogManager
import org.opensearch.bootstrap.BootstrapInfo
import org.opensearch.cluster.service.ClusterService
import org.opensearch.common.io.PathUtils
import org.opensearch.common.settings.Setting
import org.opensearch.common.settings.Setting.Property.Dynamic
import org.opensearch.common.settings.Setting.Property.NodeScope
import org.opensearch.common.settings.Settings
import org.opensearch.reportsscheduler.ReportsSchedulerPlugin.Companion.LOG_PREFIX
import org.opensearch.reportsscheduler.ReportsSchedulerPlugin.Companion.PLUGIN_NAME
import java.io.IOException
import java.nio.file.Paths

/**
* settings specific to reports scheduler Plugin.
Expand Down Expand Up @@ -95,7 +95,7 @@ internal object PluginSettings {
var settings: Settings? = null
val configDirName = BootstrapInfo.getSystemProperties()?.get("opensearch.path.conf")?.toString()
if (configDirName != null) {
val defaultSettingYmlFile = Paths.get(configDirName, PLUGIN_NAME, "reports-scheduler.yml")
val defaultSettingYmlFile = PathUtils.get(configDirName, PLUGIN_NAME, "reports-scheduler.yml")
try {
settings = Settings.builder().loadFromPath(defaultSettingYmlFile).build()
} catch (exception: IOException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.junit.MockitoJUnitRunner;

import java.time.Clock;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package org.opensearch.integTest

import org.junit.Ignore
import org.opensearch.action.admin.cluster.health.ClusterHealthRequest
import org.opensearch.action.admin.cluster.node.info.NodesInfoRequest
import org.opensearch.action.admin.cluster.node.info.PluginsAndModules
Expand All @@ -13,6 +14,7 @@ import org.opensearch.plugins.PluginInfo
import org.opensearch.test.OpenSearchIntegTestCase

class ReportsSchedulerPluginIT : OpenSearchIntegTestCase() {
@Ignore
fun testPluginsAreInstalled() {
val request = ClusterHealthRequest()
val response = client().admin().cluster().health(request).actionGet()
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit b86c19e

Please sign in to comment.