Skip to content

Commit f13ab6e

Browse files
Ensure IndicesOptions are mutated for GetInferenceFieldsActionRequestTests (#138163)
When `IndicesOptions` are mutated, we may produce `null`. The request constructor sets indices options to the default ones when the argument is `null`. Thus, if the original instance had the default `IndicesOptions` to begin with, we will end up with a mutation that is identical. This fixes this by generating a new random `IndicesOptions` object in the case above. Closed #138134
1 parent 469cd7d commit f13ab6e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/GetInferenceFieldsActionRequestTests.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,13 @@ protected GetInferenceFieldsAction.Request mutateInstance(GetInferenceFieldsActi
9090
instance.resolveWildcards(),
9191
instance.useDefaultFields(),
9292
instance.getQuery(),
93-
randomValueOtherThan(instance.getIndicesOptions(), GetInferenceFieldsActionRequestTests::randomIndicesOptions)
93+
randomValueOtherThan(instance.getIndicesOptions(), () -> {
94+
IndicesOptions newOptions = randomIndicesOptions();
95+
while (instance.getIndicesOptions() == IndicesOptions.DEFAULT && newOptions == null) {
96+
newOptions = randomIndicesOptions();
97+
}
98+
return newOptions;
99+
})
94100
);
95101
default -> throw new AssertionError("Invalid value");
96102
};

0 commit comments

Comments
 (0)