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 @@ -103,34 +103,41 @@ public void testMlIndicesBecomeHidden() throws Exception {
}
}
} else {
Map<String, Object> indexSettingsMap = contentAsMap(getMlIndicesSettings());
Map<String, Object> aliasesMap = contentAsMap(getMlAliases());

assertThat("Index settings map was: " + indexSettingsMap, indexSettingsMap, is(aMapWithSize(greaterThanOrEqualTo(4))));
for (Map.Entry<String, Object> e : indexSettingsMap.entrySet()) {
String indexName = e.getKey();
@SuppressWarnings("unchecked")
Map<String, Object> settings = (Map<String, Object>) e.getValue();
assertThat(settings, is(notNullValue()));
assertThat(
"Index " + indexName + " expected to be hidden but wasn't, settings = " + settings,
XContentMapValues.extractValue(settings, "settings", "index", "hidden"),
is(equalTo("true"))
);
}
// The 5 operations in MlInitializationService.makeMlInternalIndicesHidden() run sequentially, so might
// not all be finished when this test runs. The desired state should exist within a few seconds of startup,
// hence the assertBusy().
assertBusy(() -> {
Comment on lines +106 to +109
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the changes apart from the comment and the assertBusy() are just auto-formatting changes.

Map<String, Object> indexSettingsMap = contentAsMap(getMlIndicesSettings());
Map<String, Object> aliasesMap = contentAsMap(getMlAliases());

for (Tuple<List<String>, String> indexAndAlias : EXPECTED_INDEX_ALIAS_PAIRS) {
List<String> indices = indexAndAlias.v1();
String alias = indexAndAlias.v2();
assertThat(
indexAndAlias + " expected to be hidden but wasn't, aliasesMap = " + aliasesMap,
indices.stream()
.anyMatch(
index -> Boolean.TRUE.equals(XContentMapValues.extractValue(aliasesMap, index, "aliases", alias, "is_hidden"))
),
is(true)
);
}
assertThat("Index settings map was: " + indexSettingsMap, indexSettingsMap, is(aMapWithSize(greaterThanOrEqualTo(4))));
for (Map.Entry<String, Object> e : indexSettingsMap.entrySet()) {
String indexName = e.getKey();
@SuppressWarnings("unchecked")
Map<String, Object> settings = (Map<String, Object>) e.getValue();
assertThat(settings, is(notNullValue()));
assertThat(
"Index " + indexName + " expected to be hidden but wasn't, settings = " + settings,
XContentMapValues.extractValue(settings, "settings", "index", "hidden"),
is(equalTo("true"))
);
}

for (Tuple<List<String>, String> indexAndAlias : EXPECTED_INDEX_ALIAS_PAIRS) {
List<String> indices = indexAndAlias.v1();
String alias = indexAndAlias.v2();
assertThat(
indexAndAlias + " expected to be hidden but wasn't, aliasesMap = " + aliasesMap,
indices.stream()
.anyMatch(
index -> Boolean.TRUE.equals(
XContentMapValues.extractValue(aliasesMap, index, "aliases", alias, "is_hidden")
)
),
is(true)
);
}
});
}
}

Expand Down