@@ -183,30 +183,36 @@ public void testExplainLifecycle() throws Exception {
183183 createIndex ("squash" , Settings .EMPTY );
184184
185185 ExplainLifecycleRequest req = new ExplainLifecycleRequest ("foo-01" , "baz-01" , "squash" );
186- ExplainLifecycleResponse response = execute (req , highLevelClient ().indexLifecycle ()::explainLifecycle ,
186+ // Occasionally the explain is so fast that the indices have not yet left the "new" phase,
187+ // so we assertBusy here in the event that they haven't progressed to the "hot" phase yet.
188+ assertBusy (() -> {
189+ ExplainLifecycleResponse response = execute (req , highLevelClient ().indexLifecycle ()::explainLifecycle ,
187190 highLevelClient ().indexLifecycle ()::explainLifecycleAsync );
188- Map <String , IndexLifecycleExplainResponse > indexResponses = response .getIndexResponses ();
189- assertEquals (3 , indexResponses .size ());
190- IndexLifecycleExplainResponse fooResponse = indexResponses .get ("foo-01" );
191- assertNotNull (fooResponse );
192- assertTrue (fooResponse .managedByILM ());
193- assertEquals ("foo-01" , fooResponse .getIndex ());
194- assertEquals ("hot" , fooResponse .getPhase ());
195- assertEquals ("rollover" , fooResponse .getAction ());
196- assertEquals ("check-rollover-ready" , fooResponse .getStep ());
197- assertEquals (new PhaseExecutionInfo (policy .getName (), new Phase ("" , hotPhase .getMinimumAge (), hotPhase .getActions ()),
191+ Map <String , IndexLifecycleExplainResponse > indexResponses = response .getIndexResponses ();
192+ assertEquals (3 , indexResponses .size ());
193+
194+ IndexLifecycleExplainResponse squashResponse = indexResponses .get ("squash" );
195+ assertNotNull (squashResponse );
196+ assertFalse (squashResponse .managedByILM ());
197+ assertEquals ("squash" , squashResponse .getIndex ());
198+
199+ IndexLifecycleExplainResponse fooResponse = indexResponses .get ("foo-01" );
200+ assertNotNull (fooResponse );
201+ assertTrue (fooResponse .managedByILM ());
202+ assertEquals ("foo-01" , fooResponse .getIndex ());
203+ assertEquals ("hot" , fooResponse .getPhase ());
204+ assertEquals ("rollover" , fooResponse .getAction ());
205+ assertEquals ("check-rollover-ready" , fooResponse .getStep ());
206+ assertEquals (new PhaseExecutionInfo (policy .getName (), new Phase ("" , hotPhase .getMinimumAge (), hotPhase .getActions ()),
198207 1L , expectedPolicyModifiedDate ), fooResponse .getPhaseExecutionInfo ());
199- IndexLifecycleExplainResponse bazResponse = indexResponses .get ("baz-01" );
200- assertNotNull (bazResponse );
201- assertTrue (bazResponse .managedByILM ());
202- assertEquals ("baz-01" , bazResponse .getIndex ());
203- assertEquals ("hot" , bazResponse .getPhase ());
204- assertEquals ("rollover" , bazResponse .getAction ());
205- assertEquals ("check-rollover-ready" , bazResponse .getStep ());
206- IndexLifecycleExplainResponse squashResponse = indexResponses .get ("squash" );
207- assertNotNull (squashResponse );
208- assertFalse (squashResponse .managedByILM ());
209- assertEquals ("squash" , squashResponse .getIndex ());
208+ IndexLifecycleExplainResponse bazResponse = indexResponses .get ("baz-01" );
209+ assertNotNull (bazResponse );
210+ assertTrue (bazResponse .managedByILM ());
211+ assertEquals ("baz-01" , bazResponse .getIndex ());
212+ assertEquals ("hot" , bazResponse .getPhase ());
213+ assertEquals ("rollover" , bazResponse .getAction ());
214+ assertEquals ("check-rollover-ready" , bazResponse .getStep ());
215+ });
210216 }
211217
212218 public void testDeleteLifecycle () throws IOException {
0 commit comments