From baca7db2b2386dfd8c0a2ccb63acf9692830525a Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Tue, 12 Apr 2022 08:33:42 -0700 Subject: [PATCH] Fix BuildTests serialization This commit fixes a randomization bug in the tests for Build serialization, which could generate the same object when it should mutate. closes #85800 --- .../test/java/org/elasticsearch/BuildTests.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/BuildTests.java b/server/src/test/java/org/elasticsearch/BuildTests.java index 55f8c3790d396..06f9f84662979 100644 --- a/server/src/test/java/org/elasticsearch/BuildTests.java +++ b/server/src/test/java/org/elasticsearch/BuildTests.java @@ -148,12 +148,8 @@ public void testSerialization() { // Note: the cast of the Copy- and MutateFunction is needed for some IDE (specifically Eclipse 4.10.0) to infer the right type (WriteableBuild b) -> copyWriteable(b, writableRegistry(), WriteableBuild::new, Version.CURRENT), (WriteableBuild b) -> { - switch (randomIntBetween(1, 6)) { + switch (randomIntBetween(1, 5)) { case 1: - return new WriteableBuild( - new Build(b.build.type(), b.build.hash(), b.build.date(), b.build.isSnapshot(), b.build.qualifiedVersion()) - ); - case 2: return new WriteableBuild( new Build( randomValueOtherThan(b.build.type(), () -> randomFrom(Build.Type.values())), @@ -163,7 +159,7 @@ public void testSerialization() { b.build.qualifiedVersion() ) ); - case 3: + case 2: return new WriteableBuild( new Build( b.build.type(), @@ -173,7 +169,7 @@ public void testSerialization() { b.build.qualifiedVersion() ) ); - case 4: + case 3: return new WriteableBuild( new Build( b.build.type(), @@ -183,7 +179,7 @@ public void testSerialization() { b.build.qualifiedVersion() ) ); - case 5: + case 4: return new WriteableBuild( new Build( b.build.type(), @@ -193,7 +189,7 @@ public void testSerialization() { b.build.qualifiedVersion() ) ); - case 6: + case 5: return new WriteableBuild( new Build( b.build.type(),