Migrate createIndex().

This commit is contained in:
Andrew Raines 2013-09-23 17:04:54 -05:00
parent 26334a7a61
commit 917a3c3b9d
18 changed files with 56 additions and 44 deletions

View File

@ -75,7 +75,7 @@ public class MinimumMasterNodesTests extends AbstractIntegrationTest {
assertThat(state.nodes().size(), equalTo(2));
assertThat(state.metaData().indices().containsKey("test"), equalTo(false));
client().admin().indices().prepareCreate("test").execute().actionGet();
createIndex("test");
logger.info("--> indexing some data");
for (int i = 0; i < 100; i++) {
client().prepareIndex("test", "type1", Integer.toString(i)).setSource("field", "value").execute().actionGet();

View File

@ -59,7 +59,7 @@ public class NoMasterNodeTests extends AbstractIntegrationTest {
cluster().startNode(settings);
// start a second node, create an index, and then shut it down so we have no master block
cluster().startNode(settings);
client().admin().indices().prepareCreate("test").execute().actionGet();
createIndex("test");
client().admin().cluster().prepareHealth("test").setWaitForGreenStatus().execute().actionGet();
cluster().stopRandomNode();
assertThat(awaitBusy(new Predicate<Object>() {

View File

@ -59,8 +59,8 @@ public class AwarenessAllocationTests extends AbstractIntegrationTest {
cluster().startNode(ImmutableSettings.settingsBuilder().put(commonSettings).put("node.rack_id", "rack_1").build());
cluster().startNode(ImmutableSettings.settingsBuilder().put(commonSettings).put("node.rack_id", "rack_1").build());
client().admin().indices().prepareCreate("test1").execute().actionGet();
client().admin().indices().prepareCreate("test2").execute().actionGet();
createIndex("test1");
createIndex("test2");
ClusterHealthResponse health = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
assertThat(health.isTimedOut(), equalTo(false));

View File

@ -805,7 +805,7 @@ public class SimpleQueryTests extends AbstractIntegrationTest {
@Test
public void testBasicFilterById() throws Exception {
client().admin().indices().prepareCreate("test").execute().actionGet();
createIndex("test");
ensureGreen();
client().prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject()
@ -838,7 +838,7 @@ public class SimpleQueryTests extends AbstractIntegrationTest {
@Test
public void testBasicQueryById() throws Exception {
client().admin().indices().prepareCreate("test").execute().actionGet();
createIndex("test");
ensureGreen();
client().prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject()

View File

@ -103,7 +103,7 @@ public class ExplainActionTests extends AbstractIntegrationTest {
@SuppressWarnings("unchecked")
@Test
public void testExplainWithFields() throws Exception {
client().admin().indices().prepareCreate("test").execute().actionGet();
createIndex("test");
client().admin().cluster().prepareHealth("test").setWaitForGreenStatus().execute().actionGet();
client().prepareIndex("test", "test", "1")

View File

@ -43,7 +43,8 @@ public class IndexActionTests extends AbstractIntegrationTest {
@Test
public void testCreatedFlag() throws Exception {
createIndex("test"); ensureGreen();
createIndex("test");
ensureGreen();
IndexResponse indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_1").execute().actionGet();
assertTrue(indexResponse.isCreated());
@ -60,7 +61,8 @@ public class IndexActionTests extends AbstractIntegrationTest {
@Test
public void testCreatedFlagWithFlush() throws Exception {
createIndex("test"); ensureGreen();
createIndex("test");
ensureGreen();
IndexResponse indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_1").execute().actionGet();
assertTrue(indexResponse.isCreated());
@ -75,7 +77,8 @@ public class IndexActionTests extends AbstractIntegrationTest {
@Test
public void testCreatedFlagParallelExecution() throws Exception {
createIndex("test"); ensureGreen();
createIndex("test");
ensureGreen();
int threadCount = 20;
final int docCount = 300;
@ -106,7 +109,8 @@ public class IndexActionTests extends AbstractIntegrationTest {
@Test
public void testCreatedFlagWithExternalVersioning() throws Exception {
createIndex("test"); ensureGreen();
createIndex("test");
ensureGreen();
IndexResponse indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_1").setVersion(123)
.setVersionType(VersionType.EXTERNAL).execute().actionGet();
@ -115,7 +119,8 @@ public class IndexActionTests extends AbstractIntegrationTest {
@Test
public void testCreateFlagWithBulk() {
createIndex("test"); ensureGreen();
createIndex("test");
ensureGreen();
BulkResponse bulkResponse = client().prepareBulk().add(client().prepareIndex("test", "type", "1").setSource("field1", "value1_1")).execute().actionGet();
assertThat(bulkResponse.hasFailures(), equalTo(false));

View File

@ -34,7 +34,7 @@ public class IgnoreIndicesTests extends AbstractIntegrationTest {
@Test
public void testMissing() throws Exception {
client().admin().indices().prepareCreate("test1").execute().actionGet();
createIndex("test1");
ensureYellow();
try {
@ -129,7 +129,7 @@ public class IgnoreIndicesTests extends AbstractIntegrationTest {
client().admin().indices().prepareValidateQuery("test1", "test2").setIgnoreIndices(IgnoreIndices.MISSING)
.execute().actionGet();
client().admin().indices().prepareCreate("test2").execute().actionGet();
createIndex("test2");
ensureYellow();

View File

@ -45,7 +45,7 @@ public class AnalyzeActionTests extends AbstractIntegrationTest {
// ignore
}
client().admin().indices().prepareCreate("test").execute().actionGet();
createIndex("test");
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
for (int i = 0; i < 10; i++) {
@ -65,7 +65,7 @@ public class AnalyzeActionTests extends AbstractIntegrationTest {
} catch (Exception e) {
// ignore
}
client().admin().indices().prepareCreate("test").execute().actionGet();
createIndex("test");
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
client().prepareIndex("test", "test", "1")
@ -100,7 +100,7 @@ public class AnalyzeActionTests extends AbstractIntegrationTest {
@Test
public void analyzerWithFieldOrTypeTests() throws Exception {
client().admin().indices().prepareCreate("test").execute().actionGet();
createIndex("test");
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
client().admin().indices().preparePutMapping("test")

View File

@ -37,7 +37,7 @@ public class UpdateSettingsTests extends AbstractIntegrationTest {
@Test
public void testOpenCloseUpdateSettings() throws Exception {
client().admin().indices().prepareCreate("test").execute().actionGet();
createIndex("test");
try {
client().admin().indices().prepareUpdateSettings("test")
@ -100,4 +100,4 @@ public class UpdateSettingsTests extends AbstractIntegrationTest {
assertThrows(client().prepareIndex("test", "type", "1").setSource("f", 3).setVersion(4), VersionConflictEngineException.class); // delete is should not be in cache
}
}
}

View File

@ -47,8 +47,8 @@ public class SimpleIndexStatsTests extends AbstractIntegrationTest {
@Test
public void simpleStats() throws Exception {
// rely on 1 replica for this tests
client().admin().indices().prepareCreate("test1").execute().actionGet();
client().admin().indices().prepareCreate("test2").execute().actionGet();
createIndex("test1");
createIndex("test2");
ClusterHealthResponse clusterHealthResponse = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
assertThat(clusterHealthResponse.isTimedOut(), equalTo(false));
@ -150,8 +150,8 @@ public class SimpleIndexStatsTests extends AbstractIntegrationTest {
@Test
public void testMergeStats() {
// rely on 1 replica for this tests
client().admin().indices().prepareCreate("test1").execute().actionGet();
// rely on 1 replica for this tests
createIndex("test1");
ClusterHealthResponse clusterHealthResponse = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
assertThat(clusterHealthResponse.isTimedOut(), equalTo(false));
@ -189,9 +189,9 @@ public class SimpleIndexStatsTests extends AbstractIntegrationTest {
@Test
public void testAllFlags() throws Exception {
// rely on 1 replica for this tests
client().admin().indices().prepareCreate("test1").execute().actionGet();
client().admin().indices().prepareCreate("test2").execute().actionGet();
// rely on 1 replica for this tests
createIndex("test1");
createIndex("test2");
ClusterHealthResponse clusterHealthResponse = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
assertThat(clusterHealthResponse.isTimedOut(), equalTo(false));

View File

@ -155,7 +155,7 @@ public class SimpleIndicesWarmerTests extends AbstractIntegrationTest {
@Test
public void deleteNonExistentIndexWarmerTest() {
client().admin().indices().prepareCreate("test").execute().actionGet();
createIndex("test");
try {
client().admin().indices().prepareDeleteWarmer().setIndices("test").setName("foo").execute().actionGet(1000);

View File

@ -40,7 +40,7 @@ public class FullRollingRestartTests extends AbstractIntegrationTest {
@Slow
public void testFullRollingRestart() throws Exception {
cluster().startNode();
client().admin().indices().prepareCreate("test").execute().actionGet();
createIndex("test");
for (int i = 0; i < 1000; i++) {
client().prepareIndex("test", "type1", Long.toString(i))

View File

@ -99,7 +99,7 @@ public class SimpleRoutingTests extends AbstractIntegrationTest {
@Test
public void testSimpleSearchRouting() {
client().admin().indices().prepareCreate("test").execute().actionGet();
createIndex("test");
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
logger.info("--> indexing with id [1], and routing [0]");

View File

@ -53,7 +53,7 @@ public class SearchSourceCompressTests extends AbstractIntegrationTest {
} catch (Exception e) {
// ignore
}
client().admin().indices().prepareCreate("test").execute().actionGet();
createIndex("test");
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")

View File

@ -585,8 +585,8 @@ public class HighlighterSearchTests extends AbstractIntegrationTest {
@Test
public void testGlobalHighlightingSettingsOverriddenAtFieldLevel() {
client().admin().indices().prepareCreate("test").execute().actionGet();
client().admin().cluster().prepareHealth("test").setWaitForGreenStatus().execute().actionGet();
createIndex("test");
ensureGreen();
client().prepareIndex("test", "type1")
.setSource("field1", "this is a test", "field2", "this is another test")
@ -610,7 +610,7 @@ public class HighlighterSearchTests extends AbstractIntegrationTest {
@Test
public void testHighlightingOnWildcardFields() throws Exception {
client().admin().indices().prepareCreate("test").execute().actionGet();
createIndex("test");
client().admin().cluster().prepareHealth("test").setWaitForGreenStatus().execute().actionGet();
client().prepareIndex("test", "type1")
@ -633,7 +633,7 @@ public class HighlighterSearchTests extends AbstractIntegrationTest {
@Test
public void testPlainHighlighter() throws Exception {
client().admin().indices().prepareCreate("test").execute().actionGet();
createIndex("test");
client().admin().cluster().prepareHealth("test").setWaitForGreenStatus().execute().actionGet();
client().prepareIndex("test", "type1")

View File

@ -75,7 +75,7 @@ public class SearchPreferenceTests extends AbstractIntegrationTest {
@Test
public void simplePreferenceTests() throws Exception {
client().admin().indices().prepareCreate("test").execute().actionGet();
createIndex("test");
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
client().prepareIndex("test", "type1").setSource("field1", "value1").execute().actionGet();
@ -96,4 +96,4 @@ public class SearchPreferenceTests extends AbstractIntegrationTest {
searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setPreference("1234").execute().actionGet();
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
}
}
}

View File

@ -1101,7 +1101,7 @@ public class SimpleQueryTests extends AbstractIntegrationTest {
@Test
public void testBasicFilterById() throws Exception {
client().admin().indices().prepareCreate("test").execute().actionGet();
createIndex("test");
ensureGreen();
client().prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject()
@ -1153,7 +1153,7 @@ public class SimpleQueryTests extends AbstractIntegrationTest {
@Test
public void testBasicQueryById() throws Exception {
client().admin().indices().prepareCreate("test").execute().actionGet();
createIndex("test");
ensureGreen();
client().prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject()

View File

@ -43,9 +43,11 @@ public class SimpleVersioningTests extends AbstractIntegrationTest {
@Test
public void testExternalVersioningInitialDelete() throws Exception {
createIndex("test"); ensureGreen();
createIndex("test");
ensureGreen();
// Note - external version doesn't throw version conflicts on deletes of non existent records. This is different from internal versioning
DeleteResponse deleteResponse = client().prepareDelete("test", "type", "1").setVersion(17).setVersionType(VersionType.EXTERNAL).execute().actionGet();
assertThat(deleteResponse.isNotFound(), equalTo(true));
@ -62,7 +64,8 @@ public class SimpleVersioningTests extends AbstractIntegrationTest {
@Test
public void testExternalVersioning() throws Exception {
createIndex("test"); ensureGreen();
createIndex("test");
ensureGreen();
IndexResponse indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_1").setVersion(12).setVersionType(VersionType.EXTERNAL).execute().actionGet();
assertThat(indexResponse.getVersion(), equalTo(12l));
@ -123,7 +126,8 @@ public class SimpleVersioningTests extends AbstractIntegrationTest {
@Test
public void testInternalVersioningInitialDelete() throws Exception {
createIndex("test"); ensureGreen();
createIndex("test");
ensureGreen();
assertThrows(client().prepareDelete("test", "type", "1").setVersion(17).execute(),
VersionConflictEngineException.class);
@ -136,7 +140,8 @@ public class SimpleVersioningTests extends AbstractIntegrationTest {
@Test
public void testInternalVersioning() throws Exception {
createIndex("test"); ensureGreen();
createIndex("test");
ensureGreen();
IndexResponse indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_1").execute().actionGet();
assertThat(indexResponse.getVersion(), equalTo(1l));
@ -203,7 +208,8 @@ public class SimpleVersioningTests extends AbstractIntegrationTest {
@Test
public void testSimpleVersioningWithFlush() throws Exception {
createIndex("test"); ensureGreen();
createIndex("test");
ensureGreen();
IndexResponse indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_1").execute().actionGet();
assertThat(indexResponse.getVersion(), equalTo(1l));
@ -242,7 +248,8 @@ public class SimpleVersioningTests extends AbstractIntegrationTest {
@Test
public void testVersioningWithBulk() {
createIndex("test"); ensureGreen();
createIndex("test");
ensureGreen();
BulkResponse bulkResponse = client().prepareBulk().add(client().prepareIndex("test", "type", "1").setSource("field1", "value1_1")).execute().actionGet();
assertThat(bulkResponse.hasFailures(), equalTo(false));