Skip to content

Commit 3e173cb

Browse files
committed
use createAndPopulateIndex()
1 parent ae58433 commit 3e173cb

File tree

1 file changed

+4
-28
lines changed

1 file changed

+4
-28
lines changed

x-pack/plugin/searchable-snapshots/src/test/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsSystemIndicesIntegTests.java

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88

99
import org.elasticsearch.ElasticsearchException;
1010
import 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;
1411
import org.elasticsearch.client.Client;
1512
import org.elasticsearch.client.OriginSettingClient;
1613
import org.elasticsearch.cluster.metadata.IndexMetadata;
@@ -29,10 +26,8 @@
2926
import java.util.Locale;
3027

3128
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
32-
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
3329
import static org.hamcrest.Matchers.containsString;
3430
import static org.hamcrest.Matchers.equalTo;
35-
import static org.hamcrest.Matchers.is;
3631

3732
public 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

Comments
 (0)