Skip to content

[TEST] Fix MlMappingsUpgradeIT testMappingsUpgrade #37769

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

Merged
merged 2 commits into from
Jan 27, 2019
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 @@ -38,7 +38,6 @@ protected Collection<String> templatesToWaitFor() {
* The purpose of this test is to ensure that when a job is open through a rolling upgrade we upgrade the results
* index mappings when it is assigned to an upgraded node even if no other ML endpoint is called after the upgrade
*/
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/37763")
public void testMappingsUpgrade() throws Exception {

switch (CLUSTER_TYPE) {
Expand All @@ -65,6 +64,8 @@ private void createAndOpenTestJob() throws IOException {
Job.Builder job = new Job.Builder(JOB_ID);
job.setAnalysisConfig(analysisConfig);
job.setDataDescription(new DataDescription.Builder());
// Use a custom index because other rolling upgrade tests meddle with the shared index
job.setResultsIndexName("mappings-upgrade-test");

Request putJob = new Request("PUT", "_ml/anomaly_detectors/" + JOB_ID);
putJob.setJsonEntity(Strings.toString(job.build()));
Expand All @@ -85,7 +86,16 @@ private void assertUpgradedMappings() throws Exception {

Map<String, Object> responseLevel = entityAsMap(response);
assertNotNull(responseLevel);
Map<String, Object> indexLevel = (Map<String, Object>) responseLevel.get(".ml-anomalies-shared");
Map<String, Object> indexLevel = null;
// The name of the concrete index underlying the results index 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-anomalies-") && entry.getKey().contains("mappings-upgrade-test")) {
indexLevel = (Map<String, Object>) entry.getValue();
break;
}
}
assertNotNull(indexLevel);
Map<String, Object> mappingsLevel = (Map<String, Object>) indexLevel.get("mappings");
assertNotNull(mappingsLevel);
Expand Down