8
8
9
9
package org .elasticsearch .action .bulk ;
10
10
11
+ import org .elasticsearch .action .support .AutoCreateIndex ;
11
12
import org .elasticsearch .common .settings .Settings ;
12
13
import org .elasticsearch .common .xcontent .XContentType ;
14
+ import org .elasticsearch .index .IndexNotFoundException ;
13
15
import org .elasticsearch .test .ESIntegTestCase ;
14
16
import org .elasticsearch .test .ESIntegTestCase .ClusterScope ;
15
17
import org .elasticsearch .test .ESIntegTestCase .Scope ;
16
18
19
+ import static org .elasticsearch .test .hamcrest .ElasticsearchAssertions .assertAcked ;
17
20
import static org .hamcrest .Matchers .equalTo ;
21
+ import static org .hamcrest .Matchers .instanceOf ;
18
22
19
23
@ ClusterScope (scope = Scope .TEST , numDataNodes = 0 )
20
24
public class BulkProcessorClusterSettingsIT extends ESIntegTestCase {
@@ -41,4 +45,12 @@ public void testBulkProcessorAutoCreateRestrictions() throws Exception {
41
45
equalTo ("[wontwork] IndexNotFoundException[no such index [wontwork] and [action.auto_create_index] is [false]]" ));
42
46
assertFalse ("Operation on existing index should succeed" , responses [2 ].isFailed ());
43
47
}
48
+
49
+ public void testIndexWithDisabledAutoCreateIndex () {
50
+ assertAcked (client ().admin ().cluster ().prepareUpdateSettings ().setTransientSettings (Settings .builder ()
51
+ .put (AutoCreateIndex .AUTO_CREATE_INDEX_SETTING .getKey (), randomFrom ("-*" , "+.*" )).build ()).get ());
52
+ final BulkItemResponse itemResponse =
53
+ client ().prepareBulk ().add (client ().prepareIndex ("test-index" , "type1" ).setSource ("foo" , "bar" )).get ().getItems ()[0 ];
54
+ assertThat (itemResponse .getFailure ().getCause (), instanceOf (IndexNotFoundException .class ));
55
+ }
44
56
}
0 commit comments