Skip to content

Commit 32503fa

Browse files
committed
better validation before migrating
1 parent cf6fcc8 commit 32503fa

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ class TransportVersionManagementPluginFuncTest extends AbstractGradleFuncTest {
275275
when:
276276
def result = validateDefinitionsFails()
277277
then:
278-
assertDefinitionsFailure(result, "Transport version base version 8013000 is missing patch version 8013001")
278+
assertDefinitionsFailure(result, "Transport version base id 8013000 is missing patch ids between 8013000 and 8013002")
279279
}
280280

281281
def "primary id must not be patch version"() {

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/transport/ValidateTransportVersionDefinitionsTask.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,14 @@ private void cleanupAndValidateBase(int base, List<IdAndDefinition> ids) {
293293
// first sort the ids list so we can check compactness and quickly lookup the highest id later
294294
ids.sort(Comparator.comparingInt(a -> a.id().complete()));
295295

296-
for (int ndx = 0; ndx < ids.size(); ++ndx) {
297-
IdAndDefinition idAndDefinition = ids.get(ndx);
298-
if (idAndDefinition.id().patch() != ndx) {
299-
throw new IllegalStateException("Transport version base version " + base + " is missing patch version " + (base + ndx));
296+
// TODO: switch this to a fully dense check once all existing transport versions have been migrated
297+
IdAndDefinition previous = ids.getLast();
298+
for (int ndx = ids.size() - 2; ndx >= 0; --ndx) {
299+
IdAndDefinition next = ids.get(ndx);
300+
// note that next and previous are reversed here because we are iterating in reverse order
301+
if (previous.id().complete() - 1 != next.id().complete()) {
302+
throw new IllegalStateException("Transport version base id " + base +
303+
" is missing patch ids between " + next.id() + " and " + previous.id());
300304
}
301305
}
302306
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
9112000

0 commit comments

Comments
 (0)