diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index f5f565fcc8fe5..c18b01261f31f 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -133,6 +133,14 @@ dependencies { integTestImplementation('org.spockframework:spock-core:2.4-M6-groovy-4.0') { exclude module: "groovy" } + // Integration with JUnit 4 features for Spock 2+ (which internally uses JUnit Platform - + // part of JUnit 5) - https://spockframework.org/spock/docs/2.4-M6/modules.html + integTestImplementation('org.spockframework:spock-junit4:2.4-M6-groovy-4.0') { + exclude module: "groovy" + } + integTestImplementation(platform("org.junit:junit-bom:${props.getProperty('junit5')}")) + integTestRuntimeOnly("org.junit.platform:junit-platform-launcher") + integTestRuntimeOnly("org.junit.vintage:junit-vintage-engine") } configurations.all { @@ -253,6 +261,7 @@ if (project != rootProject) { } tasks.register("integTest", Test) { + useJUnitPlatform() inputs.dir(file("src/testKit")).withPropertyName("testkit dir").withPathSensitivity(PathSensitivity.RELATIVE) systemProperty 'test.version_under_test', version onlyIf { org.opensearch.gradle.info.BuildParams.inFipsJvm == false } diff --git a/buildSrc/src/integTest/groovy/org/opensearch/gradle/DistributionDownloadPluginFuncTest.groovy b/buildSrc/src/integTest/groovy/org/opensearch/gradle/DistributionDownloadPluginFuncTest.groovy index d49c85f0f0e17..634cd208a1df2 100644 --- a/buildSrc/src/integTest/groovy/org/opensearch/gradle/DistributionDownloadPluginFuncTest.groovy +++ b/buildSrc/src/integTest/groovy/org/opensearch/gradle/DistributionDownloadPluginFuncTest.groovy @@ -56,8 +56,8 @@ class DistributionDownloadPluginFuncTest extends AbstractGradleFuncTest { where: version | platform | distType VersionProperties.getOpenSearch() | OpenSearchDistribution.Platform.LINUX | "current" - "8.1.0-SNAPSHOT" | OpenSearchDistribution.Platform.LINUX | "bwc" - "7.0.0" | OpenSearchDistribution.Platform.WINDOWS | "released" + "2.19.0-SNAPSHOT" | OpenSearchDistribution.Platform.LINUX | "bwc" + "3.3.0" | OpenSearchDistribution.Platform.WINDOWS | "released" } @@ -72,7 +72,8 @@ class DistributionDownloadPluginFuncTest extends AbstractGradleFuncTest { """ when: - def runner = gradleRunner('clean', 'setupDistro', '-i') + def customGradleUserHome = testProjectDir.newFolder().absolutePath; + def runner = gradleRunner('clean', 'setupDistro', '-i', '-g', customGradleUserHome) def result = withMockedDistributionDownload(version, platform, runner) { // initial run build() @@ -82,7 +83,8 @@ class DistributionDownloadPluginFuncTest extends AbstractGradleFuncTest { then: result.task(":setupDistro").outcome == TaskOutcome.SUCCESS - assertOutputContains(result.output, "Skipping ${SymbolicLinkPreservingUntarTransform.class.simpleName}") + result.output.count("Unpacking opensearch-${version}-linux-x64.tar.gz " + + "using SymbolicLinkPreservingUntarTransform.") == 0 } def "transforms are reused across projects"() { @@ -91,6 +93,7 @@ class DistributionDownloadPluginFuncTest extends AbstractGradleFuncTest { def platform = OpenSearchDistribution.Platform.LINUX 3.times { + testProjectDir.newFolder("sub-$it") settingsFile << """ include ':sub-$it' """ diff --git a/buildSrc/src/integTest/groovy/org/opensearch/gradle/JdkDownloadPluginFuncTest.groovy b/buildSrc/src/integTest/groovy/org/opensearch/gradle/JdkDownloadPluginFuncTest.groovy index 160e7805b3648..c070dbf7cd535 100644 --- a/buildSrc/src/integTest/groovy/org/opensearch/gradle/JdkDownloadPluginFuncTest.groovy +++ b/buildSrc/src/integTest/groovy/org/opensearch/gradle/JdkDownloadPluginFuncTest.groovy @@ -108,6 +108,7 @@ class JdkDownloadPluginFuncTest extends AbstractGradleFuncTest { def mockRepoUrl = urlPath(jdkVendor, jdkVersion, platform) def mockedContent = filebytes(jdkVendor, platform) 3.times { + testProjectDir.newFolder("sub-$it") settingsFile << """ include ':sub-$it' """ @@ -193,7 +194,7 @@ class JdkDownloadPluginFuncTest extends AbstractGradleFuncTest { } then: - assertOutputContains(result.output, "Skipping $transformType") + result.output.count("Unpacking ${platform}-12.0.2-x64.tar.gz using ${transformType}.") == 0 where: platform | transformType @@ -246,6 +247,7 @@ class JdkDownloadPluginFuncTest extends AbstractGradleFuncTest { p.repositories.all { repo -> if(repo.name == "jdk_repo_${jdkVendor}_${jdkVersion}") { repo.setUrl('${server.baseUrl()}') + repo.setAllowInsecureProtocol(true) } } }""" diff --git a/buildSrc/src/integTest/groovy/org/opensearch/gradle/internal/InternalDistributionArchiveSetupPluginFuncTest.groovy b/buildSrc/src/integTest/groovy/org/opensearch/gradle/internal/InternalDistributionArchiveSetupPluginFuncTest.groovy index fa36bd36ed031..9d853cebfc4d1 100644 --- a/buildSrc/src/integTest/groovy/org/opensearch/gradle/internal/InternalDistributionArchiveSetupPluginFuncTest.groovy +++ b/buildSrc/src/integTest/groovy/org/opensearch/gradle/internal/InternalDistributionArchiveSetupPluginFuncTest.groovy @@ -98,6 +98,9 @@ class InternalDistributionArchiveSetupPluginFuncTest extends AbstractGradleFuncT given: file('someFile.txt') << "some content" + testProjectDir.newFolder("consumer") + testProjectDir.newFolder("producer-tar") + settingsFile << """ include ':consumer' include ':producer-tar' diff --git a/buildSrc/src/integTest/groovy/org/opensearch/gradle/internal/InternalDistributionDownloadPluginFuncTest.groovy b/buildSrc/src/integTest/groovy/org/opensearch/gradle/internal/InternalDistributionDownloadPluginFuncTest.groovy index 46143687b83a7..70c3df59f84f8 100644 --- a/buildSrc/src/integTest/groovy/org/opensearch/gradle/internal/InternalDistributionDownloadPluginFuncTest.groovy +++ b/buildSrc/src/integTest/groovy/org/opensearch/gradle/internal/InternalDistributionDownloadPluginFuncTest.groovy @@ -122,6 +122,8 @@ class InternalDistributionDownloadPluginFuncTest extends AbstractGradleFuncTest internalBuild() bwcMinorProjectSetup() buildFile << """ + import org.opensearch.gradle.JavaPackageType + apply plugin: 'opensearch.internal-distribution-download' opensearch_distributions { @@ -130,7 +132,7 @@ class InternalDistributionDownloadPluginFuncTest extends AbstractGradleFuncTest type = "archive" platform = "linux" architecture = Architecture.current(); - bundledJdk = false + bundledJdk = JavaPackageType.NONE } } tasks.register("createExtractedTestDistro") { diff --git a/buildSrc/src/integTest/resources/org/opensearch/gradle/internal/fake_git/remote/distribution/archives/build.gradle b/buildSrc/src/integTest/resources/org/opensearch/gradle/internal/fake_git/remote/distribution/archives/build.gradle index fbd5936061779..355b26ecced8c 100644 --- a/buildSrc/src/integTest/resources/org/opensearch/gradle/internal/fake_git/remote/distribution/archives/build.gradle +++ b/buildSrc/src/integTest/resources/org/opensearch/gradle/internal/fake_git/remote/distribution/archives/build.gradle @@ -32,7 +32,7 @@ subprojects { apply plugin:'base' tasks.register('tar', Tar) { - from('.') + from('build.gradle') destinationDirectory.set(file('build/distributions')) archiveBaseName.set("opensearch") archiveVersion.set("8.0.1-SNAPSHOT") diff --git a/buildSrc/src/testKit/testingConventions/build.gradle b/buildSrc/src/testKit/testingConventions/build.gradle index 676960bcc8b70..afd3f06a4ed68 100644 --- a/buildSrc/src/testKit/testingConventions/build.gradle +++ b/buildSrc/src/testKit/testingConventions/build.gradle @@ -21,7 +21,7 @@ allprojects { mavenCentral() } dependencies { - testImplementation "junit:junit:4.13.2" + testImplementation "junit:junit:${versions.junit}" } ext.licenseFile = file("$buildDir/dummy/license") diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e5caa7cb23666..98bdccdc47a62 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -74,6 +74,7 @@ password4j = "1.8.3" # test dependencies randomizedrunner = "2.7.1" junit = "4.13.2" +junit5 = "6.0.0" hamcrest = "2.1" mockito = "5.16.1" objenesis = "3.3" diff --git a/plugins/identity-shiro/build.gradle b/plugins/identity-shiro/build.gradle index 6479e1300be15..581cf89023883 100644 --- a/plugins/identity-shiro/build.gradle +++ b/plugins/identity-shiro/build.gradle @@ -33,7 +33,7 @@ dependencies { testImplementation project(path: ':modules:transport-netty4') // for http testImplementation "org.mockito:mockito-core:${versions.mockito}" testImplementation project(path: ':client:rest-high-level') - testImplementation 'junit:junit:4.13.2' + testImplementation "junit:junit:${versions.junit}" } /*