Skip to content

Commit db56f11

Browse files
authored
Prepare for bump to 6.0.1 on the 6.0 branch (#27386)
An attempt to bump to 6.0.1 on the 6.0 branch exposed up a handful of issues that this commit fixes. One of those fixes is a terrible hack that will be fixed more thoroughly in #27397, and another is a back port of d5e56c5 which is related to #27251.
1 parent effdf58 commit db56f11

File tree

4 files changed

+51
-7
lines changed

4 files changed

+51
-7
lines changed

build.gradle

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ List<Version> versions = []
8181
// keep track of the previous major version's last minor, so we know where wire compat begins
8282
int prevMinorIndex = -1 // index in the versions list of the last minor from the prev major
8383
int lastPrevMinor = -1 // the minor version number from the prev major we most recently seen
84+
int prevBugfixIndex = -1 // index in the versions list of the last bugfix release from the prev major
8485
for (String line : versionLines) {
8586
/* Note that this skips alphas and betas which is fine because they aren't
8687
* compatible with anything. */
@@ -97,12 +98,19 @@ for (String line : versionLines) {
9798
prevMinorIndex = versions.size() - 1
9899
lastPrevMinor = minor
99100
}
101+
if (major == prevMajor) {
102+
prevBugfixIndex = versions.size() - 1
103+
}
100104
}
101105
}
102106
if (versions.toSorted { it.id } != versions) {
103107
println "Versions: ${versions}"
104108
throw new GradleException("Versions.java contains out of order version constants")
105109
}
110+
if (prevBugfixIndex != -1) {
111+
versions[prevBugfixIndex] = new Version(
112+
versions[prevBugfixIndex].major, versions[prevBugfixIndex].minor, versions[prevBugfixIndex].bugfix, true)
113+
}
106114
if (currentVersion.bugfix == 0) {
107115
// If on a release branch, after the initial release of that branch, the bugfix version will
108116
// be bumped, and will be != 0. On master and N.x branches, we want to test against the
@@ -248,6 +256,11 @@ subprojects {
248256
ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-release-snapshot'
249257
ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-1]}"] = ':distribution:bwc-release-snapshot'
250258
}
259+
} else if (indexCompatVersions[-2].snapshot) {
260+
/* This is a terrible hack for the bump to 6.0.1 which will be fixed by #27397 */
261+
ext.projectSubstitutions["org.elasticsearch.distribution.deb:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release-snapshot'
262+
ext.projectSubstitutions["org.elasticsearch.distribution.rpm:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release-snapshot'
263+
ext.projectSubstitutions["org.elasticsearch.distribution.zip:elasticsearch:${indexCompatVersions[-2]}"] = ':distribution:bwc-release-snapshot'
251264
}
252265
project.afterEvaluate {
253266
configurations.all {

qa/mixed-cluster/src/test/java/org/elasticsearch/backwards/IndexingIT.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public void testSeqNoCheckpoints() throws Exception {
199199
final int numberOfInitialDocs = 1 + randomInt(5);
200200
logger.info("indexing [{}] docs initially", numberOfInitialDocs);
201201
numDocs += indexDocs(index, 0, numberOfInitialDocs);
202-
assertSeqNoOnShards(index, nodes, 0, newNodeClient);
202+
assertSeqNoOnShards(index, nodes, nodes.getBWCVersion().major >= 6 ? numDocs : 0, newNodeClient);
203203
logger.info("allowing shards on all nodes");
204204
updateIndexSetting(index, Settings.builder().putNull("index.routing.allocation.include._name"));
205205
ensureGreen();
@@ -210,7 +210,7 @@ public void testSeqNoCheckpoints() throws Exception {
210210
final int numberOfDocsAfterAllowingShardsOnAllNodes = 1 + randomInt(5);
211211
logger.info("indexing [{}] docs after allowing shards on all nodes", numberOfDocsAfterAllowingShardsOnAllNodes);
212212
numDocs += indexDocs(index, numDocs, numberOfDocsAfterAllowingShardsOnAllNodes);
213-
assertSeqNoOnShards(index, nodes, 0, newNodeClient);
213+
assertSeqNoOnShards(index, nodes, nodes.getBWCVersion().major >= 6 ? numDocs : 0, newNodeClient);
214214
Shard primary = buildShards(index, nodes, newNodeClient).stream().filter(Shard::isPrimary).findFirst().get();
215215
logger.info("moving primary to new node by excluding {}", primary.getNode().getNodeName());
216216
updateIndexSetting(index, Settings.builder().put("index.routing.allocation.exclude._name", primary.getNode().getNodeName()));
@@ -220,7 +220,7 @@ public void testSeqNoCheckpoints() throws Exception {
220220
logger.info("indexing [{}] docs after moving primary", numberOfDocsAfterMovingPrimary);
221221
numDocsOnNewPrimary += indexDocs(index, numDocs, numberOfDocsAfterMovingPrimary);
222222
numDocs += numberOfDocsAfterMovingPrimary;
223-
assertSeqNoOnShards(index, nodes, numDocsOnNewPrimary, newNodeClient);
223+
assertSeqNoOnShards(index, nodes, nodes.getBWCVersion().major >= 6 ? numDocs : numDocsOnNewPrimary, newNodeClient);
224224
/*
225225
* Dropping the number of replicas to zero, and then increasing it to one triggers a recovery thus exercising any BWC-logic in
226226
* the recovery code.
@@ -238,7 +238,7 @@ public void testSeqNoCheckpoints() throws Exception {
238238
// the number of documents on the primary and on the recovered replica should match the number of indexed documents
239239
assertCount(index, "_primary", numDocs);
240240
assertCount(index, "_replica", numDocs);
241-
assertSeqNoOnShards(index, nodes, numDocsOnNewPrimary, newNodeClient);
241+
assertSeqNoOnShards(index, nodes, nodes.getBWCVersion().major >= 6 ? numDocs : numDocsOnNewPrimary, newNodeClient);
242242
}
243243
}
244244

test/framework/src/main/java/org/elasticsearch/test/VersionUtils.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,15 @@ static Tuple<List<Version>, List<Version>> resolveReleasedVersions(Version curre
7575
+ "but was [" + versions.get(versions.size() - 1) + "] and current was [" + current + "]";
7676

7777
if (current.revision != 0) {
78-
/* If we are in a stable branch there should be no unreleased version constants
79-
* because we don't expect to release any new versions in older branches. If there
80-
* are extra constants then gradle will yell about it. */
78+
/* If we are in a stable branch then the only unreleased versions should be the current one and
79+
* the latest one in the previous major version. If there are extra constants then gradle will yell about it. */
80+
for (int i = versions.size() - 1; i >= 0; i--) {
81+
if (versions.get(i).major < current.major) {
82+
Version lastOfPreviousMajor = versions.remove(i);
83+
return new Tuple<>(unmodifiableList(versions), Arrays.asList(lastOfPreviousMajor, current));
84+
}
85+
}
86+
8187
return new Tuple<>(unmodifiableList(versions), singletonList(current));
8288
}
8389

test/framework/src/test/java/org/elasticsearch/test/VersionUtilsTests.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,31 @@ public void testResolveReleasedVersionsForUnstableBranch() {
168168
assertEquals(Arrays.asList(TestUnstableBranch.V_5_3_2, TestUnstableBranch.V_5_4_0, TestUnstableBranch.V_6_0_0_beta2), unreleased);
169169
}
170170

171+
static class TestNewMajorRelease {
172+
public static final Version V_5_6_0 = Version.fromString("5.6.0");
173+
public static final Version V_5_6_1 = Version.fromString("5.6.1");
174+
public static final Version V_5_6_2 = Version.fromString("5.6.2");
175+
public static final Version V_6_0_0_alpha1 = Version.fromString("6.0.0-alpha1");
176+
public static final Version V_6_0_0_alpha2 = Version.fromString("6.0.0-alpha2");
177+
public static final Version V_6_0_0_beta1 = Version.fromString("6.0.0-beta1");
178+
public static final Version V_6_0_0_beta2 = Version.fromString("6.0.0-beta2");
179+
public static final Version V_6_0_0 = Version.fromString("6.0.0");
180+
public static final Version V_6_0_1 = Version.fromString("6.0.1");
181+
public static final Version CURRENT = V_6_0_1;
182+
}
183+
184+
public void testResolveReleasedVersionsAtNewMajorRelease() {
185+
Tuple<List<Version>, List<Version>> t = VersionUtils.resolveReleasedVersions(TestNewMajorRelease.CURRENT,
186+
TestNewMajorRelease.class);
187+
List<Version> released = t.v1();
188+
List<Version> unreleased = t.v2();
189+
assertEquals(Arrays.asList(TestNewMajorRelease.V_5_6_0, TestNewMajorRelease.V_5_6_1,
190+
TestNewMajorRelease.V_6_0_0_alpha1, TestNewMajorRelease.V_6_0_0_alpha2,
191+
TestNewMajorRelease.V_6_0_0_beta1, TestNewMajorRelease.V_6_0_0_beta2,
192+
TestNewMajorRelease.V_6_0_0), released);
193+
assertEquals(Arrays.asList(TestNewMajorRelease.V_5_6_2, TestNewMajorRelease.V_6_0_1), unreleased);
194+
}
195+
171196
/**
172197
* Tests that {@link Version#minimumCompatibilityVersion()} and {@link VersionUtils#allReleasedVersions()}
173198
* agree with the list of wire and index compatible versions we build in gradle.

0 commit comments

Comments
 (0)