Skip to content

Commit 1530927

Browse files
authored
Don't generate invalid combination of subobjects parameter in logsdb tests (#114265) (#114341)
(cherry picked from commit 965265a) # Conflicts: # muted-tests.yml
1 parent a9d2aec commit 1530927

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

test/framework/src/main/java/org/elasticsearch/logsdb/datageneration/datasource/DefaultMappingParametersHandler.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,12 @@ public DataSourceResponse.ObjectMappingParametersGenerator handle(DataSourceRequ
102102
// TODO enable subobjects: auto
103103
// It is disabled because it currently does not have auto flattening and that results in asserts being triggered when using
104104
// copy_to.
105-
if (ESTestCase.randomBoolean()) {
106-
parameters.put(
107-
"subobjects",
108-
ESTestCase.randomValueOtherThan(
109-
ObjectMapper.Subobjects.AUTO,
110-
() -> ESTestCase.randomFrom(ObjectMapper.Subobjects.values())
111-
).toString()
112-
);
113-
}
105+
var subobjects = ESTestCase.randomValueOtherThan(
106+
ObjectMapper.Subobjects.AUTO,
107+
() -> ESTestCase.randomFrom(ObjectMapper.Subobjects.values())
108+
);
114109

115-
if (request.parentSubobjects() == ObjectMapper.Subobjects.DISABLED
116-
|| parameters.getOrDefault("subobjects", "true").equals("false")) {
110+
if (request.parentSubobjects() == ObjectMapper.Subobjects.DISABLED || subobjects == ObjectMapper.Subobjects.DISABLED) {
117111
// "enabled: false" is not compatible with subobjects: false
118112
// changing "dynamic" from parent context is not compatible with subobjects: false
119113
// changing subobjects value is not compatible with subobjects: false
@@ -124,6 +118,9 @@ public DataSourceResponse.ObjectMappingParametersGenerator handle(DataSourceRequ
124118
return parameters;
125119
}
126120

121+
if (ESTestCase.randomBoolean()) {
122+
parameters.put("subobjects", subobjects.toString());
123+
}
127124
if (ESTestCase.randomBoolean()) {
128125
parameters.put("dynamic", ESTestCase.randomFrom("true", "false", "strict", "runtime"));
129126
}

0 commit comments

Comments
 (0)