Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump to 2.0 alpha1 and gradle 7 #325

Merged
merged 17 commits into from
Apr 4, 2022
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ name: Test and Build Reports Scheduler
on: [push, pull_request]

env:
OPENSEARCH_VERSION: '1.3.0-SNAPSHOT'
OPENSEARCH_VERSION: '2.0.0-alpha1-SNAPSHOT'

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

steps:
Expand All @@ -35,7 +35,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
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))/, '$1.0')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opensearch_build = opensearch_version.replaceAll(/([\d.]*.\d+(?!.\d))/, '$1.0')
Please replace this to handle multiple digits.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was common-utils 2.0.0 alpha1 deprecated? backend build is failing immediately because it can't resolve the reference

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 @@ -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 {
Expand All @@ -109,7 +111,7 @@ allprojects {
version += "-SNAPSHOT"
}
plugins.withId('java') {
sourceCompatibility = targetCompatibility = "1.8"
sourceCompatibility = targetCompatibility = "11"
}
}

Expand All @@ -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"
Expand Down Expand Up @@ -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<RegularFile>(){
@Override
Expand Down
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.