Skip to content

Commit 2e60a3b

Browse files
committed
iter
1 parent 975a87e commit 2e60a3b

File tree

1 file changed

+34
-18
lines changed

1 file changed

+34
-18
lines changed

build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/transport/TransportVersionGenerationFuncTest.groovy

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,15 @@ class TransportVersionGenerationFuncTest extends AbstractTransportVersionFuncTes
9090
String name
9191
) {
9292
given:
93-
def originalLatestFiles = latestFilesModified.stream().map { readLatestFile(it) }.toList()
93+
List<LatestFile> originalModifiedLatestFiles = readLatestFiles(latestFilesModified)
94+
List<LatestFile> originalBranchesLatestFiles = readLatestFiles(branchesParam)
9495

95-
when: "generation should revert the latest files to their original state"
96-
originalLatestFiles.forEach {
96+
when: "We modify the latest files"
97+
originalModifiedLatestFiles.forEach {
9798
latestTransportVersion(it.branch, it.name + "_modification", (it.id + 1).toString())
9899
}
100+
101+
and: "We run the generation task"
99102
def args = [
100103
":myserver:validateTransportVersionDefinitions",
101104
":myserver:generateTransportVersionDefinition"
@@ -104,26 +107,39 @@ class TransportVersionGenerationFuncTest extends AbstractTransportVersionFuncTes
104107
args.add("--branches=" + branchesParam.join(","))
105108
}
106109
if (name != null) {
107-
referencedTransportVersion(name)
110+
referencedTransportVersion(name) // Ensure the definition file is referenced to allow validation to succeed
108111
}
109112
def result = gradleRunner(args.toArray(new String[0])).build()
110113

111-
then: "The generation and validation tasks should succeed, and the latest files should be reverted"
114+
then: "The generation and validation tasks should succeed"
112115
result.task(":myserver:generateTransportVersionDefinition").outcome == TaskOutcome.SUCCESS
113116
result.task(":myserver:validateTransportVersionDefinitions").outcome == TaskOutcome.SUCCESS
114-
originalLatestFiles.forEach { originalLatest ->
115-
def latest = readLatestFile(originalLatest.branch)
116-
assert latest.branch == originalLatest.branch
117-
assert latest.id == originalLatest.id
117+
118+
and: "The modified latest files should be reverted if there is no name specified or they are not specified in the branches param"
119+
originalModifiedLatestFiles.forEach { originalLatest ->
120+
boolean noNameSpecified = name == null
121+
boolean modifiedNotInBranchesParam = branchesParam != null && branchesParam.contains(originalLatest.branch) == false
122+
if (noNameSpecified || modifiedNotInBranchesParam) {
123+
def latest = readLatestFile(originalLatest.branch)
124+
assert latest.branch == originalLatest.branch
125+
assert latest.id == originalLatest.id
126+
}
127+
}
128+
129+
and: "The latest files for the branches param should be incremented correctly"
130+
if (name != null) {
131+
validateDefinitionFile(name, originalBranchesLatestFiles,)
118132
}
119-
// TODO assert that the definition file is created if a name is specified, and contains the correct incremented IDs
120133

121134
where:
122135
branchesParam | latestFilesModified | name
123-
// null | ["9.2"] | null
124-
// null | ["9.2", "9.1"] | null
125-
// ["9.2", "9.1"] | ["9.2"] | null
126-
["9.2"] | ["9.1"] | "test_tv" // TODO legitimate bug?
136+
null | ["9.2"] | null
137+
null | ["9.2", "9.1"] | null
138+
["9.2", "9.1"] | ["9.2"] | null
139+
["9.2"] | ["9.1"] | null
140+
["9.2"] | ["9.1"] | "test_tv" // TODO legitimate bug, need to always clean up latest.
141+
["9.2", "9.1"] | ["9.2", "9.1"] | "test_tv"
142+
127143
}
128144

129145
// TODO this test is finding a legitimate bug
@@ -173,10 +189,10 @@ class TransportVersionGenerationFuncTest extends AbstractTransportVersionFuncTes
173189

174190
when:
175191
def result = gradleRunner(
176-
":myserver:validateTransportVersionDefinitions",
177-
":myserver:generateTransportVersionDefinition",
178-
"--name=new_name" ,
179-
"--branches=9.2"
192+
":myserver:validateTransportVersionDefinitions",
193+
":myserver:generateTransportVersionDefinition",
194+
"--name=new_name",
195+
"--branches=9.2"
180196
).build()
181197

182198
then:

0 commit comments

Comments
 (0)