@@ -83,9 +83,10 @@ public void testHandleSpaces() { // see #21449
8383 public void testAutoCreationDisabled () {
8484 Settings settings = Settings .builder ().put (AutoCreateIndex .AUTO_CREATE_INDEX_SETTING .getKey (), false ).build ();
8585 AutoCreateIndex autoCreateIndex = newAutoCreateIndex (settings );
86+ String randomIndex = randomAlphaOfLengthBetween (1 , 10 );
8687 IndexNotFoundException e = expectThrows (IndexNotFoundException .class , () ->
87- autoCreateIndex .shouldAutoCreate (randomAlphaOfLengthBetween ( 1 , 10 ) , buildClusterState ()));
88- assertEquals ("no such index and [action.auto_create_index] is [false]" , e .getMessage ());
88+ autoCreateIndex .shouldAutoCreate (randomIndex , buildClusterState ()));
89+ assertEquals ("no such index [" + randomIndex + "] and [action.auto_create_index] is [false]" , e .getMessage ());
8990 }
9091
9192 public void testAutoCreationEnabled () {
@@ -207,14 +208,15 @@ private AutoCreateIndex newAutoCreateIndex(Settings settings) {
207208 private void expectNotMatch (ClusterState clusterState , AutoCreateIndex autoCreateIndex , String index ) {
208209 IndexNotFoundException e = expectThrows (IndexNotFoundException .class , () ->
209210 autoCreateIndex .shouldAutoCreate (index , clusterState ));
210- assertEquals ("no such index and [action.auto_create_index] ([" + autoCreateIndex .getAutoCreate () + "]) doesn't match" ,
211- e .getMessage ());
211+ assertEquals (
212+ "no such index [" + index + "] and [action.auto_create_index] ([" + autoCreateIndex .getAutoCreate () + "]) doesn't match" ,
213+ e .getMessage ());
212214 }
213215
214216 private void expectForbidden (ClusterState clusterState , AutoCreateIndex autoCreateIndex , String index , String forbiddingPattern ) {
215217 IndexNotFoundException e = expectThrows (IndexNotFoundException .class , () ->
216218 autoCreateIndex .shouldAutoCreate (index , clusterState ));
217- assertEquals ("no such index and [action.auto_create_index] contains [" + forbiddingPattern
219+ assertEquals ("no such index [" + index + "] and [action.auto_create_index] contains [" + forbiddingPattern
218220 + "] which forbids automatic creation of the index" , e .getMessage ());
219221 }
220222}
0 commit comments