From 464fdb281fafe28d8b439037fb386137a539a63f Mon Sep 17 00:00:00 2001 From: Hailong Cui Date: Thu, 30 Mar 2023 14:34:13 +0800 Subject: [PATCH] upgrade mockito and byte-buddy version to align with opensearch core and Fix BWC test case failure (#644) * upgrade mockito and byte-buddy version to align with opensearch core Signed-off-by: Hailong Cui * upgrade BWC version to 2.7.0 to fix BWC testcase Signed-off-by: Hailong Cui * Enable logs for security run with docker Signed-off-by: Hailong Cui * Remove unused lines Signed-off-by: Hailong Cui --------- Signed-off-by: Hailong Cui --- .../security-notifications-test-workflow.yml | 4 +- notifications/core-spi/build.gradle | 2 +- notifications/core/build.gradle | 2 +- notifications/notifications/build.gradle | 88 ++++++++----------- 4 files changed, 43 insertions(+), 53 deletions(-) diff --git a/.github/workflows/security-notifications-test-workflow.yml b/.github/workflows/security-notifications-test-workflow.yml index b54a86ce..0d77cf7a 100644 --- a/.github/workflows/security-notifications-test-workflow.yml +++ b/.github/workflows/security-notifications-test-workflow.yml @@ -73,9 +73,9 @@ jobs: if: env.imagePresent == 'true' run: | cd .. - docker run -p 9200:9200 -d -p 9600:9600 -e "discovery.type=single-node" opensearch-notifications:test + container_id=`docker run -p 9200:9200 -d -p 9600:9600 -e "discovery.type=single-node" opensearch-notifications:test` sleep 120 - + echo `docker logs $container_id` - name: Run Notification Test for security enabled test cases if: env.imagePresent == 'true' run: | diff --git a/notifications/core-spi/build.gradle b/notifications/core-spi/build.gradle index 842f9a3a..1e42a59d 100644 --- a/notifications/core-spi/build.gradle +++ b/notifications/core-spi/build.gradle @@ -68,7 +68,7 @@ dependencies { testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.6.2') testImplementation "org.jetbrains.kotlin:kotlin-test:${kotlin_version}" testImplementation "org.jetbrains.kotlin:kotlin-reflect:${kotlin_version}" // required by mockk - testImplementation "net.bytebuddy:byte-buddy-agent:1.12.7" + testImplementation "net.bytebuddy:byte-buddy-agent:${versions.bytebuddy}" testImplementation "org.opensearch.test:framework:${opensearch_version}" } diff --git a/notifications/core/build.gradle b/notifications/core/build.gradle index 0d0557ad..238bba98 100644 --- a/notifications/core/build.gradle +++ b/notifications/core/build.gradle @@ -167,7 +167,7 @@ dependencies { testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.6.2') testImplementation "org.jetbrains.kotlin:kotlin-test:${kotlin_version}" testImplementation "net.bytebuddy:byte-buddy-agent:1.12.7" - testImplementation "org.mockito:mockito-core:5.1.0" + testImplementation "org.mockito:mockito-core:${versions.mockito}" testImplementation "org.opensearch.test:framework:${opensearch_version}" testImplementation "org.jetbrains.kotlin:kotlin-reflect:${kotlin_version}" // required by mockk implementation project(path: ":${rootProject.name}-core-spi", configuration: 'shadow') diff --git a/notifications/notifications/build.gradle b/notifications/notifications/build.gradle index 9bd66464..de3a4d4d 100644 --- a/notifications/notifications/build.gradle +++ b/notifications/notifications/build.gradle @@ -126,8 +126,8 @@ dependencies { testImplementation "org.opensearch.test:framework:${opensearch_version}" testImplementation "org.jetbrains.kotlin:kotlin-test:${kotlin_version}" testImplementation "org.jetbrains.kotlin:kotlin-reflect:${kotlin_version}" // required by mockk - testImplementation "net.bytebuddy:byte-buddy-agent:1.12.7" - testImplementation "org.mockito:mockito-core:5.1.0" + testImplementation "net.bytebuddy:byte-buddy-agent:${versions.bytebuddy}" + testImplementation "org.mockito:mockito-core:${versions.mockito}" testImplementation 'com.google.code.gson:gson:2.8.9' testImplementation 'org.springframework.integration:spring-integration-mail:5.5.0' testImplementation 'org.springframework.integration:spring-integration-test-support:5.5.0' @@ -259,61 +259,51 @@ testClusters.integTest { setting 'path.repo', repo.absolutePath } -String bwcVersion = "2.5.0.0" +// Always be minimumCompatibilityVersion of current opensearch version(3.0.0) +def bwcVersionShort = "2.7.0" +def bwcVersion = bwcVersionShort + ".0" +def bwcOpenSearchVesion= bwcVersionShort + "-SNAPSHOT" +def bwcPluginVersion = bwcVersion + "-SNAPSHOT" String baseName = "notificationsBwcCluster" -String bwcPluginsResourcePath = "src/test/resources/plugins/bwc" -String bwcNotificationsCoreFilePath = "$bwcPluginsResourcePath/notifications-core/$bwcVersion" -String bwcNotificationsFilePath = "$bwcPluginsResourcePath/notifications/$bwcVersion" -String bwcNotificationsCoreDownload = "https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/" + - "2.5.0/latest/linux/x64/tar/builds/opensearch/plugins/opensearch-notifications-core-" + - bwcVersion + ".zip" -String bwcNotificationsDownload = "https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/" + - "2.5.0/latest/linux/x64/tar/builds/opensearch/plugins/opensearch-notifications-" + - bwcVersion + ".zip" +configurations { + opensearchPlugin +} + +dependencies { + opensearchPlugin "org.opensearch.plugin:opensearch-notifications-core:${bwcPluginVersion}@zip" + opensearchPlugin "org.opensearch.plugin:notifications:${bwcPluginVersion}@zip" +} + +ext.resolvePluginFile = { pluginId -> + return new Callable() { + @Override + RegularFile call() throws Exception { + return new RegularFile() { + @Override + File getAsFile() { + return configurations.opensearchPlugin.resolvedConfiguration.resolvedArtifacts + .find { ResolvedArtifact f -> + f.name.startsWith(pluginId) + } + .file + } + } + } + } +} + +def notificationsCoreFile = resolvePluginFile("opensearch-notifications-core") +def notificationsFile = resolvePluginFile("notifications") 2.times { i -> testClusters { "${baseName}$i" { testDistribution = "INTEG_TEST" - versions = ["2.5.0-SNAPSHOT", opensearch_version] + versions = [bwcOpenSearchVesion, opensearch_version] numberOfNodes = 3 - plugin(provider(new Callable(){ - @Override - RegularFile call() throws Exception { - return new RegularFile() { - @Override - File getAsFile() { - if (new File("$project.rootDir/$bwcNotificationsCoreFilePath").exists()) { - project.delete(files("$project.rootDir/$bwcNotificationsCoreFilePath")) - } - project.mkdir bwcNotificationsCoreFilePath - ant.get(src: bwcNotificationsCoreDownload, - dest: bwcNotificationsCoreFilePath, - httpusecaches: false) - return fileTree(bwcNotificationsCoreFilePath).getSingleFile() - } - } - } - })) - plugin(provider(new Callable(){ - @Override - RegularFile call() throws Exception { - return new RegularFile() { - @Override - File getAsFile() { - if (new File("$project.rootDir/$bwcNotificationsFilePath").exists()) { - project.delete(files("$project.rootDir/$bwcNotificationsFilePath")) - } - project.mkdir bwcNotificationsFilePath - ant.get(src: bwcNotificationsDownload, - dest: bwcNotificationsFilePath, - httpusecaches: false) - return fileTree(bwcNotificationsFilePath).getSingleFile() - } - } - } - })) + plugin(provider(notificationsCoreFile)) + plugin(provider(notificationsFile)) setting 'path.repo', "${buildDir}/cluster/shared/repo/${baseName}" setting 'http.content_type.required', 'true' }