Skip to content

Commit 9cfe679

Browse files
authored
Avoid using dynamic:strict with subobjects:false at root (#114247)
1 parent a83046a commit 9cfe679

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

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

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,22 @@ public DataSourceResponse.ObjectMappingParametersGenerator handle(DataSourceRequ
9898
return new DataSourceResponse.ObjectMappingParametersGenerator(() -> {
9999
var parameters = new HashMap<String, Object>();
100100

101-
if (request.parentSubobjects() == ObjectMapper.Subobjects.DISABLED) {
101+
// Changing subobjects from subobjects: false is not supported, but we can f.e. go from "true" to "false".
102+
// TODO enable subobjects: auto
103+
// It is disabled because it currently does not have auto flattening and that results in asserts being triggered when using
104+
// 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+
}
114+
115+
if (request.parentSubobjects() == ObjectMapper.Subobjects.DISABLED
116+
|| parameters.getOrDefault("subobjects", "true").equals("false")) {
102117
// "enabled: false" is not compatible with subobjects: false
103118
// changing "dynamic" from parent context is not compatible with subobjects: false
104119
// changing subobjects value is not compatible with subobjects: false
@@ -115,19 +130,6 @@ public DataSourceResponse.ObjectMappingParametersGenerator handle(DataSourceRequ
115130
if (ESTestCase.randomBoolean()) {
116131
parameters.put("enabled", ESTestCase.randomFrom("true", "false"));
117132
}
118-
// Changing subobjects from subobjects: false is not supported, but we can f.e. go from "true" to "false".
119-
// TODO enable subobjects: auto
120-
// It is disabled because it currently does not have auto flattening and that results in asserts being triggered when using
121-
// copy_to.
122-
if (ESTestCase.randomBoolean()) {
123-
parameters.put(
124-
"subobjects",
125-
ESTestCase.randomValueOtherThan(
126-
ObjectMapper.Subobjects.AUTO,
127-
() -> ESTestCase.randomFrom(ObjectMapper.Subobjects.values())
128-
).toString()
129-
);
130-
}
131133

132134
if (ESTestCase.randomBoolean()) {
133135
var value = request.isRoot() ? ESTestCase.randomFrom("none", "arrays") : ESTestCase.randomFrom("none", "arrays", "all");

0 commit comments

Comments
 (0)