Remove version.qualified from MainResponse (#35412)
The fully qualified version will be returned as `version.number`
This commit is contained in:
parent
afd42df15f
commit
e0a678f0c4
|
@ -52,7 +52,7 @@ public class PingAndInfoIT extends ESRestHighLevelClientTestCase {
|
|||
assertEquals(versionMap.get("build_hash"), info.getBuild().shortHash());
|
||||
assertEquals(versionMap.get("build_date"), info.getBuild().date());
|
||||
assertEquals(versionMap.get("build_snapshot"), info.getBuild().isSnapshot());
|
||||
assertEquals(versionMap.get("number"), info.getVersion().toString());
|
||||
assertTrue(versionMap.get("number").toString().startsWith(info.getVersion().toString()));
|
||||
assertEquals(versionMap.get("lucene_version"), info.getVersion().luceneVersion.toString());
|
||||
}
|
||||
|
||||
|
|
|
@ -371,13 +371,12 @@ This command should give you a JSON result:
|
|||
"cluster_name" : "elasticsearch",
|
||||
"cluster_uuid" : "AT69_T_DTp-1qgIJlatQqA",
|
||||
"version" : {
|
||||
"number" : "{version}",
|
||||
"number" : "{version_qualified}",
|
||||
"build_flavor" : "{build_flavor}",
|
||||
"build_type" : "zip",
|
||||
"build_hash" : "f27399d",
|
||||
"build_date" : "2016-03-30T09:51:41.449Z",
|
||||
"build_snapshot" : false,
|
||||
"qualified" : "{version_qualified}",
|
||||
"lucene_version" : "{lucene_version}",
|
||||
"minimum_wire_compatibility_version" : "1.2.3",
|
||||
"minimum_index_compatibility_version" : "1.2.3"
|
||||
|
|
|
@ -18,13 +18,12 @@ which should give you a response something like this:
|
|||
"cluster_name" : "elasticsearch",
|
||||
"cluster_uuid" : "AT69_T_DTp-1qgIJlatQqA",
|
||||
"version" : {
|
||||
"number" : "{version}",
|
||||
"number" : "{version_qualified}",
|
||||
"build_flavor" : "{build_flavor}",
|
||||
"build_type" : "zip",
|
||||
"build_hash" : "f27399d",
|
||||
"build_date" : "2016-03-30T09:51:41.449Z",
|
||||
"build_snapshot" : false,
|
||||
"qualified" : "{version_qualified}",
|
||||
"lucene_version" : "{lucene_version}",
|
||||
"minimum_wire_compatibility_version" : "1.2.3",
|
||||
"minimum_index_compatibility_version" : "1.2.3"
|
||||
|
|
|
@ -268,7 +268,11 @@ final class RemoteResponseParsers {
|
|||
"/", true, a -> (Version) a[0]);
|
||||
static {
|
||||
ConstructingObjectParser<Version, XContentType> versionParser = new ConstructingObjectParser<>(
|
||||
"version", true, a -> Version.fromString((String) a[0]));
|
||||
"version", true, a -> Version.fromString(
|
||||
((String) a[0])
|
||||
.replace("-SNAPSHOT", "")
|
||||
.replaceFirst("-(alpha\\d+|beta\\d+|rc\\d+)", "")
|
||||
));
|
||||
versionParser.declareString(constructorArg(), new ParseField("number"));
|
||||
MAIN_ACTION_PARSER.declareObject(constructorArg(), versionParser, new ParseField("version"));
|
||||
}
|
||||
|
|
|
@ -150,15 +150,15 @@ public class RemoteScrollableHitSourceTests extends ESTestCase {
|
|||
assertTrue(called.get());
|
||||
called.set(false);
|
||||
sourceWithMockedRemoteCall(false, ContentType.APPLICATION_JSON, "main/5_0_0_alpha_3.json").lookupRemoteVersion(v -> {
|
||||
// V_5_0_0_alpha3
|
||||
assertEquals(Version.fromId(5000003), v);
|
||||
// assert for V_5_0_0 (no qualifier) since we no longer consider qualifier in Version since 7
|
||||
assertEquals(Version.fromId(5000099), v);
|
||||
called.set(true);
|
||||
});
|
||||
assertTrue(called.get());
|
||||
called.set(false);
|
||||
sourceWithMockedRemoteCall(false, ContentType.APPLICATION_JSON, "main/with_unknown_fields.json").lookupRemoteVersion(v -> {
|
||||
// V_5_0_0_alpha3
|
||||
assertEquals(Version.fromId(5000003), v);
|
||||
// V_5_0_0 since we no longer consider qualifier in Version
|
||||
assertEquals(Version.fromId(5000099), v);
|
||||
called.set(true);
|
||||
});
|
||||
assertTrue(called.get());
|
||||
|
|
|
@ -516,13 +516,19 @@ wait_for_elasticsearch_status() {
|
|||
# $1 - expected version
|
||||
check_elasticsearch_version() {
|
||||
local version=$1
|
||||
local versionToCheck=$(echo $version | sed -e 's/-SNAPSHOT//' | sed -e 's/-\(alpha\|beta\|rc\)[0-9]//')
|
||||
local versionToCheck
|
||||
local major=$(echo ${version} | cut -d. -f1 )
|
||||
if [ $major -ge 7 ] ; then
|
||||
versionToCheck=$version
|
||||
else
|
||||
versionToCheck=$(echo ${version} | sed -e 's/-SNAPSHOT//')
|
||||
fi
|
||||
|
||||
run curl -s localhost:9200
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
echo $output | grep \"number\"\ :\ \"$versionToCheck\" || {
|
||||
echo "Installed an unexpected version:"
|
||||
echo "Expected $versionToCheck but installed an unexpected version:"
|
||||
curl -s localhost:9200
|
||||
false
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ public class Build {
|
|||
// not running from the official elasticsearch jar file (unit tests, IDE, uber client jar, shadiness)
|
||||
shortHash = "Unknown";
|
||||
date = "Unknown";
|
||||
version = "Unknown";
|
||||
version = Version.CURRENT.toString();
|
||||
final String buildSnapshot = System.getProperty("build.snapshot");
|
||||
if (buildSnapshot != null) {
|
||||
try {
|
||||
|
|
|
@ -253,6 +253,9 @@ public class Version implements Comparable<Version>, ToXContentFragment {
|
|||
if (rawMajor >= 5 && snapshot) { // we don't support snapshot as part of the version here anymore
|
||||
throw new IllegalArgumentException("illegal version format - snapshots are only supported until version 2.x");
|
||||
}
|
||||
if (rawMajor >=7 && parts.length == 4) { // we don't support qualifier as part of the version anymore
|
||||
throw new IllegalArgumentException("illegal version format - qualifiers are only supported until version 6.x");
|
||||
}
|
||||
final int betaOffset = rawMajor < 5 ? 0 : 25;
|
||||
//we reverse the version id calculation based on some assumption as we can't reliably reverse the modulo
|
||||
final int major = rawMajor * 1000000;
|
||||
|
|
|
@ -107,13 +107,12 @@ public class MainResponse extends ActionResponse implements ToXContentObject {
|
|||
builder.field("cluster_name", clusterName.value());
|
||||
builder.field("cluster_uuid", clusterUuid);
|
||||
builder.startObject("version")
|
||||
.field("number", version.toString())
|
||||
.field("number", build.getQualifiedVersion())
|
||||
.field("build_flavor", build.flavor().displayName())
|
||||
.field("build_type", build.type().displayName())
|
||||
.field("build_hash", build.shortHash())
|
||||
.field("build_date", build.date())
|
||||
.field("build_snapshot", build.isSnapshot())
|
||||
.field("qualified", build.getQualifiedVersion())
|
||||
.field("lucene_version", version.luceneVersion.toString())
|
||||
.field("minimum_wire_compatibility_version", version.minimumCompatibilityVersion().toString())
|
||||
.field("minimum_index_compatibility_version", version.minimumIndexCompatibilityVersion().toString())
|
||||
|
@ -141,9 +140,13 @@ public class MainResponse extends ActionResponse implements ToXContentObject {
|
|||
(String) value.get("build_hash"),
|
||||
(String) value.get("build_date"),
|
||||
(boolean) value.get("build_snapshot"),
|
||||
(String) value.get("qualified")
|
||||
(String) value.get("number")
|
||||
);
|
||||
response.version = Version.fromString((String) value.get("number"));
|
||||
response.version = Version.fromString(
|
||||
((String) value.get("number"))
|
||||
.replace("-SNAPSHOT", "")
|
||||
.replaceFirst("-(alpha\\d+|beta\\d+|rc\\d+)", "")
|
||||
);
|
||||
}, (parser, context) -> parser.map(), new ParseField("version"));
|
||||
}
|
||||
|
||||
|
@ -171,4 +174,15 @@ public class MainResponse extends ActionResponse implements ToXContentObject {
|
|||
public int hashCode() {
|
||||
return Objects.hash(nodeName, version, clusterUuid, build, clusterName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MainResponse{" +
|
||||
"nodeName='" + nodeName + '\'' +
|
||||
", version=" + version +
|
||||
", clusterName=" + clusterName +
|
||||
", clusterUuid='" + clusterUuid + '\'' +
|
||||
", build=" + build +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ public class BuildTests extends ESTestCase {
|
|||
assertNotEquals(build, differentSnapshot);
|
||||
|
||||
Build differentVersion = new Build(
|
||||
build.flavor(), build.type(), build.shortHash(), build.date(), build.isSnapshot(), "7.0.0"
|
||||
build.flavor(), build.type(), build.shortHash(), build.date(), build.isSnapshot(), "1.2.3"
|
||||
);
|
||||
assertNotEquals(build, differentVersion);
|
||||
}
|
||||
|
|
|
@ -41,11 +41,11 @@ public class MainResponseTests extends AbstractStreamableXContentTestCase<MainRe
|
|||
ClusterName clusterName = new ClusterName(randomAlphaOfLength(10));
|
||||
String nodeName = randomAlphaOfLength(10);
|
||||
final String date = new Date(randomNonNegativeLong()).toString();
|
||||
Version version = VersionUtils.randomVersionBetween(random(), Version.V_6_0_1, Version.CURRENT);
|
||||
Build build = new Build(
|
||||
Build.Flavor.UNKNOWN, Build.Type.UNKNOWN, randomAlphaOfLength(8), date, randomBoolean(),
|
||||
randomAlphaOfLength(12)
|
||||
version.toString()
|
||||
);
|
||||
Version version = VersionUtils.randomVersion(random());
|
||||
return new MainResponse(nodeName, version, clusterName, clusterUuid , build);
|
||||
}
|
||||
|
||||
|
@ -75,13 +75,12 @@ public class MainResponseTests extends AbstractStreamableXContentTestCase<MainRe
|
|||
+ "\"cluster_name\":\"clusterName\","
|
||||
+ "\"cluster_uuid\":\"" + clusterUUID + "\","
|
||||
+ "\"version\":{"
|
||||
+ "\"number\":\"" + version.toString() + "\","
|
||||
+ "\"number\":\"" + build.getQualifiedVersion() + "\","
|
||||
+ "\"build_flavor\":\"" + current.flavor().displayName() + "\","
|
||||
+ "\"build_type\":\"" + current.type().displayName() + "\","
|
||||
+ "\"build_hash\":\"" + current.shortHash() + "\","
|
||||
+ "\"build_date\":\"" + current.date() + "\","
|
||||
+ "\"build_snapshot\":" + current.isSnapshot() + ","
|
||||
+ "\"qualified\":\"" + current.getQualifiedVersion() + "\","
|
||||
+ "\"lucene_version\":\"" + version.luceneVersion.toString() + "\","
|
||||
+ "\"minimum_wire_compatibility_version\":\"" + version.minimumCompatibilityVersion().toString() + "\","
|
||||
+ "\"minimum_index_compatibility_version\":\"" + version.minimumIndexCompatibilityVersion().toString() + "\"},"
|
||||
|
|
|
@ -96,7 +96,11 @@ public class VersionHttpResource extends HttpResource {
|
|||
// the response should be filtered to just '{"version":{"number":"xyz"}}', so this is cheap and guaranteed
|
||||
@SuppressWarnings("unchecked")
|
||||
final String versionNumber = (String) ((Map<String, Object>) map.get("version")).get("number");
|
||||
final Version version = Version.fromString(versionNumber);
|
||||
final Version version = Version.fromString(
|
||||
versionNumber
|
||||
.replace("-SNAPSHOT", "")
|
||||
.replaceFirst("-(alpha\\d+|beta\\d+|rc\\d+)", "")
|
||||
);
|
||||
|
||||
if (version.onOrAfter(minimumVersion)) {
|
||||
logger.debug("version [{}] >= [{}] and supported for [{}]", version, minimumVersion, resourceOwnerName);
|
||||
|
|
Loading…
Reference in New Issue