88
99import org .elasticsearch .ElasticsearchException ;
1010import org .elasticsearch .action .admin .cluster .snapshots .create .CreateSnapshotResponse ;
11- import org .elasticsearch .action .bulk .BulkRequest ;
12- import org .elasticsearch .action .bulk .BulkResponse ;
13- import org .elasticsearch .action .index .IndexRequest ;
1411import org .elasticsearch .client .Client ;
1512import org .elasticsearch .client .OriginSettingClient ;
1613import org .elasticsearch .cluster .metadata .IndexMetadata ;
2926import java .util .Locale ;
3027
3128import static org .elasticsearch .test .hamcrest .ElasticsearchAssertions .assertAcked ;
32- import static org .elasticsearch .test .hamcrest .ElasticsearchAssertions .assertHitCount ;
3329import static org .hamcrest .Matchers .containsString ;
3430import static org .hamcrest .Matchers .equalTo ;
35- import static org .hamcrest .Matchers .is ;
3631
3732public class SearchableSnapshotsSystemIndicesIntegTests extends BaseSearchableSnapshotsIntegTestCase {
3833
@@ -43,36 +38,17 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
4338 return plugins ;
4439 }
4540
46- public void testCannotMountSystemIndex () {
41+ public void testCannotMountSystemIndex () throws Exception {
4742 executeTest (TestSystemIndexPlugin .INDEX_NAME , new OriginSettingClient (client (), ClientHelper .SEARCHABLE_SNAPSHOTS_ORIGIN ));
4843 }
4944
50- public void testCannotMountSnapshotBlobCacheIndex () {
45+ public void testCannotMountSnapshotBlobCacheIndex () throws Exception {
5146 executeTest (SearchableSnapshotsConstants .SNAPSHOT_BLOB_CACHE_INDEX , client ());
5247 }
5348
54- private void executeTest (final String indexName , final Client client ) {
49+ private void executeTest (final String indexName , final Client client ) throws Exception {
5550 final boolean isHidden = randomBoolean ();
56- assertAcked (
57- client .admin ()
58- .indices ()
59- .prepareCreate (indexName )
60- .setSettings (Settings .builder ().put (IndexMetadata .SETTING_INDEX_HIDDEN , isHidden ).build ())
61- );
62-
63- final int nbDocs = scaledRandomIntBetween (0 , 100 );
64- if (nbDocs > 0 ) {
65- final BulkRequest bulkRequest = new BulkRequest ();
66- for (int i = 0 ; i < nbDocs ; i ++) {
67- IndexRequest indexRequest = new IndexRequest (indexName );
68- indexRequest .source ("value" , i );
69- bulkRequest .add (indexRequest );
70- }
71- final BulkResponse bulkResponse = client .bulk (bulkRequest ).actionGet ();
72- assertThat (bulkResponse .hasFailures (), is (false ));
73- }
74- flushAndRefresh (indexName );
75- assertHitCount (client .prepareSearch (indexName ).get (), nbDocs );
51+ createAndPopulateIndex (indexName , Settings .builder ().put (IndexMetadata .SETTING_INDEX_HIDDEN , isHidden ));
7652
7753 final String repositoryName = randomAlphaOfLength (10 ).toLowerCase (Locale .ROOT );
7854 createRepo (repositoryName );
0 commit comments