Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-vieira committed Dec 4, 2024
1 parent 5470364 commit 6a8f361
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@

package org.elasticsearch.gradle.internal

import spock.lang.Unroll

import org.elasticsearch.gradle.fixtures.AbstractGitAwareGradleFuncTest
import org.gradle.testkit.runner.TaskOutcome
import spock.lang.Unroll

class InternalDistributionBwcSetupPluginFuncTest extends AbstractGitAwareGradleFuncTest {

Expand All @@ -23,8 +24,10 @@ class InternalDistributionBwcSetupPluginFuncTest extends AbstractGitAwareGradleF
apply plugin: 'elasticsearch.internal-distribution-bwc-setup'
"""
execute("git branch origin/8.x", file("cloned"))
execute("git branch origin/8.3", file("cloned"))
execute("git branch origin/8.2", file("cloned"))
execute("git branch origin/8.1", file("cloned"))
execute("git branch origin/7.16", file("cloned"))
execute("git branch origin/7.15", file("cloned"))
}

def "builds distribution from branches via archives extractedAssemble"() {
Expand All @@ -48,10 +51,11 @@ class InternalDistributionBwcSetupPluginFuncTest extends AbstractGitAwareGradleF
assertOutputContains(result.output, "[$bwcDistVersion] > Task :distribution:archives:darwin-tar:${expectedAssembleTaskName}")

where:
bwcDistVersion | bwcProject | expectedAssembleTaskName
"8.0.0" | "minor" | "extractedAssemble"
"7.16.0" | "staged" | "extractedAssemble"
"7.15.2" | "bugfix" | "extractedAssemble"
bwcDistVersion | bwcProject | expectedAssembleTaskName
"8.4.0" | "minor" | "extractedAssemble"
"8.3.0" | "staged" | "extractedAssemble"
"8.2.1" | "bugfix" | "extractedAssemble"
"8.1.3" | "bugfix2" | "extractedAssemble"
}

@Unroll
Expand All @@ -70,8 +74,8 @@ class InternalDistributionBwcSetupPluginFuncTest extends AbstractGitAwareGradleF

where:
bwcDistVersion | platform
"8.0.0" | "darwin"
"8.0.0" | "linux"
"8.4.0" | "darwin"
"8.4.0" | "linux"
}

def "bwc expanded distribution folder can be resolved as bwc project artifact"() {
Expand Down Expand Up @@ -107,11 +111,11 @@ class InternalDistributionBwcSetupPluginFuncTest extends AbstractGitAwareGradleF
result.task(":resolveExpandedDistribution").outcome == TaskOutcome.SUCCESS
result.task(":distribution:bwc:minor:buildBwcDarwinTar").outcome == TaskOutcome.SUCCESS
and: "assemble task triggered"
result.output.contains("[8.0.0] > Task :distribution:archives:darwin-tar:extractedAssemble")
result.output.contains("[8.4.0] > Task :distribution:archives:darwin-tar:extractedAssemble")
result.output.contains("expandedRootPath /distribution/bwc/minor/build/bwc/checkout-8.x/" +
"distribution/archives/darwin-tar/build/install")
result.output.contains("nested folder /distribution/bwc/minor/build/bwc/checkout-8.x/" +
"distribution/archives/darwin-tar/build/install/elasticsearch-8.0.0-SNAPSHOT")
"distribution/archives/darwin-tar/build/install/elasticsearch-8.4.0-SNAPSHOT")
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class InternalDistributionDownloadPluginFuncTest extends AbstractGradleFuncTest
elasticsearch_distributions {
test_distro {
version = "8.0.0"
version = "8.4.0"
type = "archive"
platform = "linux"
architecture = Architecture.current();
Expand Down Expand Up @@ -87,7 +87,7 @@ class InternalDistributionDownloadPluginFuncTest extends AbstractGradleFuncTest
elasticsearch_distributions {
test_distro {
version = "8.0.0"
version = "8.4.0"
type = "archive"
platform = "linux"
architecture = Architecture.current();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class LegacyYamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTe
given:
internalBuild()

subProject(":distribution:bwc:staged") << """
subProject(":distribution:bwc:minor") << """
configurations { checkout }
artifacts {
checkout(new File(projectDir, "checkoutDir"))
Expand All @@ -61,11 +61,11 @@ class LegacyYamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTe
result.task(transformTask).outcome == TaskOutcome.NO_SOURCE
}

def "yamlRestCompatTest executes and copies api and transforms tests from :bwc:staged"() {
def "yamlRestCompatTest executes and copies api and transforms tests from :bwc:minor"() {
given:
internalBuild()

subProject(":distribution:bwc:staged") << """
subProject(":distribution:bwc:minor") << """
configurations { checkout }
artifacts {
checkout(new File(projectDir, "checkoutDir"))
Expand Down Expand Up @@ -98,8 +98,8 @@ class LegacyYamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTe
String api = "foo.json"
String test = "10_basic.yml"
//add the compatible test and api files, these are the prior version's normal yaml rest tests
file("distribution/bwc/staged/checkoutDir/rest-api-spec/src/main/resources/rest-api-spec/api/" + api) << ""
file("distribution/bwc/staged/checkoutDir/src/yamlRestTest/resources/rest-api-spec/test/" + test) << ""
file("distribution/bwc/minor/checkoutDir/rest-api-spec/src/main/resources/rest-api-spec/api/" + api) << ""
file("distribution/bwc/minor/checkoutDir/src/yamlRestTest/resources/rest-api-spec/test/" + test) << ""

when:
def result = gradleRunner("yamlRestCompatTest").build()
Expand Down Expand Up @@ -145,7 +145,7 @@ class LegacyYamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTe
given:
internalBuild()
withVersionCatalogue()
subProject(":distribution:bwc:staged") << """
subProject(":distribution:bwc:minor") << """
configurations { checkout }
artifacts {
checkout(new File(projectDir, "checkoutDir"))
Expand Down Expand Up @@ -186,7 +186,7 @@ class LegacyYamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTe
given:
internalBuild()

subProject(":distribution:bwc:staged") << """
subProject(":distribution:bwc:minor") << """
configurations { checkout }
artifacts {
checkout(new File(projectDir, "checkoutDir"))
Expand Down Expand Up @@ -230,7 +230,7 @@ class LegacyYamlRestCompatTestPluginFuncTest extends AbstractRestResourcesFuncTe

setupRestResources([], [])

file("distribution/bwc/staged/checkoutDir/src/yamlRestTest/resources/rest-api-spec/test/test.yml" ) << """
file("distribution/bwc/minor/checkoutDir/src/yamlRestTest/resources/rest-api-spec/test/test.yml" ) << """
"one":
- do:
do_.some.key_to_replace:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
rootProject.name = "root"

include ":distribution:bwc:bugfix"
include ":distribution:bwc:bugfix2"
include ":distribution:bwc:minor"
include ":distribution:bwc:major"
include ":distribution:bwc:staged"
include ":distribution:bwc:maintenance"
include ":distribution:archives:darwin-tar"
include ":distribution:archives:oss-darwin-tar"
include ":distribution:archives:darwin-aarch64-tar"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ abstract class AbstractGradleFuncTest extends Specification {

File internalBuild(
List<String> extraPlugins = [],
String bugfix = "7.15.2",
String bugfixLucene = "8.9.0",
String staged = "7.16.0",
String stagedLucene = "8.10.0",
String minor = "8.0.0",
String minorLucene = "9.0.0"
String maintenance = "7.16.10",
String bugfix2 = "8.1.3",
String bugfix = "8.2.1",
String staged = "8.3.0",
String minor = "8.4.0",
String current = "9.0.0"
) {
buildFile << """plugins {
id 'elasticsearch.global-build-info'
Expand All @@ -172,15 +172,17 @@ abstract class AbstractGradleFuncTest extends Specification {
import org.elasticsearch.gradle.internal.BwcVersions
import org.elasticsearch.gradle.Version
Version currentVersion = Version.fromString("8.1.0")
Version currentVersion = Version.fromString("${current}")
def versionList = [
Version.fromString("$maintenance"),
Version.fromString("$bugfix2"),
Version.fromString("$bugfix"),
Version.fromString("$staged"),
Version.fromString("$minor"),
currentVersion
]
BwcVersions versions = new BwcVersions(currentVersion, versionList)
BwcVersions versions = new BwcVersions(currentVersion, versionList, ['main', '8.x', '8.3', '8.2', '8.1', '7.16'])
buildParams.getBwcVersionsProperty().set(versions)
"""
}
Expand Down

0 comments on commit 6a8f361

Please sign in to comment.