From 2f3222067e653228da62d38af51f640e41eaee86 Mon Sep 17 00:00:00 2001 From: David Turner Date: Tue, 2 Apr 2019 15:32:27 +0100 Subject: [PATCH] Use TAR instead of DOCKER build type before 6.7.0 (#40723) In 6.7.0 (#39378) we added a build type of DOCKER for the docker images, but unfortunately earlier versions do not understand this and will reject any transport messages that mention this build type. This commit fixes this by reporting TAR instead of DOCKER when talking to older nodes. Relates (but does not fix) #40511 Relates #39378 This commit is the changes that were supposed to be included in the preceding one, abe509a3b16be0707ace12abd4cabf3dc28a007d, but weren't because of a missing `git add`. --- .../java/org/elasticsearch/BuildTests.java | 37 ++++++------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/BuildTests.java b/server/src/test/java/org/elasticsearch/BuildTests.java index fdb1cabc6bcc1..4b220dad17891 100644 --- a/server/src/test/java/org/elasticsearch/BuildTests.java +++ b/server/src/test/java/org/elasticsearch/BuildTests.java @@ -115,30 +115,27 @@ private static String randomStringExcept(final String s) { public void testSerialization() { EqualsHashCodeTestUtils.checkEqualsAndHashCode(new WriteableBuild(new Build( randomFrom(Build.Flavor.values()), randomFrom(Build.Type.values()), - randomAlphaOfLength(6), randomAlphaOfLength(6), randomBoolean(), randomAlphaOfLength(6))), + randomAlphaOfLength(6), randomAlphaOfLength(6), randomBoolean())), b -> copyWriteable(b, writableRegistry(), WriteableBuild::new, Version.CURRENT), b -> { - switch (randomIntBetween(1, 6)) { + switch (randomIntBetween(1, 5)) { case 1: return new WriteableBuild(new Build( randomValueOtherThan(b.build.flavor(), () -> randomFrom(Build.Flavor.values())), b.build.type(), - b.build.shortHash(), b.build.date(), b.build.isSnapshot(), b.build.getQualifiedVersion())); + b.build.shortHash(), b.build.date(), b.build.isSnapshot())); case 2: return new WriteableBuild(new Build(b.build.flavor(), randomValueOtherThan(b.build.type(), () -> randomFrom(Build.Type.values())), - b.build.shortHash(), b.build.date(), b.build.isSnapshot(), b.build.getQualifiedVersion())); + b.build.shortHash(), b.build.date(), b.build.isSnapshot())); case 3: return new WriteableBuild(new Build(b.build.flavor(), b.build.type(), - randomStringExcept(b.build.shortHash()), b.build.date(), b.build.isSnapshot(), b.build.getQualifiedVersion())); + randomStringExcept(b.build.shortHash()), b.build.date(), b.build.isSnapshot())); case 4: return new WriteableBuild(new Build(b.build.flavor(), b.build.type(), - b.build.shortHash(), randomStringExcept(b.build.date()), b.build.isSnapshot(), b.build.getQualifiedVersion())); + b.build.shortHash(), randomStringExcept(b.build.date()), b.build.isSnapshot())); case 5: return new WriteableBuild(new Build(b.build.flavor(), b.build.type(), - b.build.shortHash(), b.build.date(), b.build.isSnapshot() == false, b.build.getQualifiedVersion())); - case 6: - return new WriteableBuild(new Build(b.build.flavor(), b.build.type(), - b.build.shortHash(), b.build.date(), b.build.isSnapshot(), randomStringExcept(b.build.getQualifiedVersion()))); + b.build.shortHash(), b.build.date(), b.build.isSnapshot() == false)); } throw new AssertionError(); }); @@ -146,34 +143,24 @@ public void testSerialization() { public void testSerializationBWC() throws IOException { final WriteableBuild dockerBuild = new WriteableBuild(new Build(randomFrom(Build.Flavor.values()), Build.Type.DOCKER, - randomAlphaOfLength(6), randomAlphaOfLength(6), randomBoolean(), randomAlphaOfLength(6))); + randomAlphaOfLength(6), randomAlphaOfLength(6), randomBoolean())); final List versions = Version.getDeclaredVersions(Version.class); final Version pre63Version = randomFrom(versions.stream().filter(v -> v.before(Version.V_6_3_0)).collect(Collectors.toList())); final Version post63Pre67Version = randomFrom(versions.stream() .filter(v -> v.onOrAfter(Version.V_6_3_0) && v.before(Version.V_6_7_0)).collect(Collectors.toList())); - final Version post67Pre70Version = randomFrom(versions.stream() - .filter(v -> v.onOrAfter(Version.V_6_7_0) && v.before(Version.V_7_0_0)).collect(Collectors.toList())); - final Version post70Version = randomFrom(versions.stream().filter(v -> v.onOrAfter(Version.V_7_0_0)).collect(Collectors.toList())); + final Version post67Version = randomFrom(versions.stream().filter(v -> v.onOrAfter(Version.V_6_7_0)).collect(Collectors.toList())); final WriteableBuild pre63 = copyWriteable(dockerBuild, writableRegistry(), WriteableBuild::new, pre63Version); final WriteableBuild post63pre67 = copyWriteable(dockerBuild, writableRegistry(), WriteableBuild::new, post63Pre67Version); - final WriteableBuild post67pre70 = copyWriteable(dockerBuild, writableRegistry(), WriteableBuild::new, post67Pre70Version); - final WriteableBuild post70 = copyWriteable(dockerBuild, writableRegistry(), WriteableBuild::new, post70Version); + final WriteableBuild post67 = copyWriteable(dockerBuild, writableRegistry(), WriteableBuild::new, post67Version); assertThat(pre63.build.flavor(), equalTo(Build.Flavor.OSS)); assertThat(post63pre67.build.flavor(), equalTo(dockerBuild.build.flavor())); - assertThat(post67pre70.build.flavor(), equalTo(dockerBuild.build.flavor())); - assertThat(post70.build.flavor(), equalTo(dockerBuild.build.flavor())); + assertThat(post67.build.flavor(), equalTo(dockerBuild.build.flavor())); assertThat(pre63.build.type(), equalTo(Build.Type.UNKNOWN)); assertThat(post63pre67.build.type(), equalTo(Build.Type.TAR)); - assertThat(post67pre70.build.type(), equalTo(dockerBuild.build.type())); - assertThat(post70.build.type(), equalTo(dockerBuild.build.type())); - - assertThat(pre63.build.getQualifiedVersion(), equalTo(pre63Version.toString())); - assertThat(post63pre67.build.getQualifiedVersion(), equalTo(post63Pre67Version.toString())); - assertThat(post67pre70.build.getQualifiedVersion(), equalTo(post67Pre70Version.toString())); - assertThat(post70.build.getQualifiedVersion(), equalTo(dockerBuild.build.getQualifiedVersion())); + assertThat(post67.build.type(), equalTo(dockerBuild.build.type())); } }