Skip to content

Commit

Permalink
Fix LogsDB challenge test (#111665)
Browse files Browse the repository at this point in the history
  • Loading branch information
lkts authored and mhl-b committed Aug 8, 2024
1 parent 47cab16 commit fb43737
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@
public class StandardVersusLogsIndexModeChallengeRestIT extends AbstractChallengeRestTest {
private final int numShards = randomBoolean() ? randomIntBetween(2, 5) : 0;
private final int numReplicas = randomBoolean() ? randomIntBetween(1, 3) : 0;
private final boolean fullyDynamicMapping = randomBoolean();

public StandardVersusLogsIndexModeChallengeRestIT() {
super("standard-apache-baseline", "logs-apache-contender", "baseline-template", "contender-template", 101, 101);
}

@Override
public void baselineMappings(XContentBuilder builder) throws IOException {
if (randomBoolean()) {
if (fullyDynamicMapping == false) {
builder.startObject()
.startObject("properties")

Expand Down Expand Up @@ -108,7 +109,7 @@ public void contenderMappings(XContentBuilder builder) throws IOException {
builder.startObject();
builder.field("subobjects", false);

if (randomBoolean()) {
if (fullyDynamicMapping == false) {
builder.startObject("properties")

.startObject("@timestamp")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,21 @@ private Optional<MatchResult> matchWithFieldSpecificMatcher(String fieldName, Li
}

var expectedFieldMapping = expectedNormalizedMapping.get(fieldName);
if (expectedFieldMapping == null || Objects.equals(actualFieldType, expectedFieldMapping.get("type")) == false) {
throw new IllegalStateException("Field type of a leaf field [" + fieldName + "] differs between expected and actual mapping");
if (expectedFieldMapping == null) {
throw new IllegalStateException("Leaf field [" + fieldName + "] is present in actual mapping but absent in expected mapping");
} else {
var expectedFieldType = expectedFieldMapping.get("type");
if (Objects.equals(actualFieldType, expectedFieldType) == false) {
throw new IllegalStateException(
"Leaf field ["
+ fieldName
+ "] has type ["
+ actualFieldType
+ "] in actual mapping but a different type ["
+ expectedFieldType
+ "] in expected mapping"
);
}
}

var fieldSpecificMatcher = fieldSpecificMatchers.get(actualFieldType);
Expand Down
6 changes: 0 additions & 6 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,6 @@ tests:
- class: org.elasticsearch.xpack.esql.analysis.VerifierTests
method: testMatchCommand
issue: https://github.com/elastic/elasticsearch/issues/111661
- class: org.elasticsearch.datastreams.logsdb.qa.StandardVersusLogsIndexModeChallengeRestIT
method: testMatchAllQuery
issue: https://github.com/elastic/elasticsearch/issues/111664
- class: org.elasticsearch.datastreams.logsdb.qa.StandardVersusLogsIndexModeChallengeRestIT
method: testTermsQuery
issue: https://github.com/elastic/elasticsearch/issues/111666

# Examples:
#
Expand Down

0 comments on commit fb43737

Please sign in to comment.