@@ -38,7 +38,6 @@ protected Collection<String> templatesToWaitFor() {
38
38
* The purpose of this test is to ensure that when a job is open through a rolling upgrade we upgrade the results
39
39
* index mappings when it is assigned to an upgraded node even if no other ML endpoint is called after the upgrade
40
40
*/
41
- @ AwaitsFix (bugUrl = "https://github.com/elastic/elasticsearch/issues/37763" )
42
41
public void testMappingsUpgrade () throws Exception {
43
42
44
43
switch (CLUSTER_TYPE ) {
@@ -65,6 +64,8 @@ private void createAndOpenTestJob() throws IOException {
65
64
Job .Builder job = new Job .Builder (JOB_ID );
66
65
job .setAnalysisConfig (analysisConfig );
67
66
job .setDataDescription (new DataDescription .Builder ());
67
+ // Use a custom index because other rolling upgrade tests meddle with the shared index
68
+ job .setResultsIndexName ("mappings-upgrade-test" );
68
69
69
70
Request putJob = new Request ("PUT" , "_ml/anomaly_detectors/" + JOB_ID );
70
71
putJob .setJsonEntity (Strings .toString (job .build ()));
@@ -85,7 +86,16 @@ private void assertUpgradedMappings() throws Exception {
85
86
86
87
Map <String , Object > responseLevel = entityAsMap (response );
87
88
assertNotNull (responseLevel );
88
- Map <String , Object > indexLevel = (Map <String , Object >) responseLevel .get (".ml-anomalies-shared" );
89
+ Map <String , Object > indexLevel = null ;
90
+ // The name of the concrete index underlying the results index alias may or may not have been changed
91
+ // by the upgrade process (depending on what other tests are being run and the order they're run in),
92
+ // so navigating to the next level of the tree must account for both cases
93
+ for (Map .Entry <String , Object > entry : responseLevel .entrySet ()) {
94
+ if (entry .getKey ().startsWith (".ml-anomalies-" ) && entry .getKey ().contains ("mappings-upgrade-test" )) {
95
+ indexLevel = (Map <String , Object >) entry .getValue ();
96
+ break ;
97
+ }
98
+ }
89
99
assertNotNull (indexLevel );
90
100
Map <String , Object > mappingsLevel = (Map <String , Object >) indexLevel .get ("mappings" );
91
101
assertNotNull (mappingsLevel );
0 commit comments