Skip to content
Merged
Changes from all 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 @@ -52,6 +52,7 @@ public void testMappingsUpgrade() throws Exception {
break;
case UPGRADED:
assertUpgradedResultsMappings();
assertUpgradedAnnotationsMappings();
closeAndReopenTestJob();
assertUpgradedConfigMappings();
IndexMappingTemplateAsserter.assertMlMappingsMatchTemplates(client());
Expand Down Expand Up @@ -126,6 +127,37 @@ private void assertUpgradedResultsMappings() throws Exception {
});
}

@SuppressWarnings("unchecked")
private void assertUpgradedAnnotationsMappings() throws Exception {

assertBusy(() -> {
Request getMappings = new Request("GET", ".ml-annotations-write/_mappings");
Response response = client().performRequest(getMappings);

Map<String, Object> responseLevel = entityAsMap(response);
assertNotNull(responseLevel);
Map<String, Object> indexLevel = null;
// The name of the concrete index underlying the annotations index write alias may or may not have been
// changed by the upgrade process (depending on what other tests are being run and the order they're run
// in), so navigating to the next level of the tree must account for both cases
for (Map.Entry<String, Object> entry : responseLevel.entrySet()) {
if (entry.getKey().startsWith(".ml-annotations-")) {
indexLevel = (Map<String, Object>) entry.getValue();
break;
}
}
assertNotNull(indexLevel);

assertEquals(Version.CURRENT.toString(), extractValue("mappings._meta.version", indexLevel));

// TODO: as the years go by, the field we assert on here should be changed
// to the most recent field we've added that would be incorrectly mapped by dynamic
// mappings, for example a field we want to be "keyword" incorrectly mapped as "text"
assertEquals("Incorrect type for event in " + responseLevel, "keyword",
extractValue("mappings.properties.event.type", indexLevel));
});
}

@SuppressWarnings("unchecked")
private void assertUpgradedConfigMappings() throws Exception {

Expand Down