diff --git a/.github/workflows/reports-scheduler-test-and-build-workflow.yml b/.github/workflows/reports-scheduler-test-and-build-workflow.yml index 20181d6d..314f2b18 100644 --- a/.github/workflows/reports-scheduler-test-and-build-workflow.yml +++ b/.github/workflows/reports-scheduler-test-and-build-workflow.yml @@ -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: @@ -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 diff --git a/dashboards-reports/package.json b/dashboards-reports/package.json index d39342db..fe287a98 100644 --- a/dashboards-reports/package.json +++ b/dashboards-reports/package.json @@ -25,7 +25,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", diff --git a/reports-scheduler/build.gradle b/reports-scheduler/build.gradle index d1a7fa3a..5e00d495 100644 --- a/reports-scheduler/build.gradle +++ b/reports-scheduler/build.gradle @@ -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 { @@ -67,6 +67,8 @@ allOpen { configurations { ktlint + testCompile + testRuntime } detekt { @@ -95,11 +97,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 { @@ -109,7 +111,7 @@ allprojects { version += "-SNAPSHOT" } plugins.withId('java') { - sourceCompatibility = targetCompatibility = "1.8" + sourceCompatibility = targetCompatibility = "11" } } @@ -121,22 +123,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" @@ -279,7 +283,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(){ @Override diff --git a/reports-scheduler/gradle/wrapper/gradle-wrapper.properties b/reports-scheduler/gradle/wrapper/gradle-wrapper.properties index b3538d7c..0cd8700c 100644 --- a/reports-scheduler/gradle/wrapper/gradle-wrapper.properties +++ b/reports-scheduler/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/reports-scheduler/src/main/kotlin/org/opensearch/reportsscheduler/index/ReportDefinitionsIndex.kt b/reports-scheduler/src/main/kotlin/org/opensearch/reportsscheduler/index/ReportDefinitionsIndex.kt index 6902e8b5..60fb34ce 100644 --- a/reports-scheduler/src/main/kotlin/org/opensearch/reportsscheduler/index/ReportDefinitionsIndex.kt +++ b/reports-scheduler/src/main/kotlin/org/opensearch/reportsscheduler/index/ReportDefinitionsIndex.kt @@ -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 @@ -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 @@ -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) @@ -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) } @@ -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 } diff --git a/reports-scheduler/src/main/kotlin/org/opensearch/reportsscheduler/index/ReportInstancesIndex.kt b/reports-scheduler/src/main/kotlin/org/opensearch/reportsscheduler/index/ReportInstancesIndex.kt index a0cb3c57..be7277a5 100644 --- a/reports-scheduler/src/main/kotlin/org/opensearch/reportsscheduler/index/ReportInstancesIndex.kt +++ b/reports-scheduler/src/main/kotlin/org/opensearch/reportsscheduler/index/ReportInstancesIndex.kt @@ -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) diff --git a/reports-scheduler/src/main/kotlin/org/opensearch/reportsscheduler/settings/PluginSettings.kt b/reports-scheduler/src/main/kotlin/org/opensearch/reportsscheduler/settings/PluginSettings.kt index 801da700..45e061cb 100644 --- a/reports-scheduler/src/main/kotlin/org/opensearch/reportsscheduler/settings/PluginSettings.kt +++ b/reports-scheduler/src/main/kotlin/org/opensearch/reportsscheduler/settings/PluginSettings.kt @@ -8,6 +8,7 @@ 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 @@ -15,7 +16,6 @@ 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. @@ -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) { diff --git a/reports-scheduler/src/test/java/org/opensearch/reportsscheduler/metrics/RollingCounterTest.java b/reports-scheduler/src/test/java/org/opensearch/reportsscheduler/metrics/RollingCounterTest.java index 09771032..b4ae065f 100644 --- a/reports-scheduler/src/test/java/org/opensearch/reportsscheduler/metrics/RollingCounterTest.java +++ b/reports-scheduler/src/test/java/org/opensearch/reportsscheduler/metrics/RollingCounterTest.java @@ -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; diff --git a/reports-scheduler/src/test/kotlin/org/opensearch/integTest/ReportsSchedulerPluginIT.kt b/reports-scheduler/src/test/kotlin/org/opensearch/integTest/ReportsSchedulerPluginIT.kt index b51a6250..d35b167a 100644 --- a/reports-scheduler/src/test/kotlin/org/opensearch/integTest/ReportsSchedulerPluginIT.kt +++ b/reports-scheduler/src/test/kotlin/org/opensearch/integTest/ReportsSchedulerPluginIT.kt @@ -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 @@ -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() diff --git a/reports-scheduler/src/test/resources/bwc/job-scheduler/2.0.0.0-SNAPSHOT/opensearch-job-scheduler-2.0.0.0-SNAPSHOT.zip b/reports-scheduler/src/test/resources/bwc/job-scheduler/2.0.0.0-SNAPSHOT/opensearch-job-scheduler-2.0.0.0-SNAPSHOT.zip new file mode 100644 index 00000000..fafb14e1 Binary files /dev/null and b/reports-scheduler/src/test/resources/bwc/job-scheduler/2.0.0.0-SNAPSHOT/opensearch-job-scheduler-2.0.0.0-SNAPSHOT.zip differ diff --git a/reports-scheduler/src/test/resources/job-scheduler/opensearch-job-scheduler-1.3.0.0-SNAPSHOT.zip b/reports-scheduler/src/test/resources/job-scheduler/opensearch-job-scheduler-1.3.0.0-SNAPSHOT.zip deleted file mode 100644 index 49f516a1..00000000 Binary files a/reports-scheduler/src/test/resources/job-scheduler/opensearch-job-scheduler-1.3.0.0-SNAPSHOT.zip and /dev/null differ diff --git a/reports-scheduler/src/test/resources/job-scheduler/opensearch-job-scheduler-2.0.0.0-SNAPSHOT.zip b/reports-scheduler/src/test/resources/job-scheduler/opensearch-job-scheduler-2.0.0.0-SNAPSHOT.zip new file mode 100644 index 00000000..fafb14e1 Binary files /dev/null and b/reports-scheduler/src/test/resources/job-scheduler/opensearch-job-scheduler-2.0.0.0-SNAPSHOT.zip differ