Skip to content

A random-random test for time-series data #132556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public FieldDataGenerator generator(String fieldName, DataSource dataSource) {
case IP -> new IpFieldDataGenerator(dataSource);
case CONSTANT_KEYWORD -> new ConstantKeywordFieldDataGenerator();
case WILDCARD -> new WildcardFieldDataGenerator(dataSource);
default -> null;
case PASSTHROUGH -> throw new IllegalArgumentException("Passthrough field type does not have a default generator");
};
}

Expand All @@ -103,7 +103,8 @@ public static FieldType tryParse(String name) {
case "ip" -> FieldType.IP;
case "constant_keyword" -> FieldType.CONSTANT_KEYWORD;
case "wildcard" -> FieldType.WILDCARD;
default -> null;
case "passthrough" -> FieldType.PASSTHROUGH;
default -> throw new IllegalArgumentException("Unknown field type: " + name);
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ public Mapping generate(Template template) {
rawMapping.put("_doc", topLevelMappingParameters);

if (specification.fullyDynamicMapping() == false) {
// Has to be "true" for fully dynamic mapping
topLevelMappingParameters.remove("dynamic");

return new Mapping(rawMapping, lookup);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public DataSourceResponse.LeafMappingParametersGenerator handle(DataSourceReques
case IP -> ipMapping();
case CONSTANT_KEYWORD -> constantKeywordMapping();
case WILDCARD -> wildcardMapping();
default -> throw new IllegalArgumentException("Unsupported field type: " + fieldType);
case PASSTHROUGH -> throw new IllegalArgumentException("Unsupported field type: " + fieldType);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,14 @@ public String generateFieldName() {
// UNSIGNED_LONG is excluded because it is mapped as long
// and values larger than long fail to parse.
private static final Set<FieldType> EXCLUDED_FROM_DYNAMIC_MAPPING = Set.of(FieldType.UNSIGNED_LONG, FieldType.PASSTHROUGH);
private static final Set<FieldType> ALLOWED_FIELD_TYPES = Arrays.stream(FieldType.values())
.filter(fieldType -> EXCLUDED_FROM_DYNAMIC_MAPPING.contains(fieldType) == false)
.collect(Collectors.toSet());

@Override
public DataSourceResponse.FieldTypeGenerator handle(DataSourceRequest.FieldTypeGenerator request) {
return new DataSourceResponse.FieldTypeGenerator(() -> {
// All field types minus the excluded ones.
var fieldTypes = Arrays.stream(FieldType.values())
.filter(fieldType -> EXCLUDED_FROM_DYNAMIC_MAPPING.contains(fieldType) == false)
.collect(Collectors.toSet());
var fieldType = ESTestCase.randomFrom(fieldTypes);
var fieldType = ESTestCase.randomFrom(ALLOWED_FIELD_TYPES);
return new DataSourceResponse.FieldTypeGenerator.FieldTypeInfo(fieldType.toString());
});
}
Expand Down
Loading