|
@@ -73,7 +73,7 @@ public class NodeMetadataTests extends ESTestCase {
|
|
final NodeMetadata nodeMetadata = new NodeMetadata(
|
|
final NodeMetadata nodeMetadata = new NodeMetadata(
|
|
nodeId,
|
|
nodeId,
|
|
randomValueOtherThanMany(
|
|
randomValueOtherThanMany(
|
|
- v -> v.after(Version.CURRENT) || v.before(Version.CURRENT.minimumIndexCompatibilityVersion()),
|
|
|
|
|
|
+ v -> v.after(Version.CURRENT) || v.before(Version.CURRENT.minimumCompatibilityVersion()),
|
|
this::randomVersion
|
|
this::randomVersion
|
|
)
|
|
)
|
|
).upgradeToCurrentVersion();
|
|
).upgradeToCurrentVersion();
|
|
@@ -83,9 +83,15 @@ public class NodeMetadataTests extends ESTestCase {
|
|
|
|
|
|
public void testUpgradesMissingVersion() {
|
|
public void testUpgradesMissingVersion() {
|
|
final String nodeId = randomAlphaOfLength(10);
|
|
final String nodeId = randomAlphaOfLength(10);
|
|
- final NodeMetadata nodeMetadata = new NodeMetadata(nodeId, Version.V_EMPTY).upgradeToCurrentVersion();
|
|
|
|
- assertThat(nodeMetadata.nodeVersion(), equalTo(Version.CURRENT));
|
|
|
|
- assertThat(nodeMetadata.nodeId(), equalTo(nodeId));
|
|
|
|
|
|
+
|
|
|
|
+ final IllegalStateException illegalStateException = expectThrows(
|
|
|
|
+ IllegalStateException.class,
|
|
|
|
+ () -> new NodeMetadata(nodeId, Version.V_EMPTY).upgradeToCurrentVersion()
|
|
|
|
+ );
|
|
|
|
+ assertThat(
|
|
|
|
+ illegalStateException.getMessage(),
|
|
|
|
+ startsWith("cannot upgrade a node from version [" + Version.V_EMPTY + "] directly to version [" + Version.CURRENT + "]")
|
|
|
|
+ );
|
|
}
|
|
}
|
|
|
|
|
|
public void testDoesNotUpgradeFutureVersion() {
|
|
public void testDoesNotUpgradeFutureVersion() {
|
|
@@ -106,13 +112,23 @@ public class NodeMetadataTests extends ESTestCase {
|
|
);
|
|
);
|
|
assertThat(
|
|
assertThat(
|
|
illegalStateException.getMessage(),
|
|
illegalStateException.getMessage(),
|
|
- allOf(startsWith("cannot upgrade a node from version ["), endsWith("] directly to version [" + Version.CURRENT + "]"))
|
|
|
|
|
|
+ allOf(
|
|
|
|
+ startsWith("cannot upgrade a node from version ["),
|
|
|
|
+ endsWith(
|
|
|
|
+ "] directly to version ["
|
|
|
|
+ + Version.CURRENT
|
|
|
|
+ + "], upgrade to version ["
|
|
|
|
+ + Version.CURRENT.minimumCompatibilityVersion()
|
|
|
|
+ + "] first."
|
|
|
|
+ )
|
|
|
|
+ )
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
public void testUpgradeMarksPreviousVersion() {
|
|
public void testUpgradeMarksPreviousVersion() {
|
|
final String nodeId = randomAlphaOfLength(10);
|
|
final String nodeId = randomAlphaOfLength(10);
|
|
- final Version version = VersionUtils.randomVersionBetween(random(), Version.V_7_3_0, Version.V_7_16_0);
|
|
|
|
|
|
+ final Version version = VersionUtils.randomVersionBetween(random(), Version.CURRENT.minimumCompatibilityVersion(), Version.V_8_0_0);
|
|
|
|
+
|
|
final NodeMetadata nodeMetadata = new NodeMetadata(nodeId, version).upgradeToCurrentVersion();
|
|
final NodeMetadata nodeMetadata = new NodeMetadata(nodeId, version).upgradeToCurrentVersion();
|
|
assertThat(nodeMetadata.nodeVersion(), equalTo(Version.CURRENT));
|
|
assertThat(nodeMetadata.nodeVersion(), equalTo(Version.CURRENT));
|
|
assertThat(nodeMetadata.previousNodeVersion(), equalTo(version));
|
|
assertThat(nodeMetadata.previousNodeVersion(), equalTo(version));
|
|
@@ -123,6 +139,6 @@ public class NodeMetadataTests extends ESTestCase {
|
|
}
|
|
}
|
|
|
|
|
|
public static Version tooOldVersion() {
|
|
public static Version tooOldVersion() {
|
|
- return Version.fromId(between(1, Version.CURRENT.minimumIndexCompatibilityVersion().id - 1));
|
|
|
|
|
|
+ return Version.fromId(between(1, Version.CURRENT.minimumCompatibilityVersion().id - 1));
|
|
}
|
|
}
|
|
}
|
|
}
|