[TEST] add explicit options to no master tests
This commit is contained in:
parent
5be8aecd10
commit
9d79848998
|
@ -83,6 +83,13 @@ public class NoMasterNodeTests extends ElasticsearchIntegrationTest {
|
||||||
assertThat(e.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE));
|
assertThat(e.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
client().prepareGet("no_index", "type1", "1").execute().actionGet();
|
||||||
|
fail("Expected ClusterBlockException");
|
||||||
|
} catch (ClusterBlockException | MasterNotDiscoveredException e) {
|
||||||
|
assertThat(e.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE));
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
client().prepareMultiGet().add("test", "type1", "1").execute().actionGet();
|
client().prepareMultiGet().add("test", "type1", "1").execute().actionGet();
|
||||||
fail("Expected ClusterBlockException");
|
fail("Expected ClusterBlockException");
|
||||||
|
@ -90,6 +97,13 @@ public class NoMasterNodeTests extends ElasticsearchIntegrationTest {
|
||||||
assertThat(e.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE));
|
assertThat(e.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
client().prepareMultiGet().add("no_index", "type1", "1").execute().actionGet();
|
||||||
|
fail("Expected ClusterBlockException");
|
||||||
|
} catch (ClusterBlockException | MasterNotDiscoveredException e) {
|
||||||
|
assertThat(e.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE));
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PercolateSourceBuilder percolateSource = new PercolateSourceBuilder();
|
PercolateSourceBuilder percolateSource = new PercolateSourceBuilder();
|
||||||
percolateSource.percolateDocument().setDoc(new HashMap());
|
percolateSource.percolateDocument().setDoc(new HashMap());
|
||||||
|
@ -101,6 +115,17 @@ public class NoMasterNodeTests extends ElasticsearchIntegrationTest {
|
||||||
assertThat(e.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE));
|
assertThat(e.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
PercolateSourceBuilder percolateSource = new PercolateSourceBuilder();
|
||||||
|
percolateSource.percolateDocument().setDoc(new HashMap());
|
||||||
|
client().preparePercolate()
|
||||||
|
.setIndices("no_index").setDocumentType("type1")
|
||||||
|
.setSource(percolateSource).execute().actionGet();
|
||||||
|
fail("Expected ClusterBlockException");
|
||||||
|
} catch (ClusterBlockException | MasterNotDiscoveredException e) {
|
||||||
|
assertThat(e.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE));
|
||||||
|
}
|
||||||
|
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
client().prepareUpdate("test", "type1", "1").setScript("test script", ScriptService.ScriptType.INLINE).setTimeout(timeout).execute().actionGet();
|
client().prepareUpdate("test", "type1", "1").setScript("test script", ScriptService.ScriptType.INLINE).setTimeout(timeout).execute().actionGet();
|
||||||
|
@ -110,6 +135,15 @@ public class NoMasterNodeTests extends ElasticsearchIntegrationTest {
|
||||||
assertThat(e.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE));
|
assertThat(e.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
now = System.currentTimeMillis();
|
||||||
|
try {
|
||||||
|
client().prepareUpdate("no_index", "type1", "1").setScript("test script", ScriptService.ScriptType.INLINE).setTimeout(timeout).execute().actionGet();
|
||||||
|
fail("Expected ClusterBlockException");
|
||||||
|
} catch (ClusterBlockException | MasterNotDiscoveredException e) {
|
||||||
|
assertThat(System.currentTimeMillis() - now, greaterThan(timeout.millis() - 50));
|
||||||
|
assertThat(e.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE));
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
client().admin().indices().prepareAnalyze("test", "this is a test").execute().actionGet();
|
client().admin().indices().prepareAnalyze("test", "this is a test").execute().actionGet();
|
||||||
fail("Expected ClusterBlockException");
|
fail("Expected ClusterBlockException");
|
||||||
|
@ -117,6 +151,13 @@ public class NoMasterNodeTests extends ElasticsearchIntegrationTest {
|
||||||
assertThat(e.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE));
|
assertThat(e.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
client().admin().indices().prepareAnalyze("no_index", "this is a test").execute().actionGet();
|
||||||
|
fail("Expected ClusterBlockException");
|
||||||
|
} catch (ClusterBlockException | MasterNotDiscoveredException e) {
|
||||||
|
assertThat(e.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE));
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
client().prepareCount("test").execute().actionGet();
|
client().prepareCount("test").execute().actionGet();
|
||||||
fail("Expected ClusterBlockException");
|
fail("Expected ClusterBlockException");
|
||||||
|
@ -124,6 +165,13 @@ public class NoMasterNodeTests extends ElasticsearchIntegrationTest {
|
||||||
assertThat(e.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE));
|
assertThat(e.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
client().prepareCount("no_index").execute().actionGet();
|
||||||
|
fail("Expected ClusterBlockException");
|
||||||
|
} catch (ClusterBlockException | MasterNotDiscoveredException e) {
|
||||||
|
assertThat(e.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE));
|
||||||
|
}
|
||||||
|
|
||||||
now = System.currentTimeMillis();
|
now = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
client().prepareIndex("test", "type1", "1").setSource(XContentFactory.jsonBuilder().startObject().endObject()).setTimeout(timeout).execute().actionGet();
|
client().prepareIndex("test", "type1", "1").setSource(XContentFactory.jsonBuilder().startObject().endObject()).setTimeout(timeout).execute().actionGet();
|
||||||
|
@ -133,6 +181,15 @@ public class NoMasterNodeTests extends ElasticsearchIntegrationTest {
|
||||||
assertThat(e.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE));
|
assertThat(e.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
now = System.currentTimeMillis();
|
||||||
|
try {
|
||||||
|
client().prepareIndex("no_index", "type1", "1").setSource(XContentFactory.jsonBuilder().startObject().endObject()).setTimeout(timeout).execute().actionGet();
|
||||||
|
fail("Expected ClusterBlockException");
|
||||||
|
} catch (ClusterBlockException | MasterNotDiscoveredException e) {
|
||||||
|
assertThat(System.currentTimeMillis() - now, greaterThan(timeout.millis() - 50));
|
||||||
|
assertThat(e.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE));
|
||||||
|
}
|
||||||
|
|
||||||
now = System.currentTimeMillis();
|
now = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
BulkRequestBuilder bulkRequestBuilder = client().prepareBulk();
|
BulkRequestBuilder bulkRequestBuilder = client().prepareBulk();
|
||||||
|
@ -142,15 +199,36 @@ public class NoMasterNodeTests extends ElasticsearchIntegrationTest {
|
||||||
bulkRequestBuilder.get();
|
bulkRequestBuilder.get();
|
||||||
fail("Expected ClusterBlockException");
|
fail("Expected ClusterBlockException");
|
||||||
} catch (ClusterBlockException | MasterNotDiscoveredException e) {
|
} catch (ClusterBlockException | MasterNotDiscoveredException e) {
|
||||||
if (autoCreateIndex) {
|
// today, we clear the metadata on when there is no master, so it will go through the auto create logic and
|
||||||
// if its auto create index, the timeout will be based on the create index API
|
// add it... (if set to true), if we didn't remove the metedata when there is no master, then, the non
|
||||||
assertThat(System.currentTimeMillis() - now, greaterThan(timeout.millis() - 50));
|
// retry in bulk should be taken into account
|
||||||
} else {
|
if (!autoCreateIndex) {
|
||||||
// TODO note, today we don't retry on global block for bulk operations-Dtests.seed=80C397728140167
|
|
||||||
assertThat(System.currentTimeMillis() - now, lessThan(50l));
|
assertThat(System.currentTimeMillis() - now, lessThan(50l));
|
||||||
}
|
} else {
|
||||||
|
assertThat(System.currentTimeMillis() - now, greaterThan(timeout.millis() - 50));
|
||||||
assertThat(e.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE));
|
assertThat(e.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
now = System.currentTimeMillis();
|
||||||
|
try {
|
||||||
|
BulkRequestBuilder bulkRequestBuilder = client().prepareBulk();
|
||||||
|
bulkRequestBuilder.add(client().prepareIndex("no_index", "type1", "1").setSource(XContentFactory.jsonBuilder().startObject().endObject()));
|
||||||
|
bulkRequestBuilder.add(client().prepareIndex("no_index", "type1", "2").setSource(XContentFactory.jsonBuilder().startObject().endObject()));
|
||||||
|
bulkRequestBuilder.setTimeout(timeout);
|
||||||
|
bulkRequestBuilder.get();
|
||||||
|
fail("Expected ClusterBlockException");
|
||||||
|
} catch (ClusterBlockException | MasterNotDiscoveredException e) {
|
||||||
|
// today, we clear the metadata on when there is no master, so it will go through the auto create logic and
|
||||||
|
// add it... (if set to true), if we didn't remove the metedata when there is no master, then, the non
|
||||||
|
// retry in bulk should be taken into account
|
||||||
|
if (!autoCreateIndex) {
|
||||||
|
assertThat(System.currentTimeMillis() - now, lessThan(50l));
|
||||||
|
} else {
|
||||||
|
assertThat(System.currentTimeMillis() - now, greaterThan(timeout.millis() - 50));
|
||||||
|
assertThat(e.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internalCluster().startNode(settings);
|
internalCluster().startNode(settings);
|
||||||
client().admin().cluster().prepareHealth().setWaitForGreenStatus().setWaitForNodes("2").execute().actionGet();
|
client().admin().cluster().prepareHealth().setWaitForGreenStatus().setWaitForNodes("2").execute().actionGet();
|
||||||
|
|
Loading…
Reference in New Issue