Skip to content

Commit fdc401e

Browse files
authored
Minor DataStreamsUpgradeIT::testUpgradeDataStream improvements (#119144) (#119169)
1 parent 50fc1ed commit fdc401e

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/DataStreamsUpgradeIT.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public void testDataStreamValidationDoesNotBreakUpgrade() throws Exception {
176176

177177
public void testUpgradeDataStream() throws Exception {
178178
String dataStreamName = "reindex_test_data_stream";
179-
int numRollovers = 5;
179+
int numRollovers = randomIntBetween(0, 5);
180180
if (CLUSTER_TYPE == ClusterType.OLD) {
181181
createAndRolloverDataStream(dataStreamName, numRollovers);
182182
} else if (CLUSTER_TYPE == ClusterType.UPGRADED) {
@@ -271,10 +271,17 @@ private void upgradeDataStream(String dataStreamName, int numRollovers) throws E
271271
);
272272
assertOK(statusResponse);
273273
assertThat(statusResponseMap.get("complete"), equalTo(true));
274+
/*
275+
* total_indices_in_data_stream is determined at the beginning of the reindex, and does not take into account the write
276+
* index being rolled over
277+
*/
278+
assertThat(statusResponseMap.get("total_indices_in_data_stream"), equalTo(numRollovers + 1));
274279
if (isOriginalClusterSameMajorVersionAsCurrent()) {
275280
// If the original cluster was the same as this one, we don't want any indices reindexed:
281+
assertThat(statusResponseMap.get("total_indices_requiring_upgrade"), equalTo(0));
276282
assertThat(statusResponseMap.get("successes"), equalTo(0));
277283
} else {
284+
assertThat(statusResponseMap.get("total_indices_requiring_upgrade"), equalTo(numRollovers + 1));
278285
assertThat(statusResponseMap.get("successes"), equalTo(numRollovers + 1));
279286
}
280287
}, 60, TimeUnit.SECONDS);
@@ -283,7 +290,15 @@ private void upgradeDataStream(String dataStreamName, int numRollovers) throws E
283290
assertOK(cancelResponse);
284291
}
285292

293+
/*
294+
* Similar to isOriginalClusterCurrent, but returns true if the major versions of the clusters are the same. So true
295+
* for 8.6 and 8.17, but false for 7.17 and 8.18.
296+
*/
286297
private boolean isOriginalClusterSameMajorVersionAsCurrent() {
298+
/*
299+
* Since data stream reindex is specifically about upgrading a data stream from one major version to the next, it's ok to use the
300+
* deprecated Version.fromString here
301+
*/
287302
return Version.fromString(UPGRADE_FROM_VERSION).major == Version.fromString(Build.current().version()).major;
288303
}
289304

0 commit comments

Comments
 (0)