From 06dee4a86a85cb016e967466989c21e0260496d8 Mon Sep 17 00:00:00 2001 From: Benjamin Trent <4357155+benwtrent@users.noreply.github.com> Date: Mon, 14 Dec 2020 14:39:34 -0500 Subject: [PATCH 1/2] [ML] Transform test fix for testCreateLatestFunction closes https://github.com/elastic/elasticsearch/issues/66292 --- .../transform/transforms/latest/LatestConfigTests.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/transforms/latest/LatestConfigTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/transforms/latest/LatestConfigTests.java index e7a7ca874d4b..58fc01293fc4 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/transforms/latest/LatestConfigTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/transforms/latest/LatestConfigTests.java @@ -15,6 +15,8 @@ import org.elasticsearch.xpack.core.transform.transforms.AbstractSerializingTransformTestCase; import java.io.IOException; +import java.util.ArrayList; +import java.util.HashSet; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.containsInAnyOrder; @@ -25,7 +27,13 @@ public class LatestConfigTests extends AbstractSerializingTransformTestCase { public static LatestConfig randomLatestConfig() { - return new LatestConfig(randomList(1, 10, () -> randomAlphaOfLengthBetween(1, 10)), randomAlphaOfLengthBetween(1, 10)); + return new LatestConfig( + new ArrayList<>( + new HashSet<>(randomList(1, 10, () -> randomAlphaOfLengthBetween(1, 10)) + ) + ), + randomAlphaOfLengthBetween(1, 10) + ); } @Override From bc8d90e37a6d407f1cef92193ece090fe551063d Mon Sep 17 00:00:00 2001 From: Benjamin Trent <4357155+benwtrent@users.noreply.github.com> Date: Tue, 15 Dec 2020 07:25:48 -0500 Subject: [PATCH 2/2] fixing tests --- .../transform/transforms/latest/LatestConfigTests.java | 6 +++++- .../transform/transforms/latest/hlrc/LatestConfigTests.java | 6 +++++- .../core/transform/transforms/latest/LatestConfigTests.java | 6 +----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/transform/transforms/latest/LatestConfigTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/transform/transforms/latest/LatestConfigTests.java index 61ac99afef97..dcc6a8bdc83e 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/transform/transforms/latest/LatestConfigTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/transform/transforms/latest/LatestConfigTests.java @@ -23,12 +23,16 @@ import org.elasticsearch.test.AbstractXContentTestCase; import java.io.IOException; +import java.util.ArrayList; import java.util.function.Predicate; public class LatestConfigTests extends AbstractXContentTestCase { public static LatestConfig randomLatestConfig() { - return new LatestConfig(randomList(5, () -> randomAlphaOfLengthBetween(1, 10)), randomAlphaOfLengthBetween(1, 10)); + return new LatestConfig( + new ArrayList<>(randomUnique(() -> randomAlphaOfLengthBetween(1, 10), randomIntBetween(1, 10))), + randomAlphaOfLengthBetween(1, 10) + ); } @Override diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/transform/transforms/latest/hlrc/LatestConfigTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/transform/transforms/latest/hlrc/LatestConfigTests.java index 2657cf2b28db..ab048a50f2d1 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/transform/transforms/latest/hlrc/LatestConfigTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/transform/transforms/latest/hlrc/LatestConfigTests.java @@ -25,6 +25,7 @@ import org.elasticsearch.xpack.core.transform.transforms.latest.LatestConfig; import java.io.IOException; +import java.util.ArrayList; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; @@ -33,7 +34,10 @@ public class LatestConfigTests extends AbstractResponseTestCase { public static LatestConfig randomLatestConfig() { - return new LatestConfig(randomList(1, 10, () -> randomAlphaOfLengthBetween(1, 10)), randomAlphaOfLengthBetween(1, 10)); + return new LatestConfig( + new ArrayList<>(randomUnique(() -> randomAlphaOfLengthBetween(1, 10), randomIntBetween(1, 10))), + randomAlphaOfLengthBetween(1, 10) + ); } @Override diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/transforms/latest/LatestConfigTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/transforms/latest/LatestConfigTests.java index 58fc01293fc4..48c53174f0a6 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/transforms/latest/LatestConfigTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/transforms/latest/LatestConfigTests.java @@ -16,7 +16,6 @@ import java.io.IOException; import java.util.ArrayList; -import java.util.HashSet; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.containsInAnyOrder; @@ -28,10 +27,7 @@ public class LatestConfigTests extends AbstractSerializingTransformTestCase( - new HashSet<>(randomList(1, 10, () -> randomAlphaOfLengthBetween(1, 10)) - ) - ), + new ArrayList<>(randomUnique(() -> randomAlphaOfLengthBetween(1, 10), randomIntBetween(1, 10))), randomAlphaOfLengthBetween(1, 10) ); }