From 2d4da7a206cb94ad8f344710ee811bd2e3624978 Mon Sep 17 00:00:00 2001 From: Przemko Robakowski Date: Mon, 5 Jul 2021 15:05:13 +0200 Subject: [PATCH] Fix ActionConfigStatsTests.testEqualsAndHashcode (#74907) Additional fixes for `ActionConfigStatsTests.testEqualsAndHashcode` Relates to #74849 --- .../xpack/core/ilm/ActionConfigStatsTests.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/ActionConfigStatsTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/ActionConfigStatsTests.java index 3645dcc787bc4..0f5b76297ec2f 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/ActionConfigStatsTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/ActionConfigStatsTests.java @@ -68,13 +68,16 @@ protected ActionConfigStats mutateInstance(ActionConfigStats instance) throws IO ActionConfigStats.Builder builder = ActionConfigStats.builder(instance); switch (between(0, 8)) { case 0: - builder.setAllocateNumberOfReplicas(randomIntBetween(0, 10000)); + int numberOfReplicas = randomValueOtherThan(instance.getAllocateNumberOfReplicas(), () -> randomIntBetween(0, 10000)); + builder.setAllocateNumberOfReplicas(numberOfReplicas); break; case 1: - builder.setForceMergeMaxNumberOfSegments(randomIntBetween(0, 10000)); + int numberOfSegments = randomValueOtherThan(instance.getForceMergeMaxNumberOfSegments(), () -> randomIntBetween(0, 10000)); + builder.setForceMergeMaxNumberOfSegments(numberOfSegments); break; case 2: - TimeValue randomAge = TimeValue.parseTimeValue(randomTimeValue(), "action_config_stats_tests"); + TimeValue randomAge = randomValueOtherThan(instance.getRolloverMaxAge(), + () -> TimeValue.parseTimeValue(randomTimeValue(), "action_config_stats_tests")); builder.setRolloverMaxAge(randomAge); break; case 3: @@ -89,7 +92,7 @@ protected ActionConfigStats mutateInstance(ActionConfigStats instance) throws IO builder.setRolloverMaxSize(randomMaxByteSize); break; case 6: - builder.setPriority(randomIntBetween(0, 50)); + builder.setPriority(randomValueOtherThan(instance.getSetPriorityPriority(), () -> randomIntBetween(0, 50))); break; case 7: ByteSizeValue randomPrimaryByteSize = ByteSizeValue.ofBytes(randomLongBetween(0, 1024L*1024L*1024L*50L));