From 08cb00c820f4cd7222e9ee7a675817b67cde106e Mon Sep 17 00:00:00 2001 From: sejli Date: Thu, 29 Sep 2022 11:43:06 -0700 Subject: [PATCH 1/6] Updating Kotlin version to latest Signed-off-by: sejli --- opensearch-observability/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opensearch-observability/build.gradle b/opensearch-observability/build.gradle index e4fe60e52..a8920d9dc 100644 --- a/opensearch-observability/build.gradle +++ b/opensearch-observability/build.gradle @@ -13,7 +13,7 @@ buildscript { // 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') common_utils_version = System.getProperty("common_utils.version", opensearch_build) - kotlin_version = System.getProperty("kotlin.version", "1.4.0") + kotlin_version = System.getProperty("kotlin.version", "1.7.20") } repositories { From e0d588f34c14af1d921900d3d48227ac367f02a9 Mon Sep 17 00:00:00 2001 From: sejli Date: Thu, 29 Sep 2022 12:22:25 -0700 Subject: [PATCH 2/6] Switch to 1.6.21 since latest fails tests Signed-off-by: sejli --- opensearch-observability/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opensearch-observability/build.gradle b/opensearch-observability/build.gradle index a8920d9dc..276ac2880 100644 --- a/opensearch-observability/build.gradle +++ b/opensearch-observability/build.gradle @@ -13,7 +13,7 @@ buildscript { // 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') common_utils_version = System.getProperty("common_utils.version", opensearch_build) - kotlin_version = System.getProperty("kotlin.version", "1.7.20") + kotlin_version = System.getProperty("kotlin.version", "1.6.21") } repositories { From 112d5d8c062a447af076c6e797cb08006854d4ff Mon Sep 17 00:00:00 2001 From: sejli Date: Thu, 29 Sep 2022 16:55:51 -0700 Subject: [PATCH 3/6] Switch to 1.6.0 because of issues, fixed some errors with build Signed-off-by: sejli --- opensearch-observability/build.gradle | 2 +- .../org/opensearch/observability/PluginRestTestCase.kt | 3 ++- .../observability/bwc/TABackwardCompatibilityIT.kt | 10 +++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/opensearch-observability/build.gradle b/opensearch-observability/build.gradle index 276ac2880..50f629e55 100644 --- a/opensearch-observability/build.gradle +++ b/opensearch-observability/build.gradle @@ -13,7 +13,7 @@ buildscript { // 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') common_utils_version = System.getProperty("common_utils.version", opensearch_build) - kotlin_version = System.getProperty("kotlin.version", "1.6.21") + kotlin_version = System.getProperty("kotlin.version", "1.6.0") } repositories { diff --git a/opensearch-observability/src/test/kotlin/org/opensearch/observability/PluginRestTestCase.kt b/opensearch-observability/src/test/kotlin/org/opensearch/observability/PluginRestTestCase.kt index c80e1bddd..d2ee8ce18 100644 --- a/opensearch-observability/src/test/kotlin/org/opensearch/observability/PluginRestTestCase.kt +++ b/opensearch-observability/src/test/kotlin/org/opensearch/observability/PluginRestTestCase.kt @@ -26,6 +26,7 @@ import org.opensearch.client.Response import org.opensearch.client.ResponseException import org.opensearch.client.RestClient import org.opensearch.client.RestClientBuilder +import org.opensearch.common.io.PathUtils import org.opensearch.common.settings.Settings import org.opensearch.common.unit.TimeValue import org.opensearch.common.util.concurrent.ThreadContext @@ -263,7 +264,7 @@ abstract class PluginRestTestCase : OpenSearchRestTestCase() { false ) proxy.getExecutionData(false)?.let { - val path = Paths.get("$jacocoBuildPath/integTest.exec") + val path = PathUtils.get("$jacocoBuildPath/integTest.exec") Files.write(path, it) } } diff --git a/opensearch-observability/src/test/kotlin/org/opensearch/observability/bwc/TABackwardCompatibilityIT.kt b/opensearch-observability/src/test/kotlin/org/opensearch/observability/bwc/TABackwardCompatibilityIT.kt index cc709de4a..f23ed095f 100644 --- a/opensearch-observability/src/test/kotlin/org/opensearch/observability/bwc/TABackwardCompatibilityIT.kt +++ b/opensearch-observability/src/test/kotlin/org/opensearch/observability/bwc/TABackwardCompatibilityIT.kt @@ -13,8 +13,8 @@ import org.opensearch.observability.PluginRestTestCase import org.opensearch.observability.constructNotebookRequest import org.opensearch.rest.RestRequest import org.opensearch.rest.RestStatus -import java.util.List -import java.util.Map +// import kotlin.Collections.List +// import kotlin.Collections.Map class TABackwardCompatibilityIT : PluginRestTestCase() { @@ -61,14 +61,14 @@ class TABackwardCompatibilityIT : PluginRestTestCase() { } @Throws(Exception::class) - @SuppressWarnings("unchecked") + @SuppressWarnings("UNCHECKED_CAST") fun `test backwards compatibility`() { val uri = getUri() val responseMap = getAsMap(uri)["nodes"] as Map> - for (response in responseMap.values()) { + for (response in responseMap.values) { val plugins = response["plugins"] as List> val pluginNames = plugins.map { plugin -> plugin["name"] }.toSet() - return when (CLUSTER_TYPE) { + when (CLUSTER_TYPE) { ClusterType.OLD -> { assertTrue(pluginNames.contains("opensearch-notebooks")) createNotebook() From f69e0efe62ae9d0614452095c6d8ea2316e906e6 Mon Sep 17 00:00:00 2001 From: Joshua Li Date: Fri, 30 Sep 2022 17:29:30 +0000 Subject: [PATCH 4/6] Fix jacoco Signed-off-by: Joshua Li --- opensearch-observability/build.gradle | 3 ++- .../org/opensearch/observability/settings/PluginSettings.kt | 4 ++-- .../kotlin/org/opensearch/observability/PluginRestTestCase.kt | 1 - 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/opensearch-observability/build.gradle b/opensearch-observability/build.gradle index 50f629e55..b70b2f950 100644 --- a/opensearch-observability/build.gradle +++ b/opensearch-observability/build.gradle @@ -28,7 +28,7 @@ buildscript { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}" classpath "org.jetbrains.kotlin:kotlin-allopen:${kotlin_version}" classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.12.0" - classpath "org.jacoco:org.jacoco.agent:0.8.5" + classpath "org.jacoco:org.jacoco.agent:0.8.7" } } @@ -117,6 +117,7 @@ allprojects { plugins.withId('java') { sourceCompatibility = targetCompatibility = "1.8" } + jacoco.toolVersion = "0.8.7" } dependencies { diff --git a/opensearch-observability/src/main/kotlin/org/opensearch/observability/settings/PluginSettings.kt b/opensearch-observability/src/main/kotlin/org/opensearch/observability/settings/PluginSettings.kt index 0f5d31504..ae1eead9b 100644 --- a/opensearch-observability/src/main/kotlin/org/opensearch/observability/settings/PluginSettings.kt +++ b/opensearch-observability/src/main/kotlin/org/opensearch/observability/settings/PluginSettings.kt @@ -8,6 +8,7 @@ package org.opensearch.observability.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.observability.ObservabilityPlugin.Companion.LOG_PREFIX import org.opensearch.observability.ObservabilityPlugin.Companion.PLUGIN_NAME import java.io.IOException -import java.nio.file.Paths /** * settings specific to observability Plugin. @@ -246,7 +246,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, "observability.yml") + val defaultSettingYmlFile = PathUtils.get(configDirName, PLUGIN_NAME, "observability.yml") try { settings = Settings.builder().loadFromPath(defaultSettingYmlFile).build() } catch (exception: IOException) { diff --git a/opensearch-observability/src/test/kotlin/org/opensearch/observability/PluginRestTestCase.kt b/opensearch-observability/src/test/kotlin/org/opensearch/observability/PluginRestTestCase.kt index d2ee8ce18..c19166a27 100644 --- a/opensearch-observability/src/test/kotlin/org/opensearch/observability/PluginRestTestCase.kt +++ b/opensearch-observability/src/test/kotlin/org/opensearch/observability/PluginRestTestCase.kt @@ -39,7 +39,6 @@ import java.io.IOException import java.io.InputStreamReader import java.nio.charset.StandardCharsets import java.nio.file.Files -import java.nio.file.Paths import java.security.cert.X509Certificate import javax.management.MBeanServerInvocationHandler import javax.management.ObjectName From d96e31cc2a8152bf239916e5eaa26628280d086a Mon Sep 17 00:00:00 2001 From: sejli Date: Fri, 30 Sep 2022 11:55:43 -0700 Subject: [PATCH 5/6] Minor changes Signed-off-by: sejli --- opensearch-observability/build.gradle | 3 ++- .../org/opensearch/observability/settings/PluginSettings.kt | 4 ++-- .../kotlin/org/opensearch/observability/PluginRestTestCase.kt | 4 +--- .../opensearch/observability/bwc/TABackwardCompatibilityIT.kt | 2 -- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/opensearch-observability/build.gradle b/opensearch-observability/build.gradle index 50f629e55..b70b2f950 100644 --- a/opensearch-observability/build.gradle +++ b/opensearch-observability/build.gradle @@ -28,7 +28,7 @@ buildscript { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}" classpath "org.jetbrains.kotlin:kotlin-allopen:${kotlin_version}" classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.12.0" - classpath "org.jacoco:org.jacoco.agent:0.8.5" + classpath "org.jacoco:org.jacoco.agent:0.8.7" } } @@ -117,6 +117,7 @@ allprojects { plugins.withId('java') { sourceCompatibility = targetCompatibility = "1.8" } + jacoco.toolVersion = "0.8.7" } dependencies { diff --git a/opensearch-observability/src/main/kotlin/org/opensearch/observability/settings/PluginSettings.kt b/opensearch-observability/src/main/kotlin/org/opensearch/observability/settings/PluginSettings.kt index 0f5d31504..ae1eead9b 100644 --- a/opensearch-observability/src/main/kotlin/org/opensearch/observability/settings/PluginSettings.kt +++ b/opensearch-observability/src/main/kotlin/org/opensearch/observability/settings/PluginSettings.kt @@ -8,6 +8,7 @@ package org.opensearch.observability.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.observability.ObservabilityPlugin.Companion.LOG_PREFIX import org.opensearch.observability.ObservabilityPlugin.Companion.PLUGIN_NAME import java.io.IOException -import java.nio.file.Paths /** * settings specific to observability Plugin. @@ -246,7 +246,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, "observability.yml") + val defaultSettingYmlFile = PathUtils.get(configDirName, PLUGIN_NAME, "observability.yml") try { settings = Settings.builder().loadFromPath(defaultSettingYmlFile).build() } catch (exception: IOException) { diff --git a/opensearch-observability/src/test/kotlin/org/opensearch/observability/PluginRestTestCase.kt b/opensearch-observability/src/test/kotlin/org/opensearch/observability/PluginRestTestCase.kt index d2ee8ce18..a0b686187 100644 --- a/opensearch-observability/src/test/kotlin/org/opensearch/observability/PluginRestTestCase.kt +++ b/opensearch-observability/src/test/kotlin/org/opensearch/observability/PluginRestTestCase.kt @@ -26,7 +26,6 @@ import org.opensearch.client.Response import org.opensearch.client.ResponseException import org.opensearch.client.RestClient import org.opensearch.client.RestClientBuilder -import org.opensearch.common.io.PathUtils import org.opensearch.common.settings.Settings import org.opensearch.common.unit.TimeValue import org.opensearch.common.util.concurrent.ThreadContext @@ -39,7 +38,6 @@ import java.io.IOException import java.io.InputStreamReader import java.nio.charset.StandardCharsets import java.nio.file.Files -import java.nio.file.Paths import java.security.cert.X509Certificate import javax.management.MBeanServerInvocationHandler import javax.management.ObjectName @@ -264,7 +262,7 @@ abstract class PluginRestTestCase : OpenSearchRestTestCase() { false ) proxy.getExecutionData(false)?.let { - val path = PathUtils.get("$jacocoBuildPath/integTest.exec") + val path = Paths.get("$jacocoBuildPath/integTest.exec") Files.write(path, it) } } diff --git a/opensearch-observability/src/test/kotlin/org/opensearch/observability/bwc/TABackwardCompatibilityIT.kt b/opensearch-observability/src/test/kotlin/org/opensearch/observability/bwc/TABackwardCompatibilityIT.kt index f23ed095f..6fe5fcf12 100644 --- a/opensearch-observability/src/test/kotlin/org/opensearch/observability/bwc/TABackwardCompatibilityIT.kt +++ b/opensearch-observability/src/test/kotlin/org/opensearch/observability/bwc/TABackwardCompatibilityIT.kt @@ -13,8 +13,6 @@ import org.opensearch.observability.PluginRestTestCase import org.opensearch.observability.constructNotebookRequest import org.opensearch.rest.RestRequest import org.opensearch.rest.RestStatus -// import kotlin.Collections.List -// import kotlin.Collections.Map class TABackwardCompatibilityIT : PluginRestTestCase() { From fdd5e40dd56b31bce54d8309411e86d2efbc03bf Mon Sep 17 00:00:00 2001 From: sejli Date: Fri, 30 Sep 2022 12:13:08 -0700 Subject: [PATCH 6/6] Fixing PathUtils import Signed-off-by: sejli --- .../kotlin/org/opensearch/observability/PluginRestTestCase.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/opensearch-observability/src/test/kotlin/org/opensearch/observability/PluginRestTestCase.kt b/opensearch-observability/src/test/kotlin/org/opensearch/observability/PluginRestTestCase.kt index a0b686187..c19166a27 100644 --- a/opensearch-observability/src/test/kotlin/org/opensearch/observability/PluginRestTestCase.kt +++ b/opensearch-observability/src/test/kotlin/org/opensearch/observability/PluginRestTestCase.kt @@ -26,6 +26,7 @@ import org.opensearch.client.Response import org.opensearch.client.ResponseException import org.opensearch.client.RestClient import org.opensearch.client.RestClientBuilder +import org.opensearch.common.io.PathUtils import org.opensearch.common.settings.Settings import org.opensearch.common.unit.TimeValue import org.opensearch.common.util.concurrent.ThreadContext @@ -262,7 +263,7 @@ abstract class PluginRestTestCase : OpenSearchRestTestCase() { false ) proxy.getExecutionData(false)?.let { - val path = Paths.get("$jacocoBuildPath/integTest.exec") + val path = PathUtils.get("$jacocoBuildPath/integTest.exec") Files.write(path, it) } }