Merge pull request #14069 from nik9000/no_test_annotation

Remove @Test
This commit is contained in:
Nik Everett 2015-10-20 18:33:46 -04:00
commit 6e81b0dd70
735 changed files with 4927 additions and 8238 deletions

View File

@ -549,7 +549,7 @@ public class Version {
}
String[] parts = version.split("\\.|\\-");
if (parts.length < 3 || parts.length > 4) {
throw new IllegalArgumentException("the version needs to contain major, minor and revision, and optionally the build: " + version);
throw new IllegalArgumentException("the version needs to contain major, minor, and revision, and optionally the build: " + version);
}
try {

View File

@ -602,7 +602,7 @@ public abstract class StreamInput extends InputStream {
* Use {@link FilterInputStream} instead which wraps a stream and supports a {@link NamedWriteableRegistry} too.
*/
<C> C readNamedWriteable(@SuppressWarnings("unused") Class<C> categoryClass) throws IOException {
throw new UnsupportedOperationException();
throw new UnsupportedOperationException("can't read named writeable from StreamInput");
}
/**

View File

@ -177,7 +177,7 @@ public class GeoDistanceRangeQueryBuilder extends AbstractQueryBuilder<GeoDistan
public GeoDistanceRangeQueryBuilder optimizeBbox(String optimizeBbox) {
if (optimizeBbox == null) {
throw new IllegalArgumentException("optimizeBox must not be null");
throw new IllegalArgumentException("optimizeBbox must not be null");
}
switch (optimizeBbox) {
case "none":
@ -200,7 +200,7 @@ public class GeoDistanceRangeQueryBuilder extends AbstractQueryBuilder<GeoDistan
this.validationMethod = method;
return this;
}
/** Returns validation method for coordinates. */
public GeoValidationMethod getValidationMethod() {
return this.validationMethod;
@ -305,7 +305,7 @@ public class GeoDistanceRangeQueryBuilder extends AbstractQueryBuilder<GeoDistan
@Override
protected boolean doEquals(GeoDistanceRangeQueryBuilder other) {
return ((Objects.equals(fieldName, other.fieldName)) &&
return ((Objects.equals(fieldName, other.fieldName)) &&
(Objects.equals(point, other.point)) &&
(Objects.equals(from, other.from)) &&
(Objects.equals(to, other.to)) &&

View File

@ -121,6 +121,7 @@ public class SimpleQueryStringBuilder extends AbstractQueryBuilder<SimpleQuerySt
/** Add several fields to run the query against with a specific boost. */
public SimpleQueryStringBuilder fields(Map<String, Float> fields) {
Objects.requireNonNull(fields, "fields cannot be null");
this.fieldsAndWeights.putAll(fields);
return this;
}

View File

@ -25,7 +25,6 @@ import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.elasticsearch.test.ESTestCase;
import org.junit.Test;
import java.io.IOException;
@ -34,9 +33,7 @@ import static org.hamcrest.Matchers.equalTo;
*/
public class TruncateTokenFilterTests extends ESTestCase {
@Test
public void simpleTest() throws IOException {
public void testSimple() throws IOException {
Analyzer analyzer = new Analyzer() {
@Override
protected TokenStreamComponents createComponents(String fieldName) {

View File

@ -25,7 +25,6 @@ import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.elasticsearch.test.ESTestCase;
import org.junit.Test;
import java.io.IOException;
@ -34,9 +33,7 @@ import static org.hamcrest.Matchers.equalTo;
/**
*/
public class UniqueTokenFilterTests extends ESTestCase {
@Test
public void simpleTest() throws IOException {
public void testSimple() throws IOException {
Analyzer analyzer = new Analyzer() {
@Override
protected TokenStreamComponents createComponents(String fieldName) {

View File

@ -23,18 +23,32 @@ import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.*;
import org.apache.lucene.search.*;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.MultiReader;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.DisjunctionMaxQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.QueryUtils;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.search.similarities.BM25Similarity;
import org.apache.lucene.search.similarities.DefaultSimilarity;
import org.apache.lucene.search.similarities.Similarity;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.TestUtil;
import org.elasticsearch.test.ESTestCase;
import org.junit.Test;
import java.io.IOException;
import java.util.*;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.equalTo;
@ -42,8 +56,6 @@ import static org.hamcrest.Matchers.equalTo;
/**
*/
public class BlendedTermQueryTests extends ESTestCase {
@Test
public void testBooleanQuery() throws IOException {
Directory dir = newDirectory();
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random())));
@ -97,7 +109,6 @@ public class BlendedTermQueryTests extends ESTestCase {
}
@Test
public void testDismaxQuery() throws IOException {
Directory dir = newDirectory();
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random())));
@ -171,7 +182,6 @@ public class BlendedTermQueryTests extends ESTestCase {
dir.close();
}
@Test
public void testBasics() {
final int iters = scaledRandomIntBetween(5, 25);
for (int j = 0; j < iters; j++) {
@ -209,7 +219,6 @@ public class BlendedTermQueryTests extends ESTestCase {
return searcher;
}
@Test
public void testExtractTerms() throws IOException {
Set<Term> terms = new HashSet<>();
int num = scaledRandomIntBetween(1, 10);

View File

@ -23,16 +23,12 @@ import org.apache.lucene.search.highlight.DefaultEncoder;
import org.apache.lucene.search.highlight.SimpleHTMLEncoder;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.test.ESTestCase;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
public class CustomPassageFormatterTests extends ESTestCase {
@Test
public void testSimpleFormat() {
String content = "This is a really cool highlighter. Postings highlighter gives nice snippets back. No matches here.";
@ -74,7 +70,6 @@ public class CustomPassageFormatterTests extends ESTestCase {
assertThat(fragments[2].isHighlighted(), equalTo(false));
}
@Test
public void testHtmlEncodeFormat() {
String content = "<b>This is a really cool highlighter.</b> Postings highlighter gives nice snippets back.";

View File

@ -24,21 +24,25 @@ import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.*;
import org.apache.lucene.search.*;
import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Sort;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.search.highlight.DefaultEncoder;
import org.apache.lucene.store.Directory;
import org.elasticsearch.search.highlight.HighlightUtils;
import org.elasticsearch.test.ESTestCase;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.equalTo;
public class CustomPostingsHighlighterTests extends ESTestCase {
@Test
public void testCustomPostingsHighlighter() throws Exception {
Directory dir = newDirectory();
IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random()));
iwc.setMergePolicy(newLogMergePolicy());
@ -106,7 +110,6 @@ public class CustomPostingsHighlighterTests extends ESTestCase {
dir.close();
}
@Test
public void testNoMatchSize() throws Exception {
Directory dir = newDirectory();
IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random()));

View File

@ -21,7 +21,6 @@ package org.apache.lucene.search.postingshighlight;
import org.elasticsearch.search.highlight.HighlightUtils;
import org.elasticsearch.test.ESTestCase;
import org.junit.Test;
import java.text.BreakIterator;
import java.text.CharacterIterator;
@ -31,8 +30,6 @@ import java.util.Locale;
import static org.hamcrest.CoreMatchers.equalTo;
public class CustomSeparatorBreakIteratorTests extends ESTestCase {
@Test
public void testBreakOnCustomSeparator() throws Exception {
Character separator = randomSeparator();
BreakIterator bi = new CustomSeparatorBreakIterator(separator);
@ -69,7 +66,6 @@ public class CustomSeparatorBreakIteratorTests extends ESTestCase {
assertThat(source.substring(0, bi.next(3)), equalTo("this" + separator + "is" + separator + "the" + separator));
}
@Test
public void testSingleSentences() throws Exception {
BreakIterator expected = BreakIterator.getSentenceInstance(Locale.ROOT);
BreakIterator actual = new CustomSeparatorBreakIterator(randomSeparator());
@ -79,7 +75,6 @@ public class CustomSeparatorBreakIteratorTests extends ESTestCase {
assertSameBreaks("", expected, actual);
}
@Test
public void testSliceEnd() throws Exception {
BreakIterator expected = BreakIterator.getSentenceInstance(Locale.ROOT);
BreakIterator actual = new CustomSeparatorBreakIterator(randomSeparator());
@ -89,7 +84,6 @@ public class CustomSeparatorBreakIteratorTests extends ESTestCase {
assertSameBreaks("000", 0, 0, expected, actual);
}
@Test
public void testSliceStart() throws Exception {
BreakIterator expected = BreakIterator.getSentenceInstance(Locale.ROOT);
BreakIterator actual = new CustomSeparatorBreakIterator(randomSeparator());
@ -99,7 +93,6 @@ public class CustomSeparatorBreakIteratorTests extends ESTestCase {
assertSameBreaks("000", 3, 0, expected, actual);
}
@Test
public void testSliceMiddle() throws Exception {
BreakIterator expected = BreakIterator.getSentenceInstance(Locale.ROOT);
BreakIterator actual = new CustomSeparatorBreakIterator(randomSeparator());
@ -110,7 +103,6 @@ public class CustomSeparatorBreakIteratorTests extends ESTestCase {
}
/** the current position must be ignored, initial position is always first() */
@Test
public void testFirstPosition() throws Exception {
BreakIterator expected = BreakIterator.getSentenceInstance(Locale.ROOT);
BreakIterator actual = new CustomSeparatorBreakIterator(randomSeparator());

View File

@ -22,13 +22,10 @@ package org.apache.lucene.util;
import org.elasticsearch.common.geo.GeoDistance;
import org.elasticsearch.common.unit.DistanceUnit;
import org.elasticsearch.test.ESTestCase;
import org.junit.Test;
import static org.hamcrest.number.IsCloseTo.closeTo;
public class SloppyMathTests extends ESTestCase {
@Test
public void testAccuracy() {
for (double lat1 = -89; lat1 <= 89; lat1+=1) {
final double lon1 = randomLongitude();
@ -42,7 +39,6 @@ public class SloppyMathTests extends ESTestCase {
}
}
@Test
public void testSloppyMath() {
testSloppyMath(DistanceUnit.METERS, 0.01, 5, 45, 90);
testSloppyMath(DistanceUnit.KILOMETERS, 0.01, 5, 45, 90);
@ -53,7 +49,7 @@ public class SloppyMathTests extends ESTestCase {
private static double maxError(double distance) {
return distance / 1000.0;
}
private void testSloppyMath(DistanceUnit unit, double...deltaDeg) {
final double lat1 = randomLatitude();
final double lon1 = randomLongitude();
@ -68,12 +64,12 @@ public class SloppyMathTests extends ESTestCase {
final double accurate = GeoDistance.ARC.calculate(lat1, lon1, lat2, lon2, unit);
final double dist = GeoDistance.SLOPPY_ARC.calculate(lat1, lon1, lat2, lon2, unit);
assertThat("distance between("+lat1+", "+lon1+") and ("+lat2+", "+lon2+"))", dist, closeTo(accurate, maxError(accurate)));
}
}
}
private static void assertAccurate(double lat1, double lon1, double lat2, double lon2) {
double accurate = GeoDistance.ARC.calculate(lat1, lon1, lat2, lon2, DistanceUnit.METERS);
double sloppy = GeoDistance.SLOPPY_ARC.calculate(lat1, lon1, lat2, lon2, DistanceUnit.METERS);

View File

@ -37,7 +37,7 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentLocation;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.index.query.*;
import org.elasticsearch.index.query.QueryShardException;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.search.SearchParseException;
import org.elasticsearch.search.SearchShardTarget;
@ -47,7 +47,6 @@ import org.elasticsearch.test.VersionUtils;
import org.elasticsearch.test.hamcrest.ElasticsearchAssertions;
import org.elasticsearch.transport.RemoteTransportException;
import org.hamcrest.Matchers;
import org.junit.Test;
import java.io.EOFException;
import java.io.FileNotFoundException;
@ -59,7 +58,6 @@ import static org.hamcrest.Matchers.equalTo;
public class ESExceptionTests extends ESTestCase {
private static final ToXContent.Params PARAMS = ToXContent.EMPTY_PARAMS;
@Test
public void testStatus() {
ElasticsearchException exception = new ElasticsearchException("test");
assertThat(exception.status(), equalTo(RestStatus.INTERNAL_SERVER_ERROR));

View File

@ -19,15 +19,14 @@
package org.elasticsearch;
import junit.framework.TestCase;
import org.apache.lucene.util.LuceneTestCase;
import org.elasticsearch.common.io.PathUtils;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.ESTokenStreamTestCase;
import org.junit.Test;
import java.io.IOException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.net.URISyntaxException;
import java.nio.file.FileVisitResult;
@ -91,7 +90,7 @@ public class NamingConventionTests extends ESTestCase {
} else if (Modifier.isAbstract(clazz.getModifiers()) == false && Modifier.isInterface(clazz.getModifiers()) == false) {
if (isTestCase(clazz)) {
missingSuffix.add(clazz);
} else if (junit.framework.Test.class.isAssignableFrom(clazz) || hasTestAnnotation(clazz)) {
} else if (junit.framework.Test.class.isAssignableFrom(clazz)) {
pureUnitTest.add(clazz);
}
}
@ -102,16 +101,6 @@ public class NamingConventionTests extends ESTestCase {
return FileVisitResult.CONTINUE;
}
private boolean hasTestAnnotation(Class<?> clazz) {
for (Method method : clazz.getDeclaredMethods()) {
if (method.getAnnotation(Test.class) != null) {
return true;
}
}
return false;
}
private boolean isTestCase(Class<?> clazz) {
return LuceneTestCase.class.isAssignableFrom(clazz);
}
@ -145,7 +134,6 @@ public class NamingConventionTests extends ESTestCase {
assertTrue(innerClasses.remove(InnerTests.class));
assertTrue(notImplementing.remove(NotImplementingTests.class));
assertTrue(pureUnitTest.remove(PlainUnit.class));
assertTrue(pureUnitTest.remove(PlainUnitTheSecond.class));
String classesToSubclass = String.join(
",",
@ -187,11 +175,4 @@ public class NamingConventionTests extends ESTestCase {
public static final class WrongNameTheSecond extends ESTestCase {}
public static final class PlainUnit extends TestCase {}
public static final class PlainUnitTheSecond {
@Test
public void foo() {
}
}
}

View File

@ -25,7 +25,6 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.VersionUtils;
import org.hamcrest.Matchers;
import org.junit.Test;
import java.lang.reflect.Modifier;
import java.util.HashMap;
@ -36,6 +35,7 @@ import static org.elasticsearch.Version.V_0_20_0;
import static org.elasticsearch.Version.V_0_90_0;
import static org.elasticsearch.test.VersionUtils.randomVersion;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
@ -102,24 +102,41 @@ public class VersionTests extends ESTestCase {
}
}
@Test(expected = IllegalArgumentException.class)
public void testTooLongVersionFromString() {
Version.fromString("1.0.0.1.3");
try {
Version.fromString("1.0.0.1.3");
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException e) {
assertThat(e.getMessage(), containsString("needs to contain major, minor, and revision"));
}
}
@Test(expected = IllegalArgumentException.class)
public void testTooShortVersionFromString() {
Version.fromString("1.0");
try {
Version.fromString("1.0");
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException e) {
assertThat(e.getMessage(), containsString("needs to contain major, minor, and revision"));
}
}
@Test(expected = IllegalArgumentException.class)
public void testWrongVersionFromString() {
Version.fromString("WRONG.VERSION");
try {
Version.fromString("WRONG.VERSION");
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException e) {
assertThat(e.getMessage(), containsString("needs to contain major, minor, and revision"));
}
}
@Test(expected = IllegalStateException.class)
public void testVersionNoPresentInSettings() {
Version.indexCreated(Settings.builder().build());
try {
Version.indexCreated(Settings.builder().build());
fail("Expected IllegalArgumentException");
} catch (IllegalStateException e) {
assertThat(e.getMessage(), containsString("[index.version.created] is not present"));
}
}
public void testIndexCreatedVersion() {

View File

@ -25,7 +25,6 @@ import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Test;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
@ -33,10 +32,7 @@ import java.util.concurrent.atomic.AtomicReference;
/**
*/
public class ListenerActionIT extends ESIntegTestCase {
@Test
public void verifyThreadedListeners() throws Throwable {
public void testThreadedListeners() throws Throwable {
final CountDownLatch latch = new CountDownLatch(1);
final AtomicReference<Throwable> failure = new AtomicReference<>();
final AtomicReference<String> threadName = new AtomicReference<>();

View File

@ -23,7 +23,6 @@ import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.test.ESTestCase;
import org.junit.Test;
import java.io.IOException;
@ -36,7 +35,6 @@ public class OriginalIndicesTests extends ESTestCase {
IndicesOptions.lenientExpandOpen() , IndicesOptions.strictExpand(), IndicesOptions.strictExpandOpen(),
IndicesOptions.strictExpandOpenAndForbidClosed(), IndicesOptions.strictSingleIndexNoExpandForbidClosed()};
@Test
public void testOriginalIndicesSerialization() throws IOException {
int iterations = iterations(10, 30);
for (int i = 0; i < iterations; i++) {

View File

@ -29,7 +29,6 @@ import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.junit.Test;
import java.util.Locale;
import java.util.concurrent.CopyOnWriteArrayList;
@ -56,8 +55,7 @@ public class RejectionActionIT extends ESIntegTestCase {
}
@Test
public void simulateSearchRejectionLoad() throws Throwable {
public void testSimulatedSearchRejectionLoad() throws Throwable {
for (int i = 0; i < 10; i++) {
client().prepareIndex("test", "type", Integer.toString(i)).setSource("field", "1").get();
}

View File

@ -24,7 +24,6 @@ import org.elasticsearch.action.admin.cluster.node.hotthreads.NodesHotThreadsReq
import org.elasticsearch.action.admin.cluster.node.hotthreads.NodesHotThreadsResponse;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Test;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
@ -41,8 +40,6 @@ import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.Matchers.lessThan;
public class HotThreadsIT extends ESIntegTestCase {
@Test
public void testHotThreadsDontFail() throws ExecutionException, InterruptedException {
/**
* This test just checks if nothing crashes or gets stuck etc.

View File

@ -41,7 +41,6 @@ import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.Matchers;
import org.junit.Test;
import java.io.IOException;
@ -165,7 +164,6 @@ public class ClusterHealthResponsesTests extends ESTestCase {
return builder.build();
}
@Test
public void testClusterIndexHealth() {
int numberOfShards = randomInt(3) + 1;
int numberOfReplicas = randomInt(4);
@ -200,7 +198,6 @@ public class ClusterHealthResponsesTests extends ESTestCase {
}
}
@Test
public void testClusterHealth() throws IOException {
ShardCounter counter = new ShardCounter();
RoutingTable.Builder routingTable = RoutingTable.builder();
@ -239,7 +236,6 @@ public class ClusterHealthResponsesTests extends ESTestCase {
return clusterHealth;
}
@Test
public void testValidations() throws IOException {
IndexMetaData indexMetaData = IndexMetaData.builder("test").settings(settings(Version.CURRENT)).numberOfShards(2).numberOfReplicas(2).build();
ShardCounter counter = new ShardCounter();

View File

@ -25,7 +25,6 @@ import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.junit.Test;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
@ -39,8 +38,6 @@ import static org.hamcrest.Matchers.hasSize;
*/
@ClusterScope(scope = ESIntegTestCase.Scope.TEST)
public class RepositoryBlocksIT extends ESIntegTestCase {
@Test
public void testPutRepositoryWithBlocks() {
logger.info("--> registering a repository is blocked when the cluster is read only");
try {
@ -60,7 +57,6 @@ public class RepositoryBlocksIT extends ESIntegTestCase {
.setSettings(Settings.settingsBuilder().put("location", randomRepoPath())));
}
@Test
public void testVerifyRepositoryWithBlocks() {
assertAcked(client().admin().cluster().preparePutRepository("test-repo-blocks")
.setType("fs")
@ -77,7 +73,6 @@ public class RepositoryBlocksIT extends ESIntegTestCase {
}
}
@Test
public void testDeleteRepositoryWithBlocks() {
assertAcked(client().admin().cluster().preparePutRepository("test-repo-blocks")
.setType("fs")
@ -96,7 +91,6 @@ public class RepositoryBlocksIT extends ESIntegTestCase {
assertAcked(client().admin().cluster().prepareDeleteRepository("test-repo-blocks"));
}
@Test
public void testGetRepositoryWithBlocks() {
assertAcked(client().admin().cluster().preparePutRepository("test-repo-blocks")
.setType("fs")

View File

@ -30,10 +30,9 @@ import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.junit.Before;
import org.junit.Test;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
import static org.hamcrest.Matchers.equalTo;
@ -85,7 +84,6 @@ public class SnapshotBlocksIT extends ESIntegTestCase {
ensureSearchable();
}
@Test
public void testCreateSnapshotWithBlocks() {
logger.info("--> creating a snapshot is allowed when the cluster is read only");
try {
@ -102,7 +100,6 @@ public class SnapshotBlocksIT extends ESIntegTestCase {
assertThat(response.status(), equalTo(RestStatus.OK));
}
@Test
public void testCreateSnapshotWithIndexBlocks() {
logger.info("--> creating a snapshot is not blocked when an index is read only");
try {
@ -123,7 +120,6 @@ public class SnapshotBlocksIT extends ESIntegTestCase {
}
}
@Test
public void testDeleteSnapshotWithBlocks() {
logger.info("--> deleting a snapshot is allowed when the cluster is read only");
try {
@ -134,7 +130,6 @@ public class SnapshotBlocksIT extends ESIntegTestCase {
}
}
@Test
public void testRestoreSnapshotWithBlocks() {
assertAcked(client().admin().indices().prepareDelete(INDEX_NAME, OTHER_INDEX_NAME));
assertFalse(client().admin().indices().prepareExists(INDEX_NAME, OTHER_INDEX_NAME).get().isExists());
@ -156,7 +151,6 @@ public class SnapshotBlocksIT extends ESIntegTestCase {
assertTrue(client().admin().indices().prepareExists(OTHER_INDEX_NAME).get().isExists());
}
@Test
public void testGetSnapshotWithBlocks() {
// This test checks that the Get Snapshot operation is never blocked, even if the cluster is read only.
try {
@ -169,7 +163,6 @@ public class SnapshotBlocksIT extends ESIntegTestCase {
}
}
@Test
public void testSnapshotStatusWithBlocks() {
// This test checks that the Snapshot Status operation is never blocked, even if the cluster is read only.
try {

View File

@ -21,11 +21,10 @@ package org.elasticsearch.action.admin.cluster.state;
import org.elasticsearch.Version;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.VersionUtils;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.equalTo;
@ -33,8 +32,6 @@ import static org.hamcrest.CoreMatchers.equalTo;
* Unit tests for the {@link ClusterStateRequest}.
*/
public class ClusterStateRequestTests extends ESTestCase {
@Test
public void testSerialization() throws Exception {
int iterations = randomIntBetween(5, 20);
for (int i = 0; i < iterations; i++) {

View File

@ -28,13 +28,12 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.store.Store;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.hamcrest.Matchers;
import org.junit.Test;
import java.io.IOException;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.test.ESIntegTestCase.*;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.is;
@ -55,7 +54,6 @@ public class ClusterStatsIT extends ESIntegTestCase {
assertThat(actionGet.isTimedOut(), is(false));
}
@Test
public void testNodeCounts() {
ClusterStatsResponse response = client().admin().cluster().prepareClusterStats().get();
assertCounts(response.getNodesStats().getCounts(), 1, 0, 0, 1, 0);
@ -84,7 +82,6 @@ public class ClusterStatsIT extends ESIntegTestCase {
assertThat(stats.getReplication(), Matchers.equalTo(replicationFactor));
}
@Test
public void testIndicesShardStats() {
ClusterStatsResponse response = client().admin().cluster().prepareClusterStats().get();
assertThat(response.getStatus(), Matchers.equalTo(ClusterHealthStatus.GREEN));
@ -129,7 +126,6 @@ public class ClusterStatsIT extends ESIntegTestCase {
}
@Test
public void testValuesSmokeScreen() throws IOException {
internalCluster().ensureAtMostNumDataNodes(5);
internalCluster().ensureAtLeastNumDataNodes(1);

View File

@ -21,16 +21,16 @@ package org.elasticsearch.action.admin.cluster.tasks;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.junit.Test;
import java.util.Arrays;
import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_METADATA;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
@ClusterScope(scope = ESIntegTestCase.Scope.TEST)
public class PendingTasksBlocksIT extends ESIntegTestCase {
@Test
public void testPendingTasksWithBlocks() {
createIndex("test");
ensureGreen("test");

View File

@ -21,19 +21,19 @@ package org.elasticsearch.action.admin.indices.cache.clear;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.junit.Test;
import java.util.Arrays;
import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_METADATA;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.hamcrest.Matchers.equalTo;
@ClusterScope(scope = ESIntegTestCase.Scope.TEST)
public class ClearIndicesCacheBlocksIT extends ESIntegTestCase {
@Test
public void testClearIndicesCacheWithBlocks() {
createIndex("test");
ensureGreen("test");

View File

@ -52,7 +52,7 @@ import static org.hamcrest.core.IsNull.notNullValue;
@ClusterScope(scope = Scope.TEST)
public class CreateIndexIT extends ESIntegTestCase {
public void testCreationDate_Given() {
public void testCreationDateGiven() {
prepareCreate("test").setSettings(Settings.builder().put(IndexMetaData.SETTING_CREATION_DATE, 4l)).get();
ClusterStateResponse response = client().admin().cluster().prepareState().get();
ClusterState state = response.getState();
@ -67,7 +67,7 @@ public class CreateIndexIT extends ESIntegTestCase {
assertThat(index.getCreationDate(), equalTo(4l));
}
public void testCreationDate_Generated() {
public void testCreationDateGenerated() {
long timeBeforeRequest = System.currentTimeMillis();
prepareCreate("test").get();
long timeAfterRequest = System.currentTimeMillis();

View File

@ -26,7 +26,6 @@ import org.elasticsearch.rest.NoOpClient;
import org.elasticsearch.test.ESTestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@ -56,7 +55,6 @@ public class CreateIndexRequestBuilderTests extends ESTestCase {
/**
* test setting the source with available setters
*/
@Test
public void testSetSource() throws IOException {
CreateIndexRequestBuilder builder = new CreateIndexRequestBuilder(this.testClient, CreateIndexAction.INSTANCE);
builder.setSource("{\""+KEY+"\" : \""+VALUE+"\"}");
@ -82,7 +80,6 @@ public class CreateIndexRequestBuilderTests extends ESTestCase {
/**
* test setting the settings with available setters
*/
@Test
public void testSetSettings() throws IOException {
CreateIndexRequestBuilder builder = new CreateIndexRequestBuilder(this.testClient, CreateIndexAction.INSTANCE);
builder.setSettings(KEY, VALUE);

View File

@ -21,14 +21,11 @@ package org.elasticsearch.action.admin.indices.delete;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.junit.Test;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
@ClusterScope(scope = ESIntegTestCase.Scope.TEST)
public class DeleteIndexBlocksIT extends ESIntegTestCase {
@Test
public void testDeleteIndexWithBlocks() {
createIndex("test");
ensureGreen("test");

View File

@ -21,19 +21,19 @@ package org.elasticsearch.action.admin.indices.flush;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.junit.Test;
import java.util.Arrays;
import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_METADATA;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.hamcrest.Matchers.equalTo;
@ClusterScope(scope = ESIntegTestCase.Scope.TEST)
public class FlushBlocksIT extends ESIntegTestCase {
@Test
public void testFlushWithBlocks() {
createIndex("test");
ensureGreen("test");

View File

@ -28,22 +28,25 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.search.warmer.IndexWarmersMetaData.Entry;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
import static org.elasticsearch.cluster.metadata.IndexMetaData.INDEX_METADATA_BLOCK;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_METADATA;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
import static org.hamcrest.Matchers.*;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
@ESIntegTestCase.SuiteScopeTestCase
public class GetIndexIT extends ESIntegTestCase {
private static final String[] allFeatures = { "_alias", "_aliases", "_mapping", "_mappings", "_settings", "_warmer", "_warmers" };
@Override
protected void setupSuiteScopeCluster() throws Exception {
assertAcked(prepareCreate("idx").addAlias(new Alias("alias_idx")).addMapping("type1", "{\"type1\":{}}")
@ -54,7 +57,6 @@ public class GetIndexIT extends ESIntegTestCase {
ensureSearchable("idx", "empty_idx");
}
@Test
public void testSimple() {
GetIndexResponse response = client().admin().indices().prepareGetIndex().addIndices("idx").get();
String[] indices = response.indices();
@ -67,12 +69,15 @@ public class GetIndexIT extends ESIntegTestCase {
assertWarmers(response, "idx");
}
@Test(expected=IndexNotFoundException.class)
public void testSimpleUnknownIndex() {
client().admin().indices().prepareGetIndex().addIndices("missing_idx").get();
try {
client().admin().indices().prepareGetIndex().addIndices("missing_idx").get();
fail("Expected IndexNotFoundException");
} catch (IndexNotFoundException e) {
assertThat(e.getMessage(), is("no such index"));
}
}
@Test
public void testEmpty() {
GetIndexResponse response = client().admin().indices().prepareGetIndex().addIndices("empty_idx").get();
String[] indices = response.indices();
@ -85,7 +90,6 @@ public class GetIndexIT extends ESIntegTestCase {
assertEmptyWarmers(response);
}
@Test
public void testSimpleMapping() {
GetIndexResponse response = runWithRandomFeatureMethod(client().admin().indices().prepareGetIndex().addIndices("idx"),
Feature.MAPPINGS);
@ -99,7 +103,6 @@ public class GetIndexIT extends ESIntegTestCase {
assertEmptyWarmers(response);
}
@Test
public void testSimpleAlias() {
GetIndexResponse response = runWithRandomFeatureMethod(client().admin().indices().prepareGetIndex().addIndices("idx"),
Feature.ALIASES);
@ -113,7 +116,6 @@ public class GetIndexIT extends ESIntegTestCase {
assertEmptyWarmers(response);
}
@Test
public void testSimpleSettings() {
GetIndexResponse response = runWithRandomFeatureMethod(client().admin().indices().prepareGetIndex().addIndices("idx"),
Feature.SETTINGS);
@ -127,7 +129,6 @@ public class GetIndexIT extends ESIntegTestCase {
assertEmptyWarmers(response);
}
@Test
public void testSimpleWarmer() {
GetIndexResponse response = runWithRandomFeatureMethod(client().admin().indices().prepareGetIndex().addIndices("idx"),
Feature.WARMERS);
@ -141,7 +142,6 @@ public class GetIndexIT extends ESIntegTestCase {
assertEmptySettings(response);
}
@Test
public void testSimpleMixedFeatures() {
int numFeatures = randomIntBetween(1, Feature.values().length);
List<Feature> features = new ArrayList<Feature>(numFeatures);
@ -176,7 +176,6 @@ public class GetIndexIT extends ESIntegTestCase {
}
}
@Test
public void testEmptyMixedFeatures() {
int numFeatures = randomIntBetween(1, Feature.values().length);
List<Feature> features = new ArrayList<Feature>(numFeatures);
@ -203,7 +202,6 @@ public class GetIndexIT extends ESIntegTestCase {
assertEmptyWarmers(response);
}
@Test
public void testGetIndexWithBlocks() {
for (String block : Arrays.asList(SETTING_BLOCKS_READ, SETTING_BLOCKS_WRITE, SETTING_READ_ONLY)) {
try {

View File

@ -21,19 +21,19 @@ package org.elasticsearch.action.admin.indices.optimize;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.junit.Test;
import java.util.Arrays;
import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_METADATA;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.hamcrest.Matchers.equalTo;
@ClusterScope(scope = ESIntegTestCase.Scope.TEST)
public class OptimizeBlocksIT extends ESIntegTestCase {
@Test
public void testOptimizeWithBlocks() {
createIndex("test");
ensureGreen("test");

View File

@ -22,19 +22,19 @@ package org.elasticsearch.action.admin.indices.refresh;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.junit.Test;
import java.util.Arrays;
import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_METADATA;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.hamcrest.Matchers.equalTo;
@ClusterScope(scope = ESIntegTestCase.Scope.TEST)
public class RefreshBlocksIT extends ESIntegTestCase {
@Test
public void testRefreshWithBlocks() {
createIndex("test");
ensureGreen("test");

View File

@ -21,18 +21,18 @@ package org.elasticsearch.action.admin.indices.segments;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.junit.Test;
import java.util.Arrays;
import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_METADATA;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
@ClusterScope(scope = ESIntegTestCase.Scope.TEST)
public class IndicesSegmentsBlocksIT extends ESIntegTestCase {
@Test
public void testIndicesSegmentsWithBlocks() {
createIndex("test-blocks");
ensureGreen("test-blocks");

View File

@ -22,14 +22,16 @@ package org.elasticsearch.action.admin.indices.segments;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.engine.Segment;
import org.elasticsearch.indices.IndexClosedException;
import org.elasticsearch.test.ESSingleNodeTestCase;
import org.junit.Before;
import org.junit.Test;
import java.util.List;
import static org.hamcrest.Matchers.is;
public class IndicesSegmentsRequestTests extends ESSingleNodeTestCase {
@Before
public void setupIndex() {
Settings settings = Settings.builder()
@ -51,7 +53,7 @@ public class IndicesSegmentsRequestTests extends ESSingleNodeTestCase {
List<Segment> segments = rsp.getIndices().get("test").iterator().next().getShards()[0].getSegments();
assertNull(segments.get(0).ramTree);
}
public void testVerbose() {
IndicesSegmentResponse rsp = client().admin().indices().prepareSegments("test").setVerbose(true).get();
List<Segment> segments = rsp.getIndices().get("test").iterator().next().getShards()[0].getSegments();
@ -61,10 +63,14 @@ public class IndicesSegmentsRequestTests extends ESSingleNodeTestCase {
/**
* with the default IndicesOptions inherited from BroadcastOperationRequest this will raise an exception
*/
@Test(expected=org.elasticsearch.indices.IndexClosedException.class)
public void testRequestOnClosedIndex() {
client().admin().indices().prepareClose("test").get();
client().admin().indices().prepareSegments("test").get();
try {
client().admin().indices().prepareSegments("test").get();
fail("Expected IndexClosedException");
} catch (IndexClosedException e) {
assertThat(e.getMessage(), is("closed"));
}
}
/**

View File

@ -20,14 +20,16 @@
package org.elasticsearch.action.admin.indices.shards;
import com.carrotsearch.hppc.cursors.IntObjectCursor;
import com.carrotsearch.hppc.cursors.ObjectCursor;
import org.apache.lucene.index.CorruptIndexException;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.client.Requests;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.routing.*;
import org.elasticsearch.cluster.routing.IndexRoutingTable;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.routing.ShardRoutingState;
import org.elasticsearch.common.collect.ImmutableOpenIntMap;
import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.common.settings.Settings;
@ -37,27 +39,31 @@ import org.elasticsearch.indices.IndicesService;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.test.store.MockFSDirectoryService;
import org.junit.Test;
import java.util.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.function.Predicate;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoTimeout;
import static org.hamcrest.Matchers.*;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST)
public class IndicesShardStoreRequestIT extends ESIntegTestCase {
@Test
public void testEmpty() {
ensureGreen();
IndicesShardStoresResponse rsp = client().admin().indices().prepareShardStores().get();
assertThat(rsp.getStoreStatuses().size(), equalTo(0));
}
@Test
@TestLogging("action.admin.indices.shards:TRACE,cluster.service:TRACE")
public void testBasic() throws Exception {
String index = "test";
@ -108,7 +114,6 @@ public class IndicesShardStoreRequestIT extends ESIntegTestCase {
enableAllocation(index);
}
@Test
public void testIndices() throws Exception {
String index1 = "test1";
String index2 = "test2";
@ -137,7 +142,6 @@ public class IndicesShardStoreRequestIT extends ESIntegTestCase {
assertThat(shardStatuses.get(index1).size(), equalTo(2));
}
@Test
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/12416")
public void testCorruptedShards() throws Exception {
String index = "test";

View File

@ -26,19 +26,24 @@ import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.collect.ImmutableOpenIntMap;
import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.common.transport.DummyTransportAddress;
import org.elasticsearch.common.xcontent.*;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.transport.NodeDisconnectedException;
import org.junit.Test;
import java.io.IOException;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.hamcrest.Matchers.equalTo;
public class IndicesShardStoreResponseTests extends ESTestCase {
@Test
public void testBasicSerialization() throws Exception {
ImmutableOpenMap.Builder<String, ImmutableOpenIntMap<List<IndicesShardStoresResponse.StoreStatus>>> indexStoreStatuses = ImmutableOpenMap.builder();
List<IndicesShardStoresResponse.Failure> failures = new ArrayList<>();
@ -104,7 +109,6 @@ public class IndicesShardStoreResponseTests extends ESTestCase {
}
}
@Test
public void testStoreStatusOrdering() throws Exception {
DiscoveryNode node1 = new DiscoveryNode("node1", DummyTransportAddress.INSTANCE, Version.CURRENT);
List<IndicesShardStoresResponse.StoreStatus> orderedStoreStatuses = new ArrayList<>();

View File

@ -23,16 +23,15 @@ import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.junit.Test;
import java.util.Arrays;
import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
@ClusterScope(scope = ESIntegTestCase.Scope.TEST)
public class IndicesStatsBlocksIT extends ESIntegTestCase {
@Test
public void testIndicesStatsWithBlocks() {
createIndex("ro");
ensureGreen("ro");

View File

@ -27,7 +27,6 @@ import org.elasticsearch.cluster.metadata.MetaDataIndexTemplateService.PutReques
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.indices.InvalidIndexTemplateException;
import org.elasticsearch.test.ESTestCase;
import org.junit.Test;
import java.util.ArrayList;
import java.util.HashMap;
@ -39,7 +38,6 @@ import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.instanceOf;
public class MetaDataIndexTemplateServiceTests extends ESTestCase {
@Test
public void testIndexTemplateInvalidNumberOfShards() {
PutRequest request = new PutRequest("test", "test_shards");
request.template("test_shards*");
@ -54,7 +52,6 @@ public class MetaDataIndexTemplateServiceTests extends ESTestCase {
assertThat(throwables.get(0).getMessage(), containsString("index must have 1 or more primary shards"));
}
@Test
public void testIndexTemplateValidationAccumulatesValidationErrors() {
PutRequest request = new PutRequest("test", "putTemplate shards");
request.template("_test_shards*");

View File

@ -20,14 +20,12 @@ package org.elasticsearch.action.admin.indices.warmer.put;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.test.ESTestCase;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.Matchers.hasSize;
public class PutWarmerRequestTests extends ESTestCase {
@Test // issue 4196
// issue 4196
public void testThatValidationWithoutSpecifyingSearchRequestFails() {
PutWarmerRequest putWarmerRequest = new PutWarmerRequest("foo");
ActionRequestValidationException validationException = putWarmerRequest.validate();

View File

@ -20,17 +20,14 @@
package org.elasticsearch.action.bulk;
import java.nio.charset.StandardCharsets;
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Test;
import java.nio.charset.StandardCharsets;
import static org.elasticsearch.test.StreamsUtils.copyToStringFromClasspath;
public class BulkIntegrationIT extends ESIntegTestCase {
@Test
public void testBulkIndexCreatesMapping() throws Exception {
String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/bulk-log.json");
BulkRequestBuilder bulkBuilder = client().prepareBulk();

View File

@ -23,12 +23,9 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.junit.Test;
@ClusterScope(scope = Scope.TEST, numDataNodes = 0)
public class BulkProcessorClusterSettingsIT extends ESIntegTestCase {
@Test
public void testBulkProcessorAutoCreateRestrictions() throws Exception {
// See issue #8125
Settings settings = Settings.settingsBuilder().put("action.auto_create_index", false).build();

View File

@ -33,7 +33,6 @@ import org.elasticsearch.common.unit.ByteSizeUnit;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Test;
import java.util.Arrays;
import java.util.HashSet;
@ -45,13 +44,16 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.*;
import static org.hamcrest.Matchers.both;
import static org.hamcrest.Matchers.either;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.lessThanOrEqualTo;
public class BulkProcessorIT extends ESIntegTestCase {
@Test
public void testThatBulkProcessorCountIsCorrect() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
BulkProcessorTestListener listener = new BulkProcessorTestListener(latch);
@ -74,7 +76,6 @@ public class BulkProcessorIT extends ESIntegTestCase {
}
}
@Test
public void testBulkProcessorFlush() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
BulkProcessorTestListener listener = new BulkProcessorTestListener(latch);
@ -101,7 +102,6 @@ public class BulkProcessorIT extends ESIntegTestCase {
}
}
@Test
public void testBulkProcessorConcurrentRequests() throws Exception {
int bulkActions = randomIntBetween(10, 100);
int numDocs = randomIntBetween(bulkActions, bulkActions + 100);
@ -153,7 +153,6 @@ public class BulkProcessorIT extends ESIntegTestCase {
assertMultiGetResponse(multiGetRequestBuilder.get(), numDocs);
}
@Test
//https://github.com/elasticsearch/elasticsearch/issues/5038
public void testBulkProcessorConcurrentRequestsNoNodeAvailableException() throws Exception {
//we create a transport client with no nodes to make sure it throws NoNodeAvailableException
@ -196,7 +195,6 @@ public class BulkProcessorIT extends ESIntegTestCase {
transportClient.close();
}
@Test
public void testBulkProcessorWaitOnClose() throws Exception {
BulkProcessorTestListener listener = new BulkProcessorTestListener();
@ -205,7 +203,7 @@ public class BulkProcessorIT extends ESIntegTestCase {
//let's make sure that the bulk action limit trips, one single execution will index all the documents
.setConcurrentRequests(randomIntBetween(0, 1)).setBulkActions(numDocs)
.setFlushInterval(TimeValue.timeValueHours(24)).setBulkSize(new ByteSizeValue(randomIntBetween(1, 10),
(ByteSizeUnit)RandomPicks.randomFrom(getRandom(), ByteSizeUnit.values())))
RandomPicks.randomFrom(getRandom(), ByteSizeUnit.values())))
.build();
MultiGetRequestBuilder multiGetRequestBuilder = indexDocs(client(), processor, numDocs);
@ -227,7 +225,6 @@ public class BulkProcessorIT extends ESIntegTestCase {
assertMultiGetResponse(multiGetRequestBuilder.get(), numDocs);
}
@Test
public void testBulkProcessorConcurrentRequestsReadOnlyIndex() throws Exception {
createIndex("test-ro");
assertAcked(client().admin().indices().prepareUpdateSettings("test-ro")

View File

@ -19,8 +19,6 @@
package org.elasticsearch.action.bulk;
import java.nio.charset.StandardCharsets;
import org.apache.lucene.util.Constants;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.delete.DeleteRequest;
@ -31,8 +29,8 @@ import org.elasticsearch.common.Strings;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.script.Script;
import org.elasticsearch.test.ESTestCase;
import org.junit.Test;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -43,8 +41,6 @@ import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.notNullValue;
public class BulkRequestTests extends ESTestCase {
@Test
public void testSimpleBulk1() throws Exception {
String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk.json");
// translate Windows line endings (\r\n) to standard ones (\n)
@ -59,7 +55,6 @@ public class BulkRequestTests extends ESTestCase {
assertThat(((IndexRequest) bulkRequest.requests().get(2)).source().toBytes(), equalTo(new BytesArray("{ \"field1\" : \"value3\" }").toBytes()));
}
@Test
public void testSimpleBulk2() throws Exception {
String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk2.json");
BulkRequest bulkRequest = new BulkRequest();
@ -67,7 +62,6 @@ public class BulkRequestTests extends ESTestCase {
assertThat(bulkRequest.numberOfActions(), equalTo(3));
}
@Test
public void testSimpleBulk3() throws Exception {
String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk3.json");
BulkRequest bulkRequest = new BulkRequest();
@ -75,7 +69,6 @@ public class BulkRequestTests extends ESTestCase {
assertThat(bulkRequest.numberOfActions(), equalTo(3));
}
@Test
public void testSimpleBulk4() throws Exception {
String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk4.json");
BulkRequest bulkRequest = new BulkRequest();
@ -98,7 +91,6 @@ public class BulkRequestTests extends ESTestCase {
assertThat(((UpdateRequest) bulkRequest.requests().get(1)).upsertRequest().source().toUtf8(), equalTo("{\"counter\":1}"));
}
@Test
public void testBulkAllowExplicitIndex() throws Exception {
String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk.json");
try {
@ -112,7 +104,6 @@ public class BulkRequestTests extends ESTestCase {
new BulkRequest().add(new BytesArray(bulkAction.getBytes(StandardCharsets.UTF_8)), "test", null, false);
}
@Test
public void testBulkAddIterable() {
BulkRequest bulkRequest = Requests.bulkRequest();
List<ActionRequest> requests = new ArrayList<>();
@ -126,7 +117,6 @@ public class BulkRequestTests extends ESTestCase {
assertThat(bulkRequest.requests().get(2), instanceOf(DeleteRequest.class));
}
@Test
public void testSimpleBulk6() throws Exception {
String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk6.json");
BulkRequest bulkRequest = new BulkRequest();
@ -139,7 +129,6 @@ public class BulkRequestTests extends ESTestCase {
}
}
@Test
public void testSimpleBulk7() throws Exception {
String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk7.json");
BulkRequest bulkRequest = new BulkRequest();
@ -152,7 +141,6 @@ public class BulkRequestTests extends ESTestCase {
}
}
@Test
public void testSimpleBulk8() throws Exception {
String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk8.json");
BulkRequest bulkRequest = new BulkRequest();
@ -165,7 +153,6 @@ public class BulkRequestTests extends ESTestCase {
}
}
@Test
public void testSimpleBulk9() throws Exception {
String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk9.json");
BulkRequest bulkRequest = new BulkRequest();
@ -178,7 +165,6 @@ public class BulkRequestTests extends ESTestCase {
}
}
@Test
public void testSimpleBulk10() throws Exception {
String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk10.json");
BulkRequest bulkRequest = new BulkRequest();

View File

@ -24,7 +24,6 @@ import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.index.VersionType;
import org.elasticsearch.search.fetch.source.FetchSourceContext;
import org.elasticsearch.test.ESTestCase;
import org.junit.Test;
import java.io.IOException;
@ -32,8 +31,6 @@ import static org.elasticsearch.test.VersionUtils.randomVersion;
import static org.hamcrest.CoreMatchers.equalTo;
public class MultiGetShardRequestTests extends ESTestCase {
@Test
public void testSerialization() throws IOException {
MultiGetRequest multiGetRequest = new MultiGetRequest();
if (randomBoolean()) {

View File

@ -27,7 +27,6 @@ import org.elasticsearch.rest.NoOpClient;
import org.elasticsearch.test.ESTestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.ByteArrayOutputStream;
import java.util.HashMap;
@ -55,7 +54,6 @@ public class IndexRequestBuilderTests extends ESTestCase {
/**
* test setting the source for the request with different available setters
*/
@Test
public void testSetSource() throws Exception {
IndexRequestBuilder indexRequestBuilder = new IndexRequestBuilder(this.testClient, IndexAction.INSTANCE);
Map<String, String> source = new HashMap<>();

View File

@ -20,19 +20,19 @@ package org.elasticsearch.action.index;
import org.elasticsearch.index.VersionType;
import org.elasticsearch.test.ESTestCase;
import org.junit.Test;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import static org.hamcrest.Matchers.*;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not;
/**
*/
public class IndexRequestTests extends ESTestCase {
@Test
public void testIndexRequestOpTypeFromString() throws Exception {
String create = "create";
String index = "index";
@ -45,10 +45,13 @@ public class IndexRequestTests extends ESTestCase {
assertThat(IndexRequest.OpType.fromString(indexUpper), equalTo(IndexRequest.OpType.INDEX));
}
@Test(expected = IllegalArgumentException.class)
public void testReadBogusString() {
String foobar = "foobar";
IndexRequest.OpType.fromString(foobar);
try {
IndexRequest.OpType.fromString("foobar");
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException e) {
assertThat(e.getMessage(), containsString("opType [foobar] not allowed"));
}
}
public void testCreateOperationRejectsVersions() {

View File

@ -23,7 +23,6 @@ import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.index.VersionType;
import org.elasticsearch.test.ESTestCase;
import org.junit.Test;
import java.io.IOException;
@ -31,8 +30,6 @@ import static org.elasticsearch.test.VersionUtils.randomVersion;
import static org.hamcrest.CoreMatchers.equalTo;
public class GetIndexedScriptRequestTests extends ESTestCase {
@Test
public void testGetIndexedScriptRequestSerialization() throws IOException {
GetIndexedScriptRequest request = new GetIndexedScriptRequest("lang", "id");
if (randomBoolean()) {

View File

@ -20,20 +20,19 @@ package org.elasticsearch.action.percolate;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.common.collect.MapBuilder;
import org.elasticsearch.test.StreamsUtils;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.test.ESTestCase;
import org.junit.Test;
import org.elasticsearch.test.StreamsUtils;
import java.util.Map;
import static org.hamcrest.Matchers.*;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
/**
*/
public class MultiPercolatorRequestTests extends ESTestCase {
@Test
public void testParseBulkRequests() throws Exception {
byte[] data = StreamsUtils.copyToBytesFromClasspath("/org/elasticsearch/action/percolate/mpercolate1.json");
MultiPercolateRequest request = new MultiPercolateRequest().add(data, 0, data.length);
@ -150,8 +149,7 @@ public class MultiPercolatorRequestTests extends ESTestCase {
assertThat(sourceMap.get("doc"), nullValue());
}
@Test
public void testParseBulkRequests_defaults() throws Exception {
public void testParseBulkRequestsDefaults() throws Exception {
byte[] data = StreamsUtils.copyToBytesFromClasspath("/org/elasticsearch/action/percolate/mpercolate2.json");
MultiPercolateRequest request = new MultiPercolateRequest();
request.indices("my-index1").documentType("my-type1").indicesOptions(IndicesOptions.lenientExpandOpen());

View File

@ -33,7 +33,6 @@ import org.elasticsearch.rest.action.search.RestMultiSearchAction;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.StreamsUtils;
import org.junit.Test;
import java.io.IOException;
import java.util.Collections;
@ -42,9 +41,7 @@ import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue;
public class MultiSearchRequestTests extends ESTestCase {
@Test
public void simpleAdd() throws Exception {
public void testSimpleAdd() throws Exception {
IndicesQueriesRegistry registry = new IndicesQueriesRegistry(Settings.EMPTY, Collections.singleton(new MatchAllQueryParser()), new NamedWriteableRegistry());
byte[] data = StreamsUtils.copyToBytesFromClasspath("/org/elasticsearch/action/search/simple-msearch1.json");
MultiSearchRequest request = RestMultiSearchAction.parseRequest(new MultiSearchRequest(), new BytesArray(data), false, null, null,
@ -71,9 +68,8 @@ public class MultiSearchRequestTests extends ESTestCase {
assertThat(request.requests().get(7).types().length, equalTo(0));
}
@Test
public void simpleAdd2() throws Exception {
IndicesQueriesRegistry registry = new IndicesQueriesRegistry(Settings.EMPTY, Collections.singleton(new MatchAllQueryParser()), new NamedWriteableRegistry());
public void testSimpleAdd2() throws Exception {
IndicesQueriesRegistry registry = new IndicesQueriesRegistry(Settings.EMPTY, Collections.singleton(new MatchAllQueryParser()), new NamedWriteableRegistry());
byte[] data = StreamsUtils.copyToBytesFromClasspath("/org/elasticsearch/action/search/simple-msearch2.json");
MultiSearchRequest request = RestMultiSearchAction.parseRequest(new MultiSearchRequest(), new BytesArray(data), false, null, null,
null, null, IndicesOptions.strictExpandOpenAndForbidClosed(), true, registry, ParseFieldMatcher.EMPTY);
@ -91,8 +87,7 @@ public class MultiSearchRequestTests extends ESTestCase {
assertThat(request.requests().get(4).types().length, equalTo(0));
}
@Test
public void simpleAdd3() throws Exception {
public void testSimpleAdd3() throws Exception {
IndicesQueriesRegistry registry = new IndicesQueriesRegistry(Settings.EMPTY, Collections.singleton(new MatchAllQueryParser()), new NamedWriteableRegistry());
byte[] data = StreamsUtils.copyToBytesFromClasspath("/org/elasticsearch/action/search/simple-msearch3.json");
MultiSearchRequest request = RestMultiSearchAction.parseRequest(new MultiSearchRequest(), new BytesArray(data), false, null, null,
@ -112,8 +107,7 @@ public class MultiSearchRequestTests extends ESTestCase {
assertThat(request.requests().get(3).searchType(), equalTo(SearchType.DFS_QUERY_THEN_FETCH));
}
@Test
public void simpleAdd4() throws Exception {
public void testSimpleAdd4() throws Exception {
IndicesQueriesRegistry registry = new IndicesQueriesRegistry(Settings.EMPTY, Collections.singleton(new MatchAllQueryParser()), new NamedWriteableRegistry());
byte[] data = StreamsUtils.copyToBytesFromClasspath("/org/elasticsearch/action/search/simple-msearch4.json");
MultiSearchRequest request = RestMultiSearchAction.parseRequest(new MultiSearchRequest(), new BytesArray(data), false, null, null,
@ -135,8 +129,7 @@ public class MultiSearchRequestTests extends ESTestCase {
assertThat(request.requests().get(2).routing(), equalTo("123"));
}
@Test
public void simpleAdd5() throws Exception {
public void testSimpleAdd5() throws Exception {
IndicesQueriesRegistry registry = new IndicesQueriesRegistry(Settings.EMPTY, Collections.singleton(new MatchAllQueryParser()), new NamedWriteableRegistry());
byte[] data = StreamsUtils.copyToBytesFromClasspath("/org/elasticsearch/action/search/simple-msearch5.json");
MultiSearchRequest request = RestMultiSearchAction.parseRequest(new MultiSearchRequest(), new BytesArray(data), true, null, null,

View File

@ -27,12 +27,10 @@ import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.test.ESTestCase;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.equalTo;
public class SearchRequestBuilderTests extends ESTestCase {
private static Client client;
@BeforeClass
@ -51,27 +49,23 @@ public class SearchRequestBuilderTests extends ESTestCase {
client = null;
}
@Test
public void testEmptySourceToString() {
SearchRequestBuilder searchRequestBuilder = client.prepareSearch();
assertThat(searchRequestBuilder.toString(), equalTo(new SearchSourceBuilder().toString()));
}
@Test
public void testQueryBuilderQueryToString() {
SearchRequestBuilder searchRequestBuilder = client.prepareSearch();
searchRequestBuilder.setQuery(QueryBuilders.matchAllQuery());
assertThat(searchRequestBuilder.toString(), equalTo(new SearchSourceBuilder().query(QueryBuilders.matchAllQuery()).toString()));
}
@Test
public void testSearchSourceBuilderToString() {
SearchRequestBuilder searchRequestBuilder = client.prepareSearch();
searchRequestBuilder.setSource(new SearchSourceBuilder().query(QueryBuilders.termQuery("field", "value")));
assertThat(searchRequestBuilder.toString(), equalTo(new SearchSourceBuilder().query(QueryBuilders.termQuery("field", "value")).toString()));
}
@Test
public void testThatToStringDoesntWipeRequestSource() {
SearchRequestBuilder searchRequestBuilder = client.prepareSearch().setSource(new SearchSourceBuilder().query(QueryBuilders.termQuery("field", "value")));
String preToString = searchRequestBuilder.request().toString();

View File

@ -23,14 +23,11 @@ import org.elasticsearch.Version;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.test.ESTestCase;
import org.junit.Test;
import static org.elasticsearch.test.VersionUtils.randomVersion;
import static org.hamcrest.CoreMatchers.equalTo;
public class IndicesOptionsTests extends ESTestCase {
@Test
public void testSerialization() throws Exception {
int iterations = randomIntBetween(5, 20);
for (int i = 0; i < iterations; i++) {
@ -55,7 +52,6 @@ public class IndicesOptionsTests extends ESTestCase {
}
}
@Test
public void testFromOptions() {
int iterations = randomIntBetween(5, 20);
for (int i = 0; i < iterations; i++) {

View File

@ -27,7 +27,6 @@ import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTestCase;
import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Collections;
@ -41,7 +40,9 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.notNullValue;
public class TransportActionFilterChainTests extends ESTestCase {
@ -52,9 +53,7 @@ public class TransportActionFilterChainTests extends ESTestCase {
counter = new AtomicInteger();
}
@Test
public void testActionFiltersRequest() throws ExecutionException, InterruptedException {
int numFilters = randomInt(10);
Set<Integer> orders = new HashSet<>(numFilters);
while (orders.size() < numFilters) {
@ -134,9 +133,7 @@ public class TransportActionFilterChainTests extends ESTestCase {
}
}
@Test
public void testActionFiltersResponse() throws ExecutionException, InterruptedException {
int numFilters = randomInt(10);
Set<Integer> orders = new HashSet<>(numFilters);
while (orders.size() < numFilters) {
@ -216,9 +213,7 @@ public class TransportActionFilterChainTests extends ESTestCase {
}
}
@Test
public void testTooManyContinueProcessingRequest() throws ExecutionException, InterruptedException {
final int additionalContinueCount = randomInt(10);
RequestTestFilter testFilter = new RequestTestFilter(randomInt(), new RequestCallback() {
@ -274,9 +269,7 @@ public class TransportActionFilterChainTests extends ESTestCase {
}
}
@Test
public void testTooManyContinueProcessingResponse() throws ExecutionException, InterruptedException {
final int additionalContinueCount = randomInt(10);
ResponseTestFilter testFilter = new ResponseTestFilter(randomInt(), new ResponseCallback() {

View File

@ -49,7 +49,6 @@ import org.elasticsearch.transport.TransportService;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import java.util.HashSet;
import java.util.Set;
@ -146,7 +145,6 @@ public class TransportMasterNodeActionTests extends ESTestCase {
}
}
@Test
public void testLocalOperationWithoutBlocks() throws ExecutionException, InterruptedException {
final boolean masterOperationFailure = randomBoolean();
@ -182,7 +180,6 @@ public class TransportMasterNodeActionTests extends ESTestCase {
}
}
@Test
public void testLocalOperationWithBlocks() throws ExecutionException, InterruptedException {
final boolean retryableBlock = randomBoolean();
final boolean unblockBeforeTimeout = randomBoolean();
@ -217,7 +214,6 @@ public class TransportMasterNodeActionTests extends ESTestCase {
assertListenerThrows("ClusterBlockException should be thrown", listener, ClusterBlockException.class);
}
@Test
public void testForceLocalOperation() throws ExecutionException, InterruptedException {
Request request = new Request();
PlainActionFuture<Response> listener = new PlainActionFuture<>();
@ -235,7 +231,6 @@ public class TransportMasterNodeActionTests extends ESTestCase {
listener.get();
}
@Test
public void testMasterNotAvailable() throws ExecutionException, InterruptedException {
Request request = new Request().masterNodeTimeout(TimeValue.timeValueSeconds(0));
clusterService.setState(ClusterStateCreationUtils.state(localNode, null, allNodes));
@ -245,7 +240,6 @@ public class TransportMasterNodeActionTests extends ESTestCase {
assertListenerThrows("MasterNotDiscoveredException should be thrown", listener, MasterNotDiscoveredException.class);
}
@Test
public void testMasterBecomesAvailable() throws ExecutionException, InterruptedException {
Request request = new Request();
clusterService.setState(ClusterStateCreationUtils.state(localNode, null, allNodes));
@ -257,7 +251,6 @@ public class TransportMasterNodeActionTests extends ESTestCase {
listener.get();
}
@Test
public void testDelegateToMaster() throws ExecutionException, InterruptedException {
Request request = new Request();
clusterService.setState(ClusterStateCreationUtils.state(localNode, remoteNode, allNodes));
@ -286,7 +279,6 @@ public class TransportMasterNodeActionTests extends ESTestCase {
assertThat(listener.get(), equalTo(response));
}
@Test
public void testDelegateToFailingMaster() throws ExecutionException, InterruptedException {
boolean failsWithConnectTransportException = randomBoolean();
Request request = new Request().masterNodeTimeout(TimeValue.timeValueSeconds(failsWithConnectTransportException ? 60 : 0));

View File

@ -48,7 +48,6 @@ import org.elasticsearch.transport.local.LocalTransport;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import java.io.IOException;
import java.util.Date;
@ -59,8 +58,12 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import static org.elasticsearch.action.support.replication.ClusterStateCreationUtils.*;
import static org.hamcrest.Matchers.*;
import static org.elasticsearch.action.support.replication.ClusterStateCreationUtils.state;
import static org.elasticsearch.action.support.replication.ClusterStateCreationUtils.stateWithAssignedPrimariesAndOneReplica;
import static org.elasticsearch.action.support.replication.ClusterStateCreationUtils.stateWithNoShard;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.lessThanOrEqualTo;
public class BroadcastReplicationTests extends ESTestCase {
@ -92,7 +95,6 @@ public class BroadcastReplicationTests extends ESTestCase {
threadPool = null;
}
@Test
public void testNotStartedPrimary() throws InterruptedException, ExecutionException, IOException {
final String index = "test";
clusterService.setState(state(index, randomBoolean(),
@ -112,7 +114,6 @@ public class BroadcastReplicationTests extends ESTestCase {
assertBroadcastResponse(2, 0, 0, response.get(), null);
}
@Test
public void testStartedPrimary() throws InterruptedException, ExecutionException, IOException {
final String index = "test";
clusterService.setState(state(index, randomBoolean(),
@ -128,7 +129,6 @@ public class BroadcastReplicationTests extends ESTestCase {
assertBroadcastResponse(1, 1, 0, response.get(), null);
}
@Test
public void testResultCombine() throws InterruptedException, ExecutionException, IOException {
final String index = "test";
int numShards = randomInt(3);
@ -161,7 +161,6 @@ public class BroadcastReplicationTests extends ESTestCase {
assertBroadcastResponse(2 * numShards, succeeded, failed, response.get(), Exception.class);
}
@Test
public void testNoShards() throws InterruptedException, ExecutionException, IOException {
clusterService.setState(stateWithNoShard());
logger.debug("--> using initial state:\n{}", clusterService.state().prettyPrint());
@ -169,7 +168,6 @@ public class BroadcastReplicationTests extends ESTestCase {
assertBroadcastResponse(0, 0, 0, response, null);
}
@Test
public void testShardsList() throws InterruptedException, ExecutionException {
final String index = "test";
final ShardId shardId = new ShardId(index, 0);

View File

@ -61,7 +61,6 @@ import org.elasticsearch.transport.TransportService;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import java.io.IOException;
import java.util.HashSet;
@ -125,7 +124,6 @@ public class TransportReplicationActionTests extends ESTestCase {
}
}
@Test
public void testBlocks() throws ExecutionException, InterruptedException {
Request request = new Request();
PlainActionFuture<Response> listener = new PlainActionFuture<>();
@ -162,7 +160,6 @@ public class TransportReplicationActionTests extends ESTestCase {
assertEquals(1, count.get());
}
@Test
public void testNotStartedPrimary() throws InterruptedException, ExecutionException {
final String index = "test";
final ShardId shardId = new ShardId(index, 0);
@ -192,7 +189,6 @@ public class TransportReplicationActionTests extends ESTestCase {
assertIndexShardCounter(1);
}
@Test
public void testRoutingToPrimary() {
final String index = "test";
final ShardId shardId = new ShardId(index, 0);
@ -227,7 +223,6 @@ public class TransportReplicationActionTests extends ESTestCase {
}
}
@Test
public void testWriteConsistency() throws ExecutionException, InterruptedException {
action = new ActionWithConsistency(Settings.EMPTY, "testActionWithConsistency", transportService, clusterService, threadPool);
final String index = "test";
@ -295,7 +290,6 @@ public class TransportReplicationActionTests extends ESTestCase {
}
}
@Test
public void testReplication() throws ExecutionException, InterruptedException {
final String index = "test";
final ShardId shardId = new ShardId(index, 0);
@ -319,7 +313,6 @@ public class TransportReplicationActionTests extends ESTestCase {
runReplicateTest(shardRoutingTable, assignedReplicas, totalShards);
}
@Test
public void testReplicationWithShadowIndex() throws ExecutionException, InterruptedException {
final String index = "test";
final ShardId shardId = new ShardId(index, 0);
@ -410,7 +403,6 @@ public class TransportReplicationActionTests extends ESTestCase {
assertIndexShardCounter(1);
}
@Test
public void testCounterOnPrimary() throws InterruptedException, ExecutionException, IOException {
final String index = "test";
final ShardId shardId = new ShardId(index, 0);
@ -451,7 +443,6 @@ public class TransportReplicationActionTests extends ESTestCase {
assertThat(transport.capturedRequests().length, equalTo(0));
}
@Test
public void testCounterIncrementedWhileReplicationOngoing() throws InterruptedException, ExecutionException, IOException {
final String index = "test";
final ShardId shardId = new ShardId(index, 0);
@ -479,7 +470,6 @@ public class TransportReplicationActionTests extends ESTestCase {
assertIndexShardCounter(1);
}
@Test
public void testReplicasCounter() throws Exception {
final ShardId shardId = new ShardId("test", 0);
clusterService.setState(state(shardId.index().getName(), true,
@ -514,7 +504,6 @@ public class TransportReplicationActionTests extends ESTestCase {
assertIndexShardCounter(1);
}
@Test
public void testCounterDecrementedIfShardOperationThrowsException() throws InterruptedException, ExecutionException, IOException {
action = new ActionWithExceptions(Settings.EMPTY, "testActionWithExceptions", transportService, clusterService, threadPool);
final String index = "test";

View File

@ -31,7 +31,6 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.test.ESIntegTestCase;
import org.hamcrest.Matchers;
import org.junit.Test;
import java.io.IOException;
@ -59,7 +58,6 @@ public class GetTermVectorsCheckDocFreqIT extends ESIntegTestCase {
.build();
}
@Test
public void testSimpleTermVectors() throws IOException {
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
.startObject("properties")

View File

@ -20,6 +20,7 @@
package org.elasticsearch.action.termvectors;
import com.carrotsearch.hppc.ObjectIntHashMap;
import org.apache.lucene.analysis.payloads.PayloadHelper;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.index.DirectoryReader;
@ -41,7 +42,6 @@ import org.elasticsearch.common.xcontent.json.JsonXContent;
import org.elasticsearch.index.engine.VersionConflictEngineException;
import org.elasticsearch.index.mapper.FieldMapper;
import org.hamcrest.Matcher;
import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@ -63,8 +63,6 @@ import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
@Test
public void testNoSuchDoc() throws Exception {
XContentBuilder mapping = jsonBuilder().startObject().startObject("type1")
.startObject("properties")
@ -91,7 +89,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
}
}
@Test
public void testExistingFieldWithNoTermVectorsNoNPE() throws Exception {
XContentBuilder mapping = jsonBuilder().startObject().startObject("type1")
.startObject("properties")
@ -119,7 +116,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
assertThat(actionGet.getFields().terms("existingfield"), nullValue());
}
@Test
public void testExistingFieldButNotInDocNPE() throws Exception {
XContentBuilder mapping = jsonBuilder().startObject().startObject("type1")
.startObject("properties")
@ -150,7 +146,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
assertThat(actionGet.getFields().terms("existingfield"), nullValue());
}
@Test
public void testNotIndexedField() throws Exception {
// must be of type string and indexed.
assertAcked(prepareCreate("test")
@ -193,7 +188,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
}
}
@Test
public void testSimpleTermVectors() throws IOException {
XContentBuilder mapping = jsonBuilder().startObject().startObject("type1")
.startObject("properties")
@ -231,7 +225,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
}
}
@Test
public void testRandomSingleTermVectors() throws IOException {
FieldType ft = new FieldType();
int config = randomInt(6);
@ -392,7 +385,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
return ret;
}
@Test
public void testDuelESLucene() throws Exception {
TestFieldSetting[] testFieldSettings = getFieldSettings();
createIndexBasedOnFieldSettings("test", "alias", testFieldSettings);
@ -419,7 +411,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
}
}
@Test
public void testRandomPayloadWithDelimitedPayloadTokenFilter() throws IOException {
//create the test document
int encoding = randomIntBetween(0, 2);
@ -587,7 +578,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
}
// like testSimpleTermVectors but we create fields with no term vectors
@Test
public void testSimpleTermVectorsWithGenerate() throws IOException {
String[] fieldNames = new String[10];
for (int i = 0; i < fieldNames.length; i++) {
@ -680,7 +670,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
assertThat(iterator.next(), nullValue());
}
@Test
public void testDuelWithAndWithoutTermVectors() throws IOException, ExecutionException, InterruptedException {
// setup indices
String[] indexNames = new String[] {"with_tv", "without_tv"};
@ -769,7 +758,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
assertThat(iter1.next(), nullValue());
}
@Test
public void testSimpleWildCards() throws IOException {
int numFields = 25;
@ -797,7 +785,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
assertThat("All term vectors should have been generated", response.getFields().size(), equalTo(numFields));
}
@Test
public void testArtificialVsExisting() throws ExecutionException, InterruptedException, IOException {
// setup indices
Settings.Builder settings = settingsBuilder()
@ -856,7 +843,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
}
}
@Test
public void testArtificialNoDoc() throws IOException {
// setup indices
Settings.Builder settings = settingsBuilder()
@ -885,7 +871,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
checkBrownFoxTermVector(resp.getFields(), "field1", false);
}
@Test
public void testArtificialNonExistingField() throws Exception {
// setup indices
Settings.Builder settings = settingsBuilder()
@ -933,7 +918,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
}
}
@Test
public void testPerFieldAnalyzer() throws IOException {
int numFields = 25;
@ -1030,7 +1014,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
return randomBoolean() ? "test" : "alias";
}
@Test
public void testDfs() throws ExecutionException, InterruptedException, IOException {
logger.info("Setting up the index ...");
Settings.Builder settings = settingsBuilder()
@ -1135,7 +1118,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
return lessThan(value);
}
@Test
public void testTermVectorsWithVersion() {
assertAcked(prepareCreate("test").addAlias(new Alias("alias"))
.setSettings(Settings.settingsBuilder().put("index.refresh_interval", -1)));
@ -1239,7 +1221,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
assertThat(response.getVersion(), equalTo(2l));
}
@Test
public void testFilterLength() throws ExecutionException, InterruptedException, IOException {
logger.info("Setting up the index ...");
Settings.Builder settings = settingsBuilder()
@ -1278,7 +1259,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
}
}
@Test
public void testFilterTermFreq() throws ExecutionException, InterruptedException, IOException {
logger.info("Setting up the index ...");
Settings.Builder settings = settingsBuilder()
@ -1319,7 +1299,6 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
}
}
@Test
public void testFilterDocFreq() throws ExecutionException, InterruptedException, IOException {
logger.info("Setting up the index ...");
Settings.Builder settings = settingsBuilder()

View File

@ -28,16 +28,16 @@ import org.elasticsearch.common.lucene.uid.Versions;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.index.engine.VersionConflictEngineException;
import org.junit.Test;
import java.io.IOException;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.*;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
public class MultiTermVectorsIT extends AbstractTermVectorsTestCase {
@Test
public void testDuelESLucene() throws Exception {
AbstractTermVectorsTestCase.TestFieldSetting[] testFieldSettings = getFieldSettings();
createIndexBasedOnFieldSettings("test", "alias", testFieldSettings);
@ -73,7 +73,6 @@ public class MultiTermVectorsIT extends AbstractTermVectorsTestCase {
}
@Test
public void testMissingIndexThrowsMissingIndex() throws Exception {
TermVectorsRequestBuilder requestBuilder = client().prepareTermVectors("testX", "typeX", Integer.toString(1));
MultiTermVectorsRequestBuilder mtvBuilder = client().prepareMultiTermVectors();
@ -84,7 +83,6 @@ public class MultiTermVectorsIT extends AbstractTermVectorsTestCase {
assertThat(response.getResponses()[0].getFailure().getCause().getMessage(), equalTo("no such index"));
}
@Test
public void testMultiTermVectorsWithVersion() throws Exception {
assertAcked(prepareCreate("test").addAlias(new Alias("alias"))
.setSettings(Settings.settingsBuilder().put("index.refresh_interval", -1)));

View File

@ -20,9 +20,17 @@
package org.elasticsearch.action.termvectors;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.*;
import org.apache.lucene.index.*;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.Fields;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TermQuery;
@ -44,7 +52,6 @@ import org.elasticsearch.rest.action.termvectors.RestTermVectorsAction;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.StreamsUtils;
import org.hamcrest.Matchers;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@ -57,10 +64,7 @@ import java.util.Set;
import static org.hamcrest.Matchers.equalTo;
public class TermVectorsUnitTests extends ESTestCase {
@Test
public void streamResponse() throws Exception {
public void testStreamResponse() throws Exception {
TermVectorsResponse outResponse = new TermVectorsResponse("a", "b", "c");
outResponse.setExists(true);
writeStandardTermVector(outResponse);
@ -169,7 +173,6 @@ public class TermVectorsUnitTests extends ESTestCase {
assertThat(fields.size(), equalTo(2));
}
@Test
public void testRestRequestParsing() throws Exception {
BytesReference inputBytes = new BytesArray(
" {\"fields\" : [\"a\", \"b\",\"c\"], \"offsets\":false, \"positions\":false, \"payloads\":true}");
@ -207,7 +210,6 @@ public class TermVectorsUnitTests extends ESTestCase {
}
@Test
public void testRequestParsingThrowsException() throws Exception {
BytesReference inputBytes = new BytesArray(
" {\"fields\" : \"a, b,c \", \"offsets\":false, \"positions\":false, \"payloads\":true, \"meaningless_term\":2}");
@ -223,9 +225,7 @@ public class TermVectorsUnitTests extends ESTestCase {
}
@Test
public void streamRequest() throws IOException {
public void testStreamRequest() throws IOException {
for (int i = 0; i < 10; i++) {
TermVectorsRequest request = new TermVectorsRequest("index", "type", "id");
request.offsets(random().nextBoolean());
@ -259,8 +259,7 @@ public class TermVectorsUnitTests extends ESTestCase {
}
}
@Test
public void testFieldTypeToTermVectorString() throws Exception {
FieldType ft = new FieldType();
ft.setStoreTermVectorOffsets(false);
@ -279,7 +278,6 @@ public class TermVectorsUnitTests extends ESTestCase {
assertThat("TypeParsers.parseTermVector should accept string with_positions_payloads but does not.", exceptiontrown, equalTo(false));
}
@Test
public void testTermVectorStringGenerationWithoutPositions() throws Exception {
FieldType ft = new FieldType();
ft.setStoreTermVectorOffsets(true);
@ -290,14 +288,13 @@ public class TermVectorsUnitTests extends ESTestCase {
assertThat(ftOpts, equalTo("with_offsets"));
}
@Test
public void testMultiParser() throws Exception {
byte[] data = StreamsUtils.copyToBytesFromClasspath("/org/elasticsearch/action/termvectors/multiRequest1.json");
BytesReference bytes = new BytesArray(data);
MultiTermVectorsRequest request = new MultiTermVectorsRequest();
request.add(new TermVectorsRequest(), bytes);
checkParsedParameters(request);
data = StreamsUtils.copyToBytesFromClasspath("/org/elasticsearch/action/termvectors/multiRequest2.json");
bytes = new BytesArray(data);
request = new MultiTermVectorsRequest();
@ -326,7 +323,7 @@ public class TermVectorsUnitTests extends ESTestCase {
}
}
@Test // issue #12311
// issue #12311
public void testMultiParserFilter() throws Exception {
byte[] data = StreamsUtils.copyToBytesFromClasspath("/org/elasticsearch/action/termvectors/multiRequest3.json");
BytesReference bytes = new BytesArray(data);

View File

@ -29,18 +29,17 @@ import org.elasticsearch.index.get.GetResult;
import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptService.ScriptType;
import org.elasticsearch.test.ESTestCase;
import org.junit.Test;
import java.util.Map;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.hamcrest.Matchers.*;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
public class UpdateRequestTests extends ESTestCase {
@Test
public void testUpdateRequest() throws Exception {
UpdateRequest request = new UpdateRequest("test", "type", "1");
// simple script
@ -126,7 +125,7 @@ public class UpdateRequestTests extends ESTestCase {
assertThat(((Map) doc.get("compound")).get("field2").toString(), equalTo("value2"));
}
@Test // Related to issue 3256
// Related to issue 3256
public void testUpdateRequestWithTTL() throws Exception {
long providedTTLValue = randomIntBetween(500, 1000);
Settings settings = settings(Version.CURRENT).build();

View File

@ -44,7 +44,6 @@ import org.elasticsearch.search.aggregations.bucket.global.Global;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Test;
import java.util.Arrays;
import java.util.HashSet;
@ -80,8 +79,6 @@ import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
public class IndexAliasesIT extends ESIntegTestCase {
@Test
public void testAliases() throws Exception {
logger.info("--> creating index [test]");
createIndex("test");
@ -108,7 +105,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
assertThat(indexResponse.getIndex(), equalTo("test_x"));
}
@Test
public void testFailedFilter() throws Exception {
logger.info("--> creating index [test]");
createIndex("test");
@ -134,7 +130,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
}
}
@Test
public void testFilteringAliases() throws Exception {
logger.info("--> creating index [test]");
assertAcked(prepareCreate("test").addMapping("type", "user", "type=string"));
@ -153,7 +148,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
}
@Test
public void testEmptyFilter() throws Exception {
logger.info("--> creating index [test]");
createIndex("test");
@ -163,7 +157,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
assertAcked(admin().indices().prepareAliases().addAlias("test", "alias1", "{}"));
}
@Test
public void testSearchingFilteringAliasesSingleIndex() throws Exception {
logger.info("--> creating index [test]");
assertAcked(prepareCreate("test").addMapping("type1", "id", "type=string", "name", "type=string"));
@ -244,7 +237,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
assertHits(searchResponse.getHits(), "1", "2", "3", "4");
}
@Test
public void testSearchingFilteringAliasesTwoIndices() throws Exception {
logger.info("--> creating index [test1]");
assertAcked(prepareCreate("test1").addMapping("type1", "name", "type=string"));
@ -308,7 +300,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
assertThat(client().prepareSearch("foos", "aliasToTests").setSize(0).setQuery(QueryBuilders.termQuery("name", "something")).get().getHits().totalHits(), equalTo(2L));
}
@Test
public void testSearchingFilteringAliasesMultipleIndices() throws Exception {
logger.info("--> creating indices");
createIndex("test1", "test2", "test3");
@ -373,7 +364,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
assertThat(client().prepareSearch("filter23", "filter13", "test1", "test2").setSize(0).setQuery(QueryBuilders.matchAllQuery()).get().getHits().totalHits(), equalTo(8L));
}
@Test
public void testDeletingByQueryFilteringAliases() throws Exception {
logger.info("--> creating index [test1] and [test2");
assertAcked(prepareCreate("test1").addMapping("type1", "name", "type=string"));
@ -411,9 +401,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
assertThat(client().prepareSearch("bars").setSize(0).setQuery(QueryBuilders.matchAllQuery()).get().getHits().totalHits(), equalTo(1L));
}
@Test
public void testDeleteAliases() throws Exception {
logger.info("--> creating index [test1] and [test2]");
assertAcked(prepareCreate("test1").addMapping("type", "name", "type=string"));
@ -442,8 +429,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
assertThat(response.exists(), equalTo(false));
}
@Test
public void testWaitForAliasCreationMultipleShards() throws Exception {
logger.info("--> creating index [test]");
createIndex("test");
@ -456,7 +441,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
}
}
@Test
public void testWaitForAliasCreationSingleShard() throws Exception {
logger.info("--> creating index [test]");
assertAcked(admin().indices().create(createIndexRequest("test").settings(settingsBuilder().put("index.numberOfReplicas", 0).put("index.numberOfShards", 1))).get());
@ -469,7 +453,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
}
}
@Test
public void testWaitForAliasSimultaneousUpdate() throws Exception {
final int aliasCount = 10;
@ -497,8 +480,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
}
}
@Test
public void testSameAlias() throws Exception {
logger.info("--> creating index [test]");
assertAcked(prepareCreate("test").addMapping("type", "name", "type=string"));
@ -540,18 +521,20 @@ public class IndexAliasesIT extends ESIntegTestCase {
}
@Test(expected = AliasesNotFoundException.class)
public void testIndicesRemoveNonExistingAliasResponds404() throws Exception {
logger.info("--> creating index [test]");
createIndex("test");
ensureGreen();
logger.info("--> deleting alias1 which does not exist");
assertAcked((admin().indices().prepareAliases().removeAlias("test", "alias1")));
try {
admin().indices().prepareAliases().removeAlias("test", "alias1").get();
fail("Expected AliasesNotFoundException");
} catch (AliasesNotFoundException e) {
assertThat(e.getMessage(), containsString("[alias1] missing"));
}
}
@Test
public void testIndicesGetAliases() throws Exception {
logger.info("--> creating indices [foobar, test, test123, foobarbaz, bazbar]");
createIndex("foobar");
createIndex("test");
@ -736,7 +719,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
assertThat(existsResponse.exists(), equalTo(false));
}
@Test
public void testAddAliasNullWithoutExistingIndices() {
try {
assertAcked(admin().indices().prepareAliases().addAliasAction(AliasAction.newAddAliasAction(null, "alias1")));
@ -747,7 +729,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
}
}
@Test
public void testAddAliasNullWithExistingIndices() throws Exception {
logger.info("--> creating index [test]");
createIndex("test");
@ -764,64 +745,89 @@ public class IndexAliasesIT extends ESIntegTestCase {
}
}
@Test(expected = ActionRequestValidationException.class)
public void testAddAliasEmptyIndex() {
admin().indices().prepareAliases().addAliasAction(AliasAction.newAddAliasAction("", "alias1")).get();
try {
admin().indices().prepareAliases().addAliasAction(AliasAction.newAddAliasAction("", "alias1")).get();
fail("Expected ActionRequestValidationException");
} catch (ActionRequestValidationException e) {
assertThat(e.getMessage(), containsString("[index] may not be empty string"));
}
}
@Test(expected = ActionRequestValidationException.class)
public void testAddAliasNullAlias() {
admin().indices().prepareAliases().addAliasAction(AliasAction.newAddAliasAction("index1", null)).get();
try {
admin().indices().prepareAliases().addAliasAction(AliasAction.newAddAliasAction("index1", null)).get();
fail("Expected ActionRequestValidationException");
} catch (ActionRequestValidationException e) {
assertThat(e.getMessage(), containsString("requires an [alias] to be set"));
}
}
@Test(expected = ActionRequestValidationException.class)
public void testAddAliasEmptyAlias() {
admin().indices().prepareAliases().addAliasAction(AliasAction.newAddAliasAction("index1", "")).get();
try {
admin().indices().prepareAliases().addAliasAction(AliasAction.newAddAliasAction("index1", "")).get();
fail("Expected ActionRequestValidationException");
} catch (ActionRequestValidationException e) {
assertThat(e.getMessage(), containsString("requires an [alias] to be set"));
}
}
@Test
public void testAddAliasNullAliasNullIndex() {
try {
admin().indices().prepareAliases().addAliasAction(AliasAction.newAddAliasAction(null, null)).get();
assertTrue("Should throw " + ActionRequestValidationException.class.getSimpleName(), false);
fail("Should throw " + ActionRequestValidationException.class.getSimpleName());
} catch (ActionRequestValidationException e) {
assertThat(e.validationErrors(), notNullValue());
assertThat(e.validationErrors().size(), equalTo(2));
}
}
@Test
public void testAddAliasEmptyAliasEmptyIndex() {
try {
admin().indices().prepareAliases().addAliasAction(AliasAction.newAddAliasAction("", "")).get();
assertTrue("Should throw " + ActionRequestValidationException.class.getSimpleName(), false);
fail("Should throw " + ActionRequestValidationException.class.getSimpleName());
} catch (ActionRequestValidationException e) {
assertThat(e.validationErrors(), notNullValue());
assertThat(e.validationErrors().size(), equalTo(2));
}
}
@Test(expected = ActionRequestValidationException.class)
public void tesRemoveAliasNullIndex() {
admin().indices().prepareAliases().addAliasAction(AliasAction.newRemoveAliasAction(null, "alias1")).get();
public void testRemoveAliasNullIndex() {
try {
admin().indices().prepareAliases().addAliasAction(AliasAction.newRemoveAliasAction(null, "alias1")).get();
fail("Expected ActionRequestValidationException");
} catch (ActionRequestValidationException e) {
assertThat(e.getMessage(), containsString("[index] may not be empty string"));
}
}
@Test(expected = ActionRequestValidationException.class)
public void tesRemoveAliasEmptyIndex() {
admin().indices().prepareAliases().addAliasAction(AliasAction.newRemoveAliasAction("", "alias1")).get();
public void testRemoveAliasEmptyIndex() {
try {
admin().indices().prepareAliases().addAliasAction(AliasAction.newRemoveAliasAction("", "alias1")).get();
fail("Expected ActionRequestValidationException");
} catch (ActionRequestValidationException e) {
assertThat(e.getMessage(), containsString("[index] may not be empty string"));
}
}
@Test(expected = ActionRequestValidationException.class)
public void tesRemoveAliasNullAlias() {
admin().indices().prepareAliases().addAliasAction(AliasAction.newRemoveAliasAction("index1", null)).get();
public void testRemoveAliasNullAlias() {
try {
admin().indices().prepareAliases().addAliasAction(AliasAction.newRemoveAliasAction("index1", null)).get();
fail("Expected ActionRequestValidationException");
} catch (ActionRequestValidationException e) {
assertThat(e.getMessage(), containsString("[alias] may not be empty string"));
}
}
@Test(expected = ActionRequestValidationException.class)
public void tesRemoveAliasEmptyAlias() {
admin().indices().prepareAliases().addAliasAction(AliasAction.newRemoveAliasAction("index1", "")).get();
public void testRemoveAliasEmptyAlias() {
try {
admin().indices().prepareAliases().addAliasAction(AliasAction.newRemoveAliasAction("index1", "")).get();
fail("Expected ActionRequestValidationException");
} catch (ActionRequestValidationException e) {
assertThat(e.getMessage(), containsString("[alias] may not be empty string"));
}
}
@Test
public void testRemoveAliasNullAliasNullIndex() {
try {
admin().indices().prepareAliases().addAliasAction(AliasAction.newRemoveAliasAction(null, null)).get();
@ -832,7 +838,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
}
}
@Test
public void testRemoveAliasEmptyAliasEmptyIndex() {
try {
admin().indices().prepareAliases().addAliasAction(AliasAction.newAddAliasAction("", "")).get();
@ -843,7 +848,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
}
}
@Test
public void testGetAllAliasesWorks() {
createIndex("index1");
createIndex("index2");
@ -857,7 +861,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
assertThat(response.getAliases(), hasKey("index1"));
}
@Test
public void testCreateIndexWithAliases() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type", "field", "type=string")
@ -868,7 +871,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
checkAliases();
}
@Test
public void testCreateIndexWithAliasesInSource() throws Exception {
assertAcked(prepareCreate("test").setSource("{\n" +
" \"aliases\" : {\n" +
@ -881,7 +883,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
checkAliases();
}
@Test
public void testCreateIndexWithAliasesSource() throws Exception {
assertAcked(prepareCreate("test")
.addMapping("type", "field", "type=string")
@ -894,7 +895,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
checkAliases();
}
@Test
public void testCreateIndexWithAliasesFilterNotValid() {
//non valid filter, invalid json
CreateIndexRequestBuilder createIndexRequestBuilder = prepareCreate("test").addAlias(new Alias("alias2").filter("f"));
@ -917,7 +917,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
}
}
@Test
// Before 2.0 alias filters were parsed at alias creation time, in order
// for filters to work correctly ES required that fields mentioned in those
// filters exist in the mapping.
@ -936,7 +935,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
.get();
}
@Test
public void testAliasFilterWithNowInRangeFilterAndQuery() throws Exception {
assertAcked(prepareCreate("my-index").addMapping("my-type", "_timestamp", "enabled=true"));
assertAcked(admin().indices().prepareAliases().addAlias("my-index", "filter1", rangeQuery("_timestamp").from("now-1d").to("now")));
@ -956,7 +954,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
}
}
@Test
public void testAliasesFilterWithHasChildQuery() throws Exception {
assertAcked(prepareCreate("my-index")
.addMapping("parent")
@ -977,7 +974,6 @@ public class IndexAliasesIT extends ESIntegTestCase {
assertThat(response.getHits().getAt(0).id(), equalTo("2"));
}
@Test
public void testAliasesWithBlocks() {
createIndex("test");
ensureGreen();

View File

@ -28,7 +28,6 @@ import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Test;
import java.util.HashMap;
@ -37,9 +36,7 @@ import static org.hamcrest.Matchers.notNullValue;
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST)
public class SimpleBlocksIT extends ESIntegTestCase {
@Test
public void verifyIndexAndClusterReadOnly() throws Exception {
public void testVerifyIndexAndClusterReadOnly() throws Exception {
// cluster.read_only = null: write and metadata not blocked
canCreateIndex("test1");
canIndexDocument("test1");
@ -82,7 +79,6 @@ public class SimpleBlocksIT extends ESIntegTestCase {
canIndexExists("ro");
}
@Test
public void testIndexReadWriteMetaDataBlocks() {
canCreateIndex("test1");
canIndexDocument("test1");

View File

@ -21,20 +21,16 @@ package org.elasticsearch.bootstrap;
import org.apache.lucene.util.Constants;
import org.elasticsearch.test.ESTestCase;
import org.junit.Test;
import static org.hamcrest.Matchers.equalTo;
public class JNANativesTests extends ESTestCase {
@Test
public void testMlockall() {
if (Constants.MAC_OS_X) {
assertFalse("Memory locking is not available on OS X platforms", JNANatives.LOCAL_MLOCKALL);
}
}
@Test
public void testConsoleCtrlHandler() {
if (Constants.WINDOWS) {
assertNotNull(JNAKernel32Library.getInstance());

View File

@ -20,14 +20,12 @@
package org.elasticsearch.bootstrap;
import org.elasticsearch.test.ESTestCase;
import org.junit.Test;
import java.util.List;
import static org.hamcrest.CoreMatchers.is;
public class JavaVersionTests extends ESTestCase {
@Test
public void testParse() {
JavaVersion javaVersion = JavaVersion.parse("1.7.0");
List<Integer> version = javaVersion.getVersion();
@ -37,13 +35,11 @@ public class JavaVersionTests extends ESTestCase {
assertThat(0, is(version.get(2)));
}
@Test
public void testToString() {
JavaVersion javaVersion = JavaVersion.parse("1.7.0");
assertThat("1.7.0", is(javaVersion.toString()));
}
@Test
public void testCompare() {
JavaVersion onePointSix = JavaVersion.parse("1.6");
JavaVersion onePointSeven = JavaVersion.parse("1.7");
@ -61,7 +57,6 @@ public class JavaVersionTests extends ESTestCase {
assertTrue(onePointSevenPointTwo.compareTo(onePointSevenPointTwoPointOne) < 0);
}
@Test
public void testValidVersions() {
String[] versions = new String[]{"1.7", "1.7.0", "0.1.7", "1.7.0.80"};
for (String version : versions) {
@ -69,7 +64,6 @@ public class JavaVersionTests extends ESTestCase {
}
}
@Test
public void testInvalidVersions() {
String[] versions = new String[]{"", "1.7.0_80", "1.7."};
for (String version : versions) {

View File

@ -23,7 +23,6 @@ import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Test;
import java.io.IOException;
@ -39,7 +38,6 @@ public class BroadcastActionsIT extends ESIntegTestCase {
return 1;
}
@Test
public void testBroadcastOperations() throws IOException {
assertAcked(prepareCreate("test", 1).execute().actionGet(5000));

View File

@ -19,6 +19,7 @@
package org.elasticsearch.bwcompat;
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
import org.apache.lucene.analysis.BaseTokenStreamTestCase;
import org.apache.lucene.util.TestUtil;
import org.elasticsearch.Version;
@ -26,7 +27,6 @@ import org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse;
import org.elasticsearch.indices.analysis.PreBuiltAnalyzers;
import org.elasticsearch.test.ESBackcompatTestCase;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Test;
import java.io.IOException;
import java.util.List;
@ -48,10 +48,8 @@ public class BasicAnalysisBackwardCompatibilityIT extends ESBackcompatTestCase {
* Simple upgrade test for analyzers to make sure they analyze to the same tokens after upgrade
* TODO we need this for random tokenizers / tokenfilters as well
*/
@Test
public void testAnalyzerTokensAfterUpgrade() throws IOException, ExecutionException, InterruptedException {
int numFields = randomIntBetween(PreBuiltAnalyzers.values().length, PreBuiltAnalyzers.values().length * 10);
StringBuilder builder = new StringBuilder();
String[] fields = new String[numFields * 2];
int fieldId = 0;
for (int i = 0; i < fields.length; i++) {

View File

@ -19,6 +19,7 @@
package org.elasticsearch.bwcompat;
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
import org.apache.lucene.index.Fields;
import org.apache.lucene.util.English;
import org.elasticsearch.ExceptionsHelper;
@ -31,7 +32,11 @@ import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.explain.ExplainResponse;
import org.elasticsearch.action.get.*;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.get.MultiGetItemResponse;
import org.elasticsearch.action.get.MultiGetRequest;
import org.elasticsearch.action.get.MultiGetRequestBuilder;
import org.elasticsearch.action.get.MultiGetResponse;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.action.search.SearchRequestBuilder;
@ -58,7 +63,6 @@ import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.ESBackcompatTestCase;
import org.junit.Test;
import java.io.IOException;
import java.util.ArrayList;
@ -66,11 +70,20 @@ import java.util.List;
import java.util.concurrent.ExecutionException;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.index.query.QueryBuilders.constantScoreQuery;
import static org.elasticsearch.index.query.QueryBuilders.existsQuery;
import static org.elasticsearch.index.query.QueryBuilders.missingQuery;
import static org.elasticsearch.index.query.QueryBuilders.*;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
import static org.hamcrest.Matchers.*;
import static org.elasticsearch.index.query.QueryBuilders.queryStringQuery;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchHits;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.lessThanOrEqualTo;
import static org.hamcrest.Matchers.notNullValue;
/**
*/
@ -79,7 +92,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
/**
* Basic test using Index &amp; Realtime Get with external versioning. This test ensures routing works correctly across versions.
*/
@Test
public void testExternalVersion() throws Exception {
createIndex("test");
final boolean routing = randomBoolean();
@ -103,7 +115,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
/**
* Basic test using Index &amp; Realtime Get with internal versioning. This test ensures routing works correctly across versions.
*/
@Test
public void testInternalVersion() throws Exception {
createIndex("test");
final boolean routing = randomBoolean();
@ -127,7 +138,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
/**
* Very basic bw compat test with a mixed version cluster random indexing and lookup by ID via term query
*/
@Test
public void testIndexAndSearch() throws Exception {
createIndex("test");
int numDocs = randomIntBetween(10, 20);
@ -144,7 +154,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
assertVersionCreated(compatibilityVersion(), "test");
}
@Test
public void testRecoverFromPreviousVersion() throws ExecutionException, InterruptedException {
if (backwardsCluster().numNewDataNodes() == 0) {
backwardsCluster().startNewNode();
@ -201,7 +210,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
/**
* Test that ensures that we will never recover from a newer to an older version (we are not forward compatible)
*/
@Test
public void testNoRecoveryFromNewNodes() throws ExecutionException, InterruptedException {
assertAcked(prepareCreate("test").setSettings(Settings.builder().put("index.routing.allocation.exclude._name", backwardsCluster().backwardsNodePattern()).put(indexSettings())));
if (backwardsCluster().numNewDataNodes() == 0) {
@ -269,7 +277,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
/**
* Upgrades a single node to the current version
*/
@Test
public void testIndexUpgradeSingleNode() throws Exception {
assertAcked(prepareCreate("test").setSettings(Settings.builder().put("index.routing.allocation.exclude._name", backwardsCluster().newNodePattern()).put(indexSettings())));
ensureYellow();
@ -308,7 +315,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
* one node after another is shut down and restarted from a newer version and we verify
* that all documents are still around after each nodes upgrade.
*/
@Test
public void testIndexRollingUpgrade() throws Exception {
String[] indices = new String[randomIntBetween(1, 3)];
for (int i = 0; i < indices.length; i++) {
@ -371,7 +377,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
}
@Test
public void testUnsupportedFeatures() throws IOException {
XContentBuilder mapping = XContentBuilder.builder(JsonXContent.jsonXContent)
.startObject()
@ -399,7 +404,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
* This filter had a major upgrade in 1.3 where we started to index the field names. Lets see if they still work as expected...
* this test is basically copied from SimpleQueryTests...
*/
@Test
public void testExistsFilter() throws IOException, ExecutionException, InterruptedException {
int indexId = 0;
String indexName;
@ -472,7 +476,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
return client().admin().cluster().prepareState().get().getState().nodes().masterNode().getVersion();
}
@Test
public void testDeleteRoutingRequired() throws ExecutionException, InterruptedException, IOException {
createIndexWithAlias();
assertAcked(client().admin().indices().preparePutMapping("test").setType("test").setSource(
@ -509,7 +512,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
assertThat(searchResponse.getHits().totalHits(), equalTo((long) numDocs - 1));
}
@Test
public void testIndexGetAndDelete() throws ExecutionException, InterruptedException {
createIndexWithAlias();
ensureYellow("test");
@ -546,7 +548,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
assertThat(searchResponse.getHits().totalHits(), equalTo((long) numDocs - 1));
}
@Test
public void testUpdate() {
createIndexWithAlias();
ensureYellow("test");
@ -577,7 +578,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
assertThat(getResponse.getSourceAsMap().containsKey("field2"), equalTo(true));
}
@Test
public void testAnalyze() {
createIndexWithAlias();
assertAcked(client().admin().indices().preparePutMapping("test").setType("test").setSource("field", "type=string,analyzer=keyword"));
@ -587,7 +587,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
assertThat(analyzeResponse.getTokens().get(0).getTerm(), equalTo("this is a test"));
}
@Test
public void testExplain() {
createIndexWithAlias();
ensureYellow("test");
@ -604,7 +603,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
assertThat(response.getExplanation().getDetails().length, equalTo(1));
}
@Test
public void testGetTermVector() throws IOException {
createIndexWithAlias();
assertAcked(client().admin().indices().preparePutMapping("test").setType("type1").setSource("field", "type=string,term_vector=with_positions_offsets_payloads").get());
@ -622,7 +620,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
assertThat(fields.terms("field").size(), equalTo(8l));
}
@Test
public void testIndicesStats() {
createIndex("test");
ensureYellow("test");
@ -632,7 +629,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
assertThat(indicesStatsResponse.getIndices().containsKey("test"), equalTo(true));
}
@Test
public void testMultiGet() throws ExecutionException, InterruptedException {
createIndexWithAlias();
ensureYellow("test");
@ -665,7 +661,6 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
}
@Test
public void testScroll() throws ExecutionException, InterruptedException {
createIndex("test");
ensureYellow("test");

View File

@ -30,17 +30,16 @@ import org.elasticsearch.cluster.block.ClusterBlocks;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESBackcompatTestCase;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_METADATA;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
import static org.hamcrest.Matchers.equalTo;
public class ClusterStateBackwardsCompatIT extends ESBackcompatTestCase {
@Test
public void testClusterState() throws Exception {
createIndex("test");
@ -57,7 +56,6 @@ public class ClusterStateBackwardsCompatIT extends ESBackcompatTestCase {
}
}
@Test
public void testClusterStateWithBlocks() {
createIndex("test-blocks");

View File

@ -30,7 +30,6 @@ import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.search.warmer.IndexWarmersMetaData.Entry;
import org.elasticsearch.test.ESBackcompatTestCase;
import org.junit.Test;
import java.util.List;
@ -40,8 +39,6 @@ import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
public class GetIndexBackwardsCompatibilityIT extends ESBackcompatTestCase {
@Test
public void testGetAliases() throws Exception {
CreateIndexResponse createIndexResponse = prepareCreate("test").addAlias(new Alias("testAlias")).execute().actionGet();
assertAcked(createIndexResponse);
@ -58,7 +55,6 @@ public class GetIndexBackwardsCompatibilityIT extends ESBackcompatTestCase {
assertThat(alias.alias(), equalTo("testAlias"));
}
@Test
public void testGetMappings() throws Exception {
CreateIndexResponse createIndexResponse = prepareCreate("test").addMapping("type1", "{\"type1\":{}}").execute().actionGet();
assertAcked(createIndexResponse);
@ -79,7 +75,6 @@ public class GetIndexBackwardsCompatibilityIT extends ESBackcompatTestCase {
assertThat(mapping.type(), equalTo("type1"));
}
@Test
public void testGetSettings() throws Exception {
CreateIndexResponse createIndexResponse = prepareCreate("test").setSettings(Settings.builder().put("number_of_shards", 1)).execute().actionGet();
assertAcked(createIndexResponse);
@ -93,7 +88,6 @@ public class GetIndexBackwardsCompatibilityIT extends ESBackcompatTestCase {
assertThat(settings.get("index.number_of_shards"), equalTo("1"));
}
@Test
public void testGetWarmers() throws Exception {
createIndex("test");
ensureSearchable("test");

View File

@ -25,17 +25,14 @@ import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequestBuilde
import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESBackcompatTestCase;
import org.junit.Test;
import org.elasticsearch.test.ESIntegTestCase;
import java.lang.reflect.Method;
@ESIntegTestCase.ClusterScope(scope= ESIntegTestCase.Scope.SUITE, numClientNodes = 0)
public class NodesStatsBasicBackwardsCompatIT extends ESBackcompatTestCase {
@Test
public void testNodeStatsSetIndices() throws Exception {
createIndex("test");
@ -54,7 +51,6 @@ public class NodesStatsBasicBackwardsCompatIT extends ESBackcompatTestCase {
}
}
@Test
public void testNodeStatsSetRandom() throws Exception {
createIndex("test");

View File

@ -54,7 +54,6 @@ import org.elasticsearch.test.hamcrest.ElasticsearchAssertions;
import org.hamcrest.Matchers;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import java.io.InputStream;
@ -71,7 +70,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.concurrent.Future;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
@ -277,7 +275,6 @@ public class OldIndexBackwardsCompatibilityIT extends ESIntegTestCase {
}
}
@Test
public void testHandlingOfUnsupportedDanglingIndexes() throws Exception {
setupCluster();
Collections.shuffle(unsupportedIndexes, getRandom());

View File

@ -20,13 +20,10 @@ package org.elasticsearch.bwcompat;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.node.Node;
import org.junit.Test;
import static org.hamcrest.Matchers.containsString;
public class RecoveryWithUnsupportedIndicesIT extends StaticIndexBackwardCompatibilityIT {
@Test
public void testUpgradeStartClusterOn_0_20_6() throws Exception {
String indexName = "unsupported-0.20.6";

View File

@ -34,7 +34,6 @@ import org.elasticsearch.snapshots.SnapshotInfo;
import org.elasticsearch.snapshots.SnapshotRestoreException;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.junit.Test;
import java.io.IOException;
import java.lang.reflect.Modifier;
@ -51,7 +50,10 @@ import java.util.TreeSet;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.*;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.notNullValue;
@ClusterScope(scope = Scope.TEST)
public class RestoreBackwardsCompatIT extends AbstractSnapshotIntegTestCase {
@ -79,8 +81,7 @@ public class RestoreBackwardsCompatIT extends AbstractSnapshotIntegTestCase {
}
}
@Test
public void restoreOldSnapshots() throws Exception {
public void testRestoreOldSnapshots() throws Exception {
String repo = "test_repo";
String snapshot = "test_1";
List<String> repoVersions = repoVersions();
@ -115,7 +116,6 @@ public class RestoreBackwardsCompatIT extends AbstractSnapshotIntegTestCase {
}
}
@Test
public void testRestoreUnsupportedSnapshots() throws Exception {
String repo = "test_repo";
String snapshot = "test_1";

View File

@ -29,7 +29,6 @@ import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.test.CompositeTestCluster;
import org.elasticsearch.test.ESBackcompatTestCase;
import org.junit.Test;
import java.util.concurrent.ExecutionException;
@ -38,10 +37,7 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSear
import static org.hamcrest.CoreMatchers.equalTo;
public class TransportClientBackwardsCompatibilityIT extends ESBackcompatTestCase {
@Test
public void testSniffMode() throws ExecutionException, InterruptedException {
Settings settings = Settings.builder().put(requiredSettings()).put("client.transport.nodes_sampler_interval", "1s")
.put("name", "transport_client_sniff_mode").put(ClusterName.SETTING, cluster().getClusterName())
.put("client.transport.sniff", true).build();

View File

@ -22,12 +22,10 @@ package org.elasticsearch.bwcompat;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESBackcompatTestCase;
import org.junit.Test;
import static org.hamcrest.Matchers.equalTo;
public class UnicastBackwardsCompatibilityIT extends ESBackcompatTestCase {
@Override
protected Settings nodeSettings(int nodeOrdinal) {
return Settings.builder()
@ -46,7 +44,6 @@ public class UnicastBackwardsCompatibilityIT extends ESBackcompatTestCase {
.build();
}
@Test
public void testUnicastDiscovery() {
ClusterHealthResponse healthResponse = client().admin().cluster().prepareHealth().get();
assertThat(healthResponse.getNumberOfDataNodes(), equalTo(cluster().numDataNodes()));

View File

@ -53,7 +53,6 @@ import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportMessage;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
@ -72,7 +71,6 @@ public abstract class AbstractClientHeadersTestCase extends ESTestCase {
.put(Headers.PREFIX + ".key2", "val 2")
.build();
@SuppressWarnings("unchecked")
private static final GenericAction[] ACTIONS = new GenericAction[] {
// client actions
GetAction.INSTANCE, SearchAction.INSTANCE, DeleteAction.INSTANCE, DeleteIndexedScriptAction.INSTANCE,
@ -107,7 +105,6 @@ public abstract class AbstractClientHeadersTestCase extends ESTestCase {
protected abstract Client buildClient(Settings headersSettings, GenericAction[] testedActions);
@Test
public void testActions() {
// TODO this is a really shitty way to test it, we need to figure out a way to test all the client methods
@ -134,7 +131,6 @@ public abstract class AbstractClientHeadersTestCase extends ESTestCase {
client.admin().indices().prepareFlush().execute().addListener(new AssertingActionListener<FlushResponse>(FlushAction.NAME));
}
@Test
public void testOverideHeader() throws Exception {
String key1Val = randomAsciiOfLength(5);
Map<String, Object> expected = new HashMap<>();

View File

@ -21,11 +21,10 @@ package org.elasticsearch.client.node;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Test;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import static org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.hamcrest.Matchers.is;
/**
@ -33,17 +32,14 @@ import static org.hamcrest.Matchers.is;
*/
@ClusterScope(scope = Scope.SUITE)
public class NodeClientIT extends ESIntegTestCase {
@Override
protected Settings nodeSettings(int nodeOrdinal) {
return settingsBuilder().put(super.nodeSettings(nodeOrdinal)).put(Client.CLIENT_TYPE_SETTING, "anything").build();
}
@Test
public void testThatClientTypeSettingCannotBeChanged() {
for (Settings settings : internalCluster().getInstances(Settings.class)) {
assertThat(settings.get(Client.CLIENT_TYPE_SETTING), is("node"));
}
}
}

View File

@ -46,7 +46,6 @@ import org.elasticsearch.transport.TransportRequestOptions;
import org.elasticsearch.transport.TransportResponse;
import org.elasticsearch.transport.TransportResponseHandler;
import org.elasticsearch.transport.TransportService;
import org.junit.Test;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@ -75,7 +74,6 @@ public class TransportClientHeadersTests extends AbstractClientHeadersTestCase {
return client;
}
@Test
public void testWithSniffing() throws Exception {
TransportClient client = TransportClient.builder()
.settings(Settings.builder()

View File

@ -28,12 +28,11 @@ import org.elasticsearch.node.Node;
import org.elasticsearch.node.internal.InternalSettingsPreparer;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.transport.TransportService;
import org.junit.Test;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
import static org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.is;
@ -41,8 +40,6 @@ import static org.hamcrest.Matchers.startsWith;
@ClusterScope(scope = Scope.TEST, numDataNodes = 0, transportClientRatio = 1.0)
public class TransportClientIT extends ESIntegTestCase {
@Test
public void testPickingUpChangesInDiscoveryNode() {
String nodeName = internalCluster().startNode(Settings.builder().put("node.data", false));
@ -51,7 +48,6 @@ public class TransportClientIT extends ESIntegTestCase {
}
@Test
public void testNodeVersionIsUpdated() {
TransportClient client = (TransportClient) internalCluster().client();
TransportClientNodesService nodeService = client.nodeService();
@ -85,14 +81,12 @@ public class TransportClientIT extends ESIntegTestCase {
}
}
@Test
public void testThatTransportClientSettingIsSet() {
TransportClient client = (TransportClient) internalCluster().client();
Settings settings = client.injector.getInstance(Settings.class);
assertThat(settings.get(Client.CLIENT_TYPE_SETTING), is("transport"));
}
@Test
public void testThatTransportClientSettingCannotBeChanged() {
Settings baseSettings = settingsBuilder().put(Client.CLIENT_TYPE_SETTING, "anything").put("path.home", createTempDir()).build();
try (TransportClient client = TransportClient.builder().settings(baseSettings).build()) {

View File

@ -28,8 +28,12 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.LocalTransportAddress;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.*;
import org.junit.Test;
import org.elasticsearch.transport.BaseTransportResponseHandler;
import org.elasticsearch.transport.TransportException;
import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.transport.TransportRequestOptions;
import org.elasticsearch.transport.TransportResponse;
import org.elasticsearch.transport.TransportService;
import java.io.Closeable;
import java.util.Collections;
@ -39,7 +43,9 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.Matchers.lessThanOrEqualTo;
import static org.hamcrest.Matchers.notNullValue;
@ -89,9 +95,7 @@ public class TransportClientNodesServiceTests extends ESTestCase {
}
}
@Test
public void testListenerFailures() throws InterruptedException {
int iters = iterations(10, 100);
for (int i = 0; i <iters; i++) {
try(final TestIteration iteration = new TestIteration()) {

View File

@ -29,26 +29,22 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.node.internal.InternalSettingsPreparer;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.transport.TransportService;
import org.junit.Test;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import static org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
@ClusterScope(scope = Scope.TEST, numClientNodes = 0)
@TestLogging("discovery.zen:TRACE")
public class TransportClientRetryIT extends ESIntegTestCase {
@Test
public void testRetry() throws IOException, ExecutionException, InterruptedException {
Iterable<TransportService> instances = internalCluster().getInstances(TransportService.class);
TransportAddress[] addresses = new TransportAddress[internalCluster().size()];
int i = 0;

View File

@ -23,15 +23,11 @@ import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
import org.elasticsearch.common.Priority;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Test;
import static org.hamcrest.Matchers.equalTo;
public class ClusterHealthIT extends ESIntegTestCase {
@Test
public void simpleLocalHealthTest() {
public void testSimpleLocalHealth() {
createIndex("test");
ensureGreen(); // master should thing it's green now.
@ -43,7 +39,6 @@ public class ClusterHealthIT extends ESIntegTestCase {
}
}
@Test
public void testHealth() {
logger.info("--> running cluster health on an index that does not exists");
ClusterHealthResponse healthResponse = client().admin().cluster().prepareHealth("test1").setWaitForYellowStatus().setTimeout("1s").execute().actionGet();

View File

@ -52,7 +52,6 @@ import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.transport.TransportRequestOptions;
import org.elasticsearch.transport.TransportService;
import org.hamcrest.Matchers;
import org.junit.Test;
import java.io.IOException;
import java.util.Collection;
@ -137,7 +136,6 @@ public class ClusterInfoServiceIT extends ESIntegTestCase {
MockTransportService.TestPlugin.class);
}
@Test
public void testClusterInfoServiceCollectsInformation() throws Exception {
internalCluster().startNodesAsync(2,
Settings.builder().put(InternalClusterInfoService.INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL, "200ms").build())
@ -187,7 +185,6 @@ public class ClusterInfoServiceIT extends ESIntegTestCase {
}
@Test
public void testClusterInfoServiceInformationClearOnError() throws InterruptedException, ExecutionException {
internalCluster().startNodesAsync(2,
// manually control publishing

View File

@ -37,21 +37,29 @@ import org.elasticsearch.discovery.zen.ZenDiscovery;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.InternalTestCluster;
import org.elasticsearch.test.MockLogAppender;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.threadpool.ThreadPool;
import org.junit.Test;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.*;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
/**
*
@ -65,7 +73,6 @@ public class ClusterServiceIT extends ESIntegTestCase {
return pluginList(TestPlugin.class);
}
@Test
public void testTimeoutUpdateTask() throws Exception {
Settings settings = settingsBuilder()
.put("discovery.type", "local")
@ -134,7 +141,6 @@ public class ClusterServiceIT extends ESIntegTestCase {
assertThat(executeCalled.get(), equalTo(false));
}
@Test
public void testAckedUpdateTask() throws Exception {
Settings settings = settingsBuilder()
.put("discovery.type", "local")
@ -211,7 +217,6 @@ public class ClusterServiceIT extends ESIntegTestCase {
assertThat(processedLatch.await(1, TimeUnit.SECONDS), equalTo(true));
}
@Test
public void testAckedUpdateTaskSameClusterState() throws Exception {
Settings settings = settingsBuilder()
.put("discovery.type", "local")
@ -283,7 +288,6 @@ public class ClusterServiceIT extends ESIntegTestCase {
assertThat(processedLatch.await(1, TimeUnit.SECONDS), equalTo(true));
}
@Test
public void testMasterAwareExecution() throws Exception {
Settings settings = settingsBuilder()
.put("discovery.type", "local")
@ -340,7 +344,6 @@ public class ClusterServiceIT extends ESIntegTestCase {
assertFalse("non-master cluster state update task was not executed", taskFailed[0]);
}
@Test
public void testAckedUpdateTaskNoAckExpected() throws Exception {
Settings settings = settingsBuilder()
.put("discovery.type", "local")
@ -413,7 +416,6 @@ public class ClusterServiceIT extends ESIntegTestCase {
assertThat(onFailure.get(), equalTo(false));
}
@Test
public void testAckedUpdateTaskTimeoutZero() throws Exception {
Settings settings = settingsBuilder()
.put("discovery.type", "local")
@ -490,7 +492,6 @@ public class ClusterServiceIT extends ESIntegTestCase {
assertThat(processedLatch.await(1, TimeUnit.SECONDS), equalTo(true));
}
@Test
public void testPendingUpdateTask() throws Exception {
Settings settings = settingsBuilder()
.put("discovery.type", "local")
@ -626,7 +627,6 @@ public class ClusterServiceIT extends ESIntegTestCase {
block2.countDown();
}
@Test
public void testLocalNodeMasterListenerCallbacks() throws Exception {
Settings settings = settingsBuilder()
.put("discovery.type", "zen")
@ -705,7 +705,6 @@ public class ClusterServiceIT extends ESIntegTestCase {
/**
* Note, this test can only work as long as we have a single thread executor executing the state update tasks!
*/
@Test
public void testPrioritizedTasks() throws Exception {
Settings settings = settingsBuilder()
.put("discovery.type", "local")
@ -738,7 +737,6 @@ public class ClusterServiceIT extends ESIntegTestCase {
}
}
@Test
@TestLogging("cluster:TRACE") // To ensure that we log cluster state events on TRACE level
public void testClusterStateUpdateLogging() throws Exception {
Settings settings = settingsBuilder()
@ -828,7 +826,6 @@ public class ClusterServiceIT extends ESIntegTestCase {
mockAppender.assertAllExpectationsMatched();
}
@Test
@TestLogging("cluster:WARN") // To ensure that we log cluster state events on WARN level
public void testLongClusterStateUpdateLogging() throws Exception {
Settings settings = settingsBuilder()

View File

@ -53,7 +53,6 @@ import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.warmer.IndexWarmersMetaData;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Test;
import java.util.Collections;
import java.util.List;
@ -71,8 +70,6 @@ import static org.hamcrest.Matchers.is;
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE, numDataNodes = 0, numClientNodes = 0)
public class ClusterStateDiffIT extends ESIntegTestCase {
@Test
public void testClusterStateDiffSerialization() throws Exception {
DiscoveryNode masterNode = new DiscoveryNode("master", new LocalTransportAddress("master"), Version.CURRENT);
DiscoveryNode otherNode = new DiscoveryNode("other", new LocalTransportAddress("other"), Version.CURRENT);

View File

@ -18,7 +18,6 @@
*/
package org.elasticsearch.cluster;
import com.carrotsearch.randomizedtesting.annotations.Repeat;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.node.DiscoveryNodes;

View File

@ -33,16 +33,13 @@ import org.elasticsearch.index.shard.ShardPath;
import org.elasticsearch.index.store.StoreStats;
import org.elasticsearch.monitor.fs.FsInfo;
import org.elasticsearch.test.ESTestCase;
import org.junit.Test;
import java.nio.file.Path;
import static org.hamcrest.Matchers.equalTo;
public class DiskUsageTests extends ESTestCase {
@Test
public void diskUsageCalcTest() {
public void testDiskUsageCalc() {
DiskUsage du = new DiskUsage("node1", "n1", "random", 100, 40);
assertThat(du.getFreeDiskAsPercentage(), equalTo(40.0));
assertThat(du.getUsedDiskAsPercentage(), equalTo(100.0 - 40.0));
@ -71,8 +68,7 @@ public class DiskUsageTests extends ESTestCase {
assertThat(du4.getTotalBytes(), equalTo(0L));
}
@Test
public void randomDiskUsageTest() {
public void testRandomDiskUsage() {
int iters = scaledRandomIntBetween(1000, 10000);
for (int i = 1; i < iters; i++) {
long total = between(Integer.MIN_VALUE, Integer.MAX_VALUE);

View File

@ -34,12 +34,16 @@ import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.disruption.NetworkDelaysPartition;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.test.transport.MockTransportService;
import org.junit.Test;
import java.util.*;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
@ -47,9 +51,15 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Predicate;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
import static org.hamcrest.Matchers.*;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoTimeout;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.isOneOf;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue;
@ClusterScope(scope = Scope.TEST, numDataNodes = 0)
@ESIntegTestCase.SuppressLocalMode
@ -62,9 +72,8 @@ public class MinimumMasterNodesIT extends ESIntegTestCase {
return classes;
}
@Test
@TestLogging("cluster.service:TRACE,discovery.zen:TRACE,gateway:TRACE,transport.tracer:TRACE")
public void simpleMinimumMasterNodes() throws Exception {
public void testSimpleMinimumMasterNodes() throws Exception {
Settings settings = settingsBuilder()
.put("discovery.type", "zen")
@ -177,8 +186,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase {
}
}
@Test
public void multipleNodesShutdownNonMasterNodes() throws Exception {
public void testMultipleNodesShutdownNonMasterNodes() throws Exception {
Settings settings = settingsBuilder()
.put("discovery.type", "zen")
.put("discovery.zen.minimum_master_nodes", 3)
@ -254,8 +262,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase {
}
}
@Test
public void dynamicUpdateMinimumMasterNodes() throws Exception {
public void testDynamicUpdateMinimumMasterNodes() throws Exception {
Settings settings = settingsBuilder()
.put("discovery.type", "zen")
.put(ZenDiscovery.SETTING_PING_TIMEOUT, "400ms")
@ -312,7 +319,6 @@ public class MinimumMasterNodesIT extends ESIntegTestCase {
);
}
@Test
public void testCanNotBringClusterDown() throws ExecutionException, InterruptedException {
int nodeCount = scaledRandomIntBetween(1, 5);
Settings.Builder settings = settingsBuilder()

View File

@ -39,22 +39,23 @@ import org.elasticsearch.script.ScriptService;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.junit.Test;
import java.util.HashMap;
import static org.elasticsearch.action.percolate.PercolateSourceBuilder.docBuilder;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
import static org.hamcrest.Matchers.*;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertExists;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.lessThan;
/**
*/
@ClusterScope(scope = Scope.TEST, numDataNodes = 0)
@ESIntegTestCase.SuppressLocalMode
public class NoMasterNodeIT extends ESIntegTestCase {
@Test
public void testNoMasterActions() throws Exception {
// note, sometimes, we want to check with the fact that an index gets created, sometimes not...
boolean autoCreateIndex = randomBoolean();
@ -211,8 +212,7 @@ public class NoMasterNodeIT extends ESIntegTestCase {
}
}
@Test
public void testNoMasterActions_writeMasterBlock() throws Exception {
public void testNoMasterActionsWriteMasterBlock() throws Exception {
Settings settings = settingsBuilder()
.put("discovery.type", "zen")
.put("action.auto_create_index", false)

View File

@ -34,11 +34,12 @@ import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.hamcrest.CollectionAssertions;
import org.junit.Before;
import org.junit.Test;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertIndexTemplateExists;
import static org.hamcrest.Matchers.*;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.is;
/**
* Checking simple filtering capabilites of the cluster state
@ -54,7 +55,6 @@ public class SimpleClusterStateIT extends ESIntegTestCase {
refresh();
}
@Test
public void testRoutingTable() throws Exception {
ClusterStateResponse clusterStateResponseUnfiltered = client().admin().cluster().prepareState().clear().setRoutingTable(true).get();
assertThat(clusterStateResponseUnfiltered.getState().routingTable().hasIndex("foo"), is(true));
@ -69,7 +69,6 @@ public class SimpleClusterStateIT extends ESIntegTestCase {
assertThat(clusterStateResponse.getState().routingTable().hasIndex("non-existent"), is(false));
}
@Test
public void testNodes() throws Exception {
ClusterStateResponse clusterStateResponse = client().admin().cluster().prepareState().clear().setNodes(true).get();
assertThat(clusterStateResponse.getState().nodes().nodes().size(), is(cluster().size()));
@ -78,7 +77,6 @@ public class SimpleClusterStateIT extends ESIntegTestCase {
assertThat(clusterStateResponseFiltered.getState().nodes().nodes().size(), is(0));
}
@Test
public void testMetadata() throws Exception {
ClusterStateResponse clusterStateResponseUnfiltered = client().admin().cluster().prepareState().clear().setMetaData(true).get();
assertThat(clusterStateResponseUnfiltered.getState().metaData().indices().size(), is(3));
@ -87,7 +85,6 @@ public class SimpleClusterStateIT extends ESIntegTestCase {
assertThat(clusterStateResponse.getState().metaData().indices().size(), is(0));
}
@Test
public void testIndexTemplates() throws Exception {
client().admin().indices().preparePutTemplate("foo_template")
.setTemplate("te*")
@ -113,7 +110,6 @@ public class SimpleClusterStateIT extends ESIntegTestCase {
assertIndexTemplateExists(getIndexTemplatesResponse, "foo_template");
}
@Test
public void testThatFilteringByIndexWorksForMetadataAndRoutingTable() throws Exception {
ClusterStateResponse clusterStateResponseFiltered = client().admin().cluster().prepareState().clear()
.setMetaData(true).setRoutingTable(true).setIndices("foo", "fuu", "non-existent").get();
@ -129,7 +125,6 @@ public class SimpleClusterStateIT extends ESIntegTestCase {
assertThat(clusterStateResponseFiltered.getState().routingTable().hasIndex("baz"), is(false));
}
@Test
public void testLargeClusterStatePublishing() throws Exception {
int estimatedBytesSize = scaledRandomIntBetween(ByteSizeValue.parseBytesSizeValue("10k", "estimatedBytesSize").bytesAsInt(),
ByteSizeValue.parseBytesSizeValue("256k", "estimatedBytesSize").bytesAsInt());
@ -162,7 +157,6 @@ public class SimpleClusterStateIT extends ESIntegTestCase {
}
}
@Test
public void testIndicesOptions() throws Exception {
ClusterStateResponse clusterStateResponse = client().admin().cluster().prepareState().clear().setMetaData(true).setIndices("f*")
.get();
@ -195,17 +189,25 @@ public class SimpleClusterStateIT extends ESIntegTestCase {
assertThat(clusterStateResponse.getState().metaData().indices().isEmpty(), is(true));
}
@Test(expected=IndexNotFoundException.class)
public void testIndicesOptionsOnAllowNoIndicesFalse() throws Exception {
// empty wildcard expansion throws exception when allowNoIndices is turned off
IndicesOptions allowNoIndices = IndicesOptions.fromOptions(false, false, true, false);
client().admin().cluster().prepareState().clear().setMetaData(true).setIndices("a*").setIndicesOptions(allowNoIndices).get();
try {
client().admin().cluster().prepareState().clear().setMetaData(true).setIndices("a*").setIndicesOptions(allowNoIndices).get();
fail("Expected IndexNotFoundException");
} catch (IndexNotFoundException e) {
assertThat(e.getMessage(), is("no such index"));
}
}
@Test(expected=IndexNotFoundException.class)
public void testIndicesIgnoreUnavailableFalse() throws Exception {
// ignore_unavailable set to false throws exception when allowNoIndices is turned off
IndicesOptions allowNoIndices = IndicesOptions.fromOptions(false, true, true, false);
client().admin().cluster().prepareState().clear().setMetaData(true).setIndices("fzzbzz").setIndicesOptions(allowNoIndices).get();
try {
client().admin().cluster().prepareState().clear().setMetaData(true).setIndices("fzzbzz").setIndicesOptions(allowNoIndices).get();
fail("Expected IndexNotFoundException");
} catch (IndexNotFoundException e) {
assertThat(e.getMessage(), is("no such index"));
}
}
}

View File

@ -25,12 +25,11 @@ import org.elasticsearch.client.Requests;
import org.elasticsearch.common.Priority;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.junit.Test;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.elasticsearch.client.Requests.createIndexRequest;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds;
import static org.elasticsearch.test.ESIntegTestCase.*;
import static org.hamcrest.Matchers.equalTo;
/**
@ -38,8 +37,6 @@ import static org.hamcrest.Matchers.equalTo;
*/
@ClusterScope(scope= Scope.TEST, numDataNodes =0)
public class SimpleDataNodesIT extends ESIntegTestCase {
@Test
public void testDataNodes() throws Exception {
internalCluster().startNode(settingsBuilder().put("node.data", false).build());
client().admin().indices().create(createIndexRequest("test")).actionGet();

View File

@ -25,24 +25,23 @@ import org.elasticsearch.discovery.MasterNotDiscoveredException;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.junit.Test;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import java.io.IOException;
import static org.elasticsearch.test.ESIntegTestCase.*;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.*;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
@ClusterScope(scope = Scope.TEST, numDataNodes = 0)
@ESIntegTestCase.SuppressLocalMode
public class SpecificMasterNodesIT extends ESIntegTestCase {
protected final Settings.Builder settingsBuilder() {
return Settings.builder().put("discovery.type", "zen");
}
@Test
public void simpleOnlyMasterNodeElection() throws IOException {
public void testSimpleOnlyMasterNodeElection() throws IOException {
logger.info("--> start data node / non master node");
internalCluster().startNode(settingsBuilder().put("node.data", true).put("node.master", false).put("discovery.initial_state_timeout", "1s"));
try {
@ -72,8 +71,7 @@ public class SpecificMasterNodesIT extends ESIntegTestCase {
assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().name(), equalTo(nextMasterEligibleNodeName));
}
@Test
public void electOnlyBetweenMasterNodes() throws IOException {
public void testElectOnlyBetweenMasterNodes() throws IOException {
logger.info("--> start data node / non master node");
internalCluster().startNode(settingsBuilder().put("node.data", true).put("node.master", false).put("discovery.initial_state_timeout", "1s"));
try {
@ -103,7 +101,6 @@ public class SpecificMasterNodesIT extends ESIntegTestCase {
* Tests that putting custom default mapping and then putting a type mapping will have the default mapping merged
* to the type mapping.
*/
@Test
public void testCustomDefaultMapping() throws Exception {
logger.info("--> start master node / non data");
internalCluster().startNode(settingsBuilder().put("node.data", false).put("node.master", true));
@ -124,7 +121,6 @@ public class SpecificMasterNodesIT extends ESIntegTestCase {
assertThat(type1Mapping.getSourceAsMap().get("_timestamp"), notNullValue());
}
@Test
public void testAliasFilterValidation() throws Exception {
logger.info("--> start master node / non data");
internalCluster().startNode(settingsBuilder().put("node.data", false).put("node.master", true));

View File

@ -23,20 +23,17 @@ import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.common.Priority;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.junit.Test;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import java.util.List;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.test.ESIntegTestCase.*;
import static org.hamcrest.Matchers.equalTo;
/**
*/
@ClusterScope(scope= Scope.TEST, numDataNodes =0)
public class UpdateSettingsValidationIT extends ESIntegTestCase {
@Test
public void testUpdateSettingsValidation() throws Exception {
List<String> nodes = internalCluster().startNodesAsync(
settingsBuilder().put("node.data", false).build(),

View File

@ -33,10 +33,9 @@ import org.elasticsearch.cluster.routing.allocation.decider.ThrottlingAllocation
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.discovery.DiscoverySettings;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Test;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import static org.elasticsearch.test.ESIntegTestCase.Scope.TEST;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.equalTo;
@ -71,7 +70,6 @@ public class AckClusterUpdateSettingsIT extends ESIntegTestCase {
assertAcked(client().admin().cluster().prepareUpdateSettings().setTransientSettings(Settings.builder().put(DiscoverySettings.PUBLISH_TIMEOUT, "0")));
}
@Test
public void testClusterUpdateSettingsAcknowledgement() {
createIndex("test");
ensureGreen();
@ -112,7 +110,6 @@ public class AckClusterUpdateSettingsIT extends ESIntegTestCase {
}
}
@Test
public void testClusterUpdateSettingsNoAcknowledgement() {
client().admin().indices().prepareCreate("test")
.setSettings(settingsBuilder()
@ -143,7 +140,6 @@ public class AckClusterUpdateSettingsIT extends ESIntegTestCase {
return client.admin().cluster().prepareState().setLocal(true).get().getState();
}
@Test
public void testOpenIndexNoAcknowledgement() {
createIndex("test");
ensureGreen();

View File

@ -20,6 +20,7 @@
package org.elasticsearch.cluster.ack;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
import org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteResponse;
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse;
@ -35,6 +36,7 @@ import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.AliasMetaData;
import org.elasticsearch.cluster.metadata.AliasOrIndex;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.IndexMetaData.State;
import org.elasticsearch.cluster.routing.RoutingNode;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.routing.ShardRoutingState;
@ -44,16 +46,18 @@ import org.elasticsearch.discovery.DiscoverySettings;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.warmer.IndexWarmersMetaData;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Test;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import java.util.List;
import java.util.concurrent.TimeUnit;
import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.*;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
@ClusterScope(minNumDataNodes = 2)
public class AckIT extends ESIntegTestCase {
@ -66,7 +70,6 @@ public class AckIT extends ESIntegTestCase {
.put(DiscoverySettings.PUBLISH_TIMEOUT, 0).build();
}
@Test
public void testUpdateSettingsAcknowledgement() {
createIndex("test");
@ -79,7 +82,6 @@ public class AckIT extends ESIntegTestCase {
}
}
@Test
public void testUpdateSettingsNoAcknowledgement() {
createIndex("test");
UpdateSettingsResponse updateSettingsResponse = client().admin().indices().prepareUpdateSettings("test").setTimeout("0s")
@ -87,7 +89,6 @@ public class AckIT extends ESIntegTestCase {
assertThat(updateSettingsResponse.isAcknowledged(), equalTo(false));
}
@Test
public void testPutWarmerAcknowledgement() {
createIndex("test");
// make sure one shard is started so the search during put warmer will not fail
@ -106,7 +107,6 @@ public class AckIT extends ESIntegTestCase {
}
}
@Test
public void testPutWarmerNoAcknowledgement() throws InterruptedException {
createIndex("test");
// make sure one shard is started so the search during put warmer will not fail
@ -131,7 +131,6 @@ public class AckIT extends ESIntegTestCase {
assertAcked(client().admin().indices().prepareDeleteWarmer().setIndices("test").setNames("custom_warmer"));
}
@Test
public void testDeleteWarmerAcknowledgement() {
createIndex("test");
index("test", "type", "1", "f", 1);
@ -147,7 +146,6 @@ public class AckIT extends ESIntegTestCase {
}
}
@Test
public void testDeleteWarmerNoAcknowledgement() throws InterruptedException {
createIndex("test");
index("test", "type", "1", "f", 1);
@ -168,7 +166,6 @@ public class AckIT extends ESIntegTestCase {
}));
}
@Test
public void testClusterRerouteAcknowledgement() throws InterruptedException {
assertAcked(prepareCreate("test").setSettings(Settings.builder()
.put(indexSettings())
@ -203,7 +200,6 @@ public class AckIT extends ESIntegTestCase {
}
}
@Test
public void testClusterRerouteNoAcknowledgement() throws InterruptedException {
client().admin().indices().prepareCreate("test")
.setSettings(settingsBuilder()
@ -217,7 +213,6 @@ public class AckIT extends ESIntegTestCase {
assertThat(clusterRerouteResponse.isAcknowledged(), equalTo(false));
}
@Test
public void testClusterRerouteAcknowledgementDryRun() throws InterruptedException {
client().admin().indices().prepareCreate("test")
.setSettings(settingsBuilder()
@ -250,7 +245,6 @@ public class AckIT extends ESIntegTestCase {
}
}
@Test
public void testClusterRerouteNoAcknowledgementDryRun() throws InterruptedException {
client().admin().indices().prepareCreate("test")
.setSettings(settingsBuilder()
@ -293,7 +287,6 @@ public class AckIT extends ESIntegTestCase {
return new MoveAllocationCommand(shardToBeMoved.shardId(), fromNodeId, toNodeId);
}
@Test
public void testIndicesAliasesAcknowledgement() {
createIndex("test");
@ -310,7 +303,6 @@ public class AckIT extends ESIntegTestCase {
}
}
@Test
public void testIndicesAliasesNoAcknowledgement() {
createIndex("test");
@ -330,7 +322,6 @@ public class AckIT extends ESIntegTestCase {
}
}
@Test
public void testCloseIndexNoAcknowledgement() {
createIndex("test");
ensureGreen();
@ -339,7 +330,6 @@ public class AckIT extends ESIntegTestCase {
assertThat(closeIndexResponse.isAcknowledged(), equalTo(false));
}
@Test
public void testOpenIndexAcknowledgement() {
createIndex("test");
ensureGreen();
@ -354,7 +344,6 @@ public class AckIT extends ESIntegTestCase {
}
}
@Test
public void testPutMappingAcknowledgement() {
createIndex("test");
ensureGreen();
@ -366,7 +355,6 @@ public class AckIT extends ESIntegTestCase {
}
}
@Test
public void testPutMappingNoAcknowledgement() {
createIndex("test");
ensureGreen();
@ -375,7 +363,6 @@ public class AckIT extends ESIntegTestCase {
assertThat(putMappingResponse.isAcknowledged(), equalTo(false));
}
@Test
public void testCreateIndexAcknowledgement() {
createIndex("test");
@ -388,7 +375,6 @@ public class AckIT extends ESIntegTestCase {
ensureGreen();
}
@Test
public void testCreateIndexNoAcknowledgement() {
CreateIndexResponse createIndexResponse = client().admin().indices().prepareCreate("test").setTimeout("0s").get();
assertThat(createIndexResponse.isAcknowledged(), equalTo(false));

View File

@ -20,6 +20,7 @@
package org.elasticsearch.cluster.allocation;
import com.carrotsearch.hppc.ObjectIntHashMap;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.routing.IndexRoutingTable;
@ -34,7 +35,6 @@ import org.elasticsearch.discovery.zen.ZenDiscovery;
import org.elasticsearch.discovery.zen.elect.ElectMasterService;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.junit.Test;
import java.util.List;
import java.util.concurrent.TimeUnit;
@ -55,7 +55,6 @@ public class AwarenessAllocationIT extends ESIntegTestCase {
return 1;
}
@Test
public void testSimpleAwareness() throws Exception {
Settings commonSettings = Settings.settingsBuilder()
.put("cluster.routing.allocation.awareness.attributes", "rack_id")
@ -104,8 +103,7 @@ public class AwarenessAllocationIT extends ESIntegTestCase {
TimeUnit.SECONDS
), equalTo(true));
}
@Test
public void testAwarenessZones() throws Exception {
Settings commonSettings = Settings.settingsBuilder()
.put(AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_FORCE_GROUP + "zone.values", "a,b")
@ -153,8 +151,7 @@ public class AwarenessAllocationIT extends ESIntegTestCase {
assertThat(counts.get(A_0), anyOf(equalTo(2),equalTo(3)));
assertThat(counts.get(B_0), anyOf(equalTo(2),equalTo(3)));
}
@Test
public void testAwarenessZonesIncrementalNodes() throws Exception {
Settings commonSettings = Settings.settingsBuilder()
.put("cluster.routing.allocation.awareness.force.zone.values", "a,b")
@ -208,7 +205,7 @@ public class AwarenessAllocationIT extends ESIntegTestCase {
assertThat(counts.get(A_0), equalTo(5));
assertThat(counts.get(B_0), equalTo(3));
assertThat(counts.get(B_1), equalTo(2));
String noZoneNode = internalCluster().startNode();
health = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().setWaitForNodes("4").execute().actionGet();
assertThat(health.isTimedOut(), equalTo(false));
@ -227,7 +224,7 @@ public class AwarenessAllocationIT extends ESIntegTestCase {
}
}
}
assertThat(counts.get(A_0), equalTo(5));
assertThat(counts.get(B_0), equalTo(3));
assertThat(counts.get(B_1), equalTo(2));
@ -248,7 +245,7 @@ public class AwarenessAllocationIT extends ESIntegTestCase {
}
}
}
assertThat(counts.get(A_0), equalTo(3));
assertThat(counts.get(B_0), equalTo(3));
assertThat(counts.get(B_1), equalTo(2));

View File

@ -45,17 +45,19 @@ import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.InternalTestCluster;
import org.junit.Test;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_METADATA;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
import static org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
import static org.hamcrest.Matchers.equalTo;
@ -65,11 +67,9 @@ import static org.hamcrest.Matchers.hasSize;
*/
@ClusterScope(scope = Scope.TEST, numDataNodes = 0)
public class ClusterRerouteIT extends ESIntegTestCase {
private final ESLogger logger = Loggers.getLogger(ClusterRerouteIT.class);
@Test
public void rerouteWithCommands_disableAllocationSettings() throws Exception {
public void testRerouteWithCommands_disableAllocationSettings() throws Exception {
Settings commonSettings = settingsBuilder()
.put(EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE, "none")
.put(EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE, "none")
@ -77,8 +77,7 @@ public class ClusterRerouteIT extends ESIntegTestCase {
rerouteWithCommands(commonSettings);
}
@Test
public void rerouteWithCommands_enableAllocationSettings() throws Exception {
public void testRerouteWithCommands_enableAllocationSettings() throws Exception {
Settings commonSettings = settingsBuilder()
.put(CLUSTER_ROUTING_ALLOCATION_ENABLE, Allocation.NONE.name())
.build();
@ -146,8 +145,7 @@ public class ClusterRerouteIT extends ESIntegTestCase {
assertThat(state.getRoutingNodes().node(state.nodes().resolveNode(node_2).id()).get(0).state(), equalTo(ShardRoutingState.STARTED));
}
@Test
public void rerouteWithAllocateLocalGateway_disableAllocationSettings() throws Exception {
public void testRerouteWithAllocateLocalGateway_disableAllocationSettings() throws Exception {
Settings commonSettings = settingsBuilder()
.put(EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE, "none")
.put(EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE, "none")
@ -155,15 +153,13 @@ public class ClusterRerouteIT extends ESIntegTestCase {
rerouteWithAllocateLocalGateway(commonSettings);
}
@Test
public void rerouteWithAllocateLocalGateway_enableAllocationSettings() throws Exception {
public void testRerouteWithAllocateLocalGateway_enableAllocationSettings() throws Exception {
Settings commonSettings = settingsBuilder()
.put(CLUSTER_ROUTING_ALLOCATION_ENABLE, Allocation.NONE.name())
.build();
rerouteWithAllocateLocalGateway(commonSettings);
}
@Test
public void testDelayWithALargeAmountOfShards() throws Exception {
Settings commonSettings = settingsBuilder()
.put(ThrottlingAllocationDecider.CLUSTER_ROUTING_ALLOCATION_CONCURRENT_RECOVERIES, 1)
@ -264,8 +260,7 @@ public class ClusterRerouteIT extends ESIntegTestCase {
}
@Test
public void rerouteExplain() {
public void testRerouteExplain() {
Settings commonSettings = settingsBuilder().build();
logger.info("--> starting a node");
@ -307,7 +302,6 @@ public class ClusterRerouteIT extends ESIntegTestCase {
assertThat(explanation.decisions().type(), equalTo(Decision.Type.YES));
}
@Test
public void testClusterRerouteWithBlocks() throws Exception {
List<String> nodesIds = internalCluster().startNodesAsync(2).get();

View File

@ -29,12 +29,11 @@ import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.junit.Test;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import java.util.List;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.test.ESIntegTestCase.*;
import static org.hamcrest.Matchers.equalTo;
@ClusterScope(scope= Scope.TEST, numDataNodes =0)
@ -42,14 +41,13 @@ public class FilteringAllocationIT extends ESIntegTestCase {
private final ESLogger logger = Loggers.getLogger(FilteringAllocationIT.class);
@Test
public void testDecommissionNodeNoReplicas() throws Exception {
logger.info("--> starting 2 nodes");
List<String> nodesIds = internalCluster().startNodesAsync(2).get();
final String node_0 = nodesIds.get(0);
final String node_1 = nodesIds.get(1);
assertThat(cluster().size(), equalTo(2));
logger.info("--> creating an index with no replicas");
client().admin().indices().prepareCreate("test")
.setSettings(settingsBuilder().put("index.number_of_replicas", 0))
@ -82,7 +80,6 @@ public class FilteringAllocationIT extends ESIntegTestCase {
assertThat(client().prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(100l));
}
@Test
public void testDisablingAllocationFiltering() throws Exception {
logger.info("--> starting 2 nodes");
List<String> nodesIds = internalCluster().startNodesAsync(2).get();
@ -118,7 +115,7 @@ public class FilteringAllocationIT extends ESIntegTestCase {
client().admin().cluster().prepareUpdateSettings()
.setTransientSettings(settingsBuilder().put("cluster.routing.allocation.node_concurrent_recoveries", numShardsOnNode1)).execute().actionGet();
// make sure we can recover all the nodes at once otherwise we might run into a state where one of the shards has not yet started relocating
// but we already fired up the request to wait for 0 relocating shards.
// but we already fired up the request to wait for 0 relocating shards.
}
logger.info("--> remove index from the first node");
client().admin().indices().prepareUpdateSettings("test")

View File

@ -18,16 +18,11 @@
*/
package org.elasticsearch.cluster.allocation;
import org.elasticsearch.cluster.ClusterInfoService;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.InternalClusterInfoService;
import org.elasticsearch.cluster.routing.RoutingNode;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Test;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.equalTo;
@ -45,10 +40,9 @@ public class SimpleAllocationIT extends ESIntegTestCase {
}
/**
* Test for
* Test for
* https://groups.google.com/d/msg/elasticsearch/y-SY_HyoB-8/EZdfNt9VO44J
*/
@Test
public void testSaneAllocation() {
assertAcked(prepareCreate("test", 3));
ensureGreen();

View File

@ -24,7 +24,6 @@ import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.test.ESTestCase;
import org.junit.Test;
import java.util.EnumSet;
@ -32,8 +31,6 @@ import static org.elasticsearch.test.VersionUtils.randomVersion;
import static org.hamcrest.CoreMatchers.equalTo;
public class ClusterBlockTests extends ESTestCase {
@Test
public void testSerialization() throws Exception {
int iterations = randomIntBetween(10, 100);
for (int i = 0; i < iterations; i++) {

Some files were not shown because too many files have changed in this diff Show More