nuke some unused stuff
This commit is contained in:
parent
aa381a2775
commit
61b60da7d2
|
@ -44,7 +44,7 @@ public class VersionTests extends ElasticsearchTestCase {
|
||||||
// we use here is the version that is actually set to the project.version
|
// we use here is the version that is actually set to the project.version
|
||||||
// in maven
|
// in maven
|
||||||
String property = System.getProperty("tests.version", null);
|
String property = System.getProperty("tests.version", null);
|
||||||
assumeNotNull(property);
|
assumeTrue("tests.version is set", property != null);
|
||||||
assertEquals(property, Version.CURRENT.toString());
|
assertEquals(property, Version.CURRENT.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -540,7 +540,7 @@ public class IndexStatsTests extends ElasticsearchIntegrationTest {
|
||||||
|
|
||||||
assertThat(stats.getTotal().getSegments(), notNullValue());
|
assertThat(stats.getTotal().getSegments(), notNullValue());
|
||||||
assertThat(stats.getTotal().getSegments().getCount(), equalTo((long) test1.totalNumShards));
|
assertThat(stats.getTotal().getSegments().getCount(), equalTo((long) test1.totalNumShards));
|
||||||
assumeTrue(org.elasticsearch.Version.CURRENT.luceneVersion != Version.LUCENE_4_6_0);
|
assumeTrue("test doesn't work with 4.6.0", org.elasticsearch.Version.CURRENT.luceneVersion != Version.LUCENE_4_6_0);
|
||||||
assertThat(stats.getTotal().getSegments().getMemoryInBytes(), greaterThan(0l));
|
assertThat(stats.getTotal().getSegments().getMemoryInBytes(), greaterThan(0l));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -422,7 +422,7 @@ public class PluginManagerTests extends ElasticsearchIntegrationTest {
|
||||||
@Test
|
@Test
|
||||||
@Network
|
@Network
|
||||||
public void testInstallPluginWithElasticsearchDownloadService() throws IOException {
|
public void testInstallPluginWithElasticsearchDownloadService() throws IOException {
|
||||||
assumeTrue(isDownloadServiceWorking("download.elasticsearch.org", 80, "/elasticsearch/ci-test.txt"));
|
assumeTrue("download.elasticsearch.org is accessible", isDownloadServiceWorking("download.elasticsearch.org", 80, "/elasticsearch/ci-test.txt"));
|
||||||
singlePluginInstallAndRemove("elasticsearch/elasticsearch-transport-thrift/2.4.0", null);
|
singlePluginInstallAndRemove("elasticsearch/elasticsearch-transport-thrift/2.4.0", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -435,8 +435,8 @@ public class PluginManagerTests extends ElasticsearchIntegrationTest {
|
||||||
@Test
|
@Test
|
||||||
@Network
|
@Network
|
||||||
public void testInstallPluginWithMavenCentral() throws IOException {
|
public void testInstallPluginWithMavenCentral() throws IOException {
|
||||||
assumeTrue(isDownloadServiceWorking("search.maven.org", 80, "/"));
|
assumeTrue("search.maven.org is accessible", isDownloadServiceWorking("search.maven.org", 80, "/"));
|
||||||
assumeTrue(isDownloadServiceWorking("repo1.maven.org", 443, "/maven2/org/elasticsearch/elasticsearch-transport-thrift/2.4.0/elasticsearch-transport-thrift-2.4.0.pom"));
|
assumeTrue("repo1.maven.org is accessible", isDownloadServiceWorking("repo1.maven.org", 443, "/maven2/org/elasticsearch/elasticsearch-transport-thrift/2.4.0/elasticsearch-transport-thrift-2.4.0.pom"));
|
||||||
singlePluginInstallAndRemove("org.elasticsearch/elasticsearch-transport-thrift/2.4.0", null);
|
singlePluginInstallAndRemove("org.elasticsearch/elasticsearch-transport-thrift/2.4.0", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,7 +449,7 @@ public class PluginManagerTests extends ElasticsearchIntegrationTest {
|
||||||
@Test
|
@Test
|
||||||
@Network
|
@Network
|
||||||
public void testInstallPluginWithGithub() throws IOException {
|
public void testInstallPluginWithGithub() throws IOException {
|
||||||
assumeTrue(isDownloadServiceWorking("github.com", 443, "/"));
|
assumeTrue("github.com is accessible", isDownloadServiceWorking("github.com", 443, "/"));
|
||||||
singlePluginInstallAndRemove("elasticsearch/kibana", null);
|
singlePluginInstallAndRemove("elasticsearch/kibana", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,9 @@ package org.elasticsearch.test;
|
||||||
|
|
||||||
import com.carrotsearch.randomizedtesting.LifecycleScope;
|
import com.carrotsearch.randomizedtesting.LifecycleScope;
|
||||||
import com.carrotsearch.randomizedtesting.RandomizedContext;
|
import com.carrotsearch.randomizedtesting.RandomizedContext;
|
||||||
|
import com.carrotsearch.randomizedtesting.RandomizedTest;
|
||||||
import com.carrotsearch.randomizedtesting.Randomness;
|
import com.carrotsearch.randomizedtesting.Randomness;
|
||||||
|
import com.carrotsearch.randomizedtesting.SysGlobals;
|
||||||
import com.carrotsearch.randomizedtesting.generators.RandomInts;
|
import com.carrotsearch.randomizedtesting.generators.RandomInts;
|
||||||
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
|
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
|
@ -279,6 +281,11 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase
|
||||||
* Default maximum number of shards for an index
|
* Default maximum number of shards for an index
|
||||||
*/
|
*/
|
||||||
protected static final int DEFAULT_MAX_NUM_SHARDS = 10;
|
protected static final int DEFAULT_MAX_NUM_SHARDS = 10;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The child JVM ordinal of this JVM. Default is <tt>0</tt>
|
||||||
|
*/
|
||||||
|
public static final int CHILD_JVM_ID = Integer.parseInt(System.getProperty(SysGlobals.CHILDVM_SYSPROP_JVM_ID, "0"));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current cluster depending on the configured {@link Scope}.
|
* The current cluster depending on the configured {@link Scope}.
|
||||||
|
@ -1755,7 +1762,7 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase
|
||||||
// It sounds like some Java Time Zones are unknown by JODA. For example: Asia/Riyadh88
|
// It sounds like some Java Time Zones are unknown by JODA. For example: Asia/Riyadh88
|
||||||
// We need to fallback in that case to a known time zone
|
// We need to fallback in that case to a known time zone
|
||||||
try {
|
try {
|
||||||
timeZone = DateTimeZone.forTimeZone(randomTimeZone());
|
timeZone = DateTimeZone.forTimeZone(RandomizedTest.randomTimeZone());
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
timeZone = DateTimeZone.forOffsetHours(randomIntBetween(-12, 12));
|
timeZone = DateTimeZone.forOffsetHours(randomIntBetween(-12, 12));
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.elasticsearch.test;
|
||||||
|
|
||||||
import com.carrotsearch.randomizedtesting.LifecycleScope;
|
import com.carrotsearch.randomizedtesting.LifecycleScope;
|
||||||
import com.carrotsearch.randomizedtesting.RandomizedContext;
|
import com.carrotsearch.randomizedtesting.RandomizedContext;
|
||||||
|
import com.carrotsearch.randomizedtesting.RandomizedTest;
|
||||||
import com.carrotsearch.randomizedtesting.SysGlobals;
|
import com.carrotsearch.randomizedtesting.SysGlobals;
|
||||||
import com.carrotsearch.randomizedtesting.annotations.Listeners;
|
import com.carrotsearch.randomizedtesting.annotations.Listeners;
|
||||||
import com.carrotsearch.randomizedtesting.annotations.TestGroup;
|
import com.carrotsearch.randomizedtesting.annotations.TestGroup;
|
||||||
|
@ -66,7 +67,6 @@ import org.elasticsearch.test.store.MockDirectoryHelper;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.Assume;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
|
@ -91,7 +91,6 @@ import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TimeZone;
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
@ -174,10 +173,6 @@ public abstract class ElasticsearchTestCase extends LuceneTestCase {
|
||||||
|
|
||||||
// old shit:
|
// old shit:
|
||||||
|
|
||||||
/**
|
|
||||||
* The number of concurrent JVMs used to run the tests, Default is <tt>1</tt>
|
|
||||||
*/
|
|
||||||
public static final int CHILD_JVM_COUNT = Integer.parseInt(System.getProperty(SysGlobals.CHILDVM_SYSPROP_JVM_COUNT, "1"));
|
|
||||||
/**
|
/**
|
||||||
* The child JVM ordinal of this JVM. Default is <tt>0</tt>
|
* The child JVM ordinal of this JVM. Default is <tt>0</tt>
|
||||||
*/
|
*/
|
||||||
|
@ -301,40 +296,15 @@ public abstract class ElasticsearchTestCase extends LuceneTestCase {
|
||||||
// old helper stuff, a lot of it is bad news and we should see if its all used
|
// old helper stuff, a lot of it is bad news and we should see if its all used
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a "scaled" random number between min and max (inclusive). The number of
|
* Returns a "scaled" random number between min and max (inclusive).
|
||||||
* iterations will fall between [min, max], but the selection will also try to
|
* @see RandomizedTest#scaledRandomIntBetween(int, int);
|
||||||
* achieve the points below:
|
|
||||||
* <ul>
|
|
||||||
* <li>the multiplier can be used to move the number of iterations closer to min
|
|
||||||
* (if it is smaller than 1) or closer to max (if it is larger than 1). Setting
|
|
||||||
* the multiplier to 0 will always result in picking min.</li>
|
|
||||||
* <li>on normal runs, the number will be closer to min than to max.</li>
|
|
||||||
* <li>on nightly runs, the number will be closer to max than to min.</li>
|
|
||||||
* </ul>
|
|
||||||
*
|
|
||||||
* @see #multiplier()
|
|
||||||
*
|
|
||||||
* @param min Minimum (inclusive).
|
|
||||||
* @param max Maximum (inclusive).
|
|
||||||
* @return Returns a random number between min and max.
|
|
||||||
*/
|
*/
|
||||||
public static int scaledRandomIntBetween(int min, int max) {
|
public static int scaledRandomIntBetween(int min, int max) {
|
||||||
if (min < 0) throw new IllegalArgumentException("min must be >= 0: " + min);
|
return RandomizedTest.scaledRandomIntBetween(min, max);
|
||||||
if (min > max) throw new IllegalArgumentException("max must be >= min: " + min + ", " + max);
|
|
||||||
|
|
||||||
double point = Math.min(1, Math.abs(random().nextGaussian()) * 0.3) * RANDOM_MULTIPLIER;
|
|
||||||
double range = max - min;
|
|
||||||
int scaled = (int) Math.round(Math.min(point * range, range));
|
|
||||||
if (isNightly()) {
|
|
||||||
return max - scaled;
|
|
||||||
} else {
|
|
||||||
return min + scaled;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A random integer from <code>min</code> to <code>max</code> (inclusive).
|
* A random integer from <code>min</code> to <code>max</code> (inclusive).
|
||||||
*
|
|
||||||
* @see #scaledRandomIntBetween(int, int)
|
* @see #scaledRandomIntBetween(int, int)
|
||||||
*/
|
*/
|
||||||
public static int randomIntBetween(int min, int max) {
|
public static int randomIntBetween(int min, int max) {
|
||||||
|
@ -376,13 +346,6 @@ public abstract class ElasticsearchTestCase extends LuceneTestCase {
|
||||||
public static double randomDouble() { return getRandom().nextDouble(); }
|
public static double randomDouble() { return getRandom().nextDouble(); }
|
||||||
public static long randomLong() { return getRandom().nextLong(); }
|
public static long randomLong() { return getRandom().nextLong(); }
|
||||||
|
|
||||||
/**
|
|
||||||
* Making {@link Assume#assumeNotNull(Object...)} directly available.
|
|
||||||
*/
|
|
||||||
public static void assumeNotNull(Object... objects) {
|
|
||||||
Assume.assumeNotNull(objects);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pick a random object from the given array. The array must not be empty.
|
* Pick a random object from the given array. The array must not be empty.
|
||||||
*/
|
*/
|
||||||
|
@ -412,85 +375,64 @@ public abstract class ElasticsearchTestCase extends LuceneTestCase {
|
||||||
* A random integer from 0..max (inclusive).
|
* A random integer from 0..max (inclusive).
|
||||||
*/
|
*/
|
||||||
public static int randomInt(int max) {
|
public static int randomInt(int max) {
|
||||||
return RandomInts.randomInt(getRandom(), max);
|
return RandomizedTest.randomInt(max);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see StringGenerator#ofCodeUnitsLength(Random, int, int) */
|
/** @see StringGenerator#ofCodeUnitsLength(Random, int, int) */
|
||||||
public static String randomAsciiOfLengthBetween(int minCodeUnits, int maxCodeUnits) {
|
public static String randomAsciiOfLengthBetween(int minCodeUnits, int maxCodeUnits) {
|
||||||
return RandomStrings.randomAsciiOfLengthBetween(getRandom(), minCodeUnits,
|
return RandomizedTest.randomAsciiOfLengthBetween(minCodeUnits, maxCodeUnits);
|
||||||
maxCodeUnits);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see StringGenerator#ofCodeUnitsLength(Random, int, int) */
|
/** @see StringGenerator#ofCodeUnitsLength(Random, int, int) */
|
||||||
public static String randomAsciiOfLength(int codeUnits) {
|
public static String randomAsciiOfLength(int codeUnits) {
|
||||||
return RandomStrings.randomAsciiOfLength(getRandom(), codeUnits);
|
return RandomizedTest.randomAsciiOfLength(codeUnits);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see StringGenerator#ofCodeUnitsLength(Random, int, int) */
|
/** @see StringGenerator#ofCodeUnitsLength(Random, int, int) */
|
||||||
public static String randomUnicodeOfLengthBetween(int minCodeUnits, int maxCodeUnits) {
|
public static String randomUnicodeOfLengthBetween(int minCodeUnits, int maxCodeUnits) {
|
||||||
return RandomStrings.randomUnicodeOfLengthBetween(getRandom(),
|
return RandomizedTest.randomUnicodeOfLengthBetween(minCodeUnits, maxCodeUnits);
|
||||||
minCodeUnits, maxCodeUnits);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see StringGenerator#ofCodeUnitsLength(Random, int, int) */
|
/** @see StringGenerator#ofCodeUnitsLength(Random, int, int) */
|
||||||
public static String randomUnicodeOfLength(int codeUnits) {
|
public static String randomUnicodeOfLength(int codeUnits) {
|
||||||
return RandomStrings.randomUnicodeOfLength(getRandom(), codeUnits);
|
return RandomizedTest.randomUnicodeOfLength(codeUnits);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see StringGenerator#ofCodePointsLength(Random, int, int) */
|
/** @see StringGenerator#ofCodePointsLength(Random, int, int) */
|
||||||
public static String randomUnicodeOfCodepointLengthBetween(int minCodePoints, int maxCodePoints) {
|
public static String randomUnicodeOfCodepointLengthBetween(int minCodePoints, int maxCodePoints) {
|
||||||
return RandomStrings.randomUnicodeOfCodepointLengthBetween(getRandom(),
|
return RandomizedTest.randomUnicodeOfCodepointLengthBetween(minCodePoints, maxCodePoints);
|
||||||
minCodePoints, maxCodePoints);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see StringGenerator#ofCodePointsLength(Random, int, int) */
|
/** @see StringGenerator#ofCodePointsLength(Random, int, int) */
|
||||||
public static String randomUnicodeOfCodepointLength(int codePoints) {
|
public static String randomUnicodeOfCodepointLength(int codePoints) {
|
||||||
return RandomStrings
|
return RandomizedTest.randomUnicodeOfCodepointLength(codePoints);
|
||||||
.randomUnicodeOfCodepointLength(getRandom(), codePoints);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see StringGenerator#ofCodeUnitsLength(Random, int, int) */
|
/** @see StringGenerator#ofCodeUnitsLength(Random, int, int) */
|
||||||
public static String randomRealisticUnicodeOfLengthBetween(int minCodeUnits, int maxCodeUnits) {
|
public static String randomRealisticUnicodeOfLengthBetween(int minCodeUnits, int maxCodeUnits) {
|
||||||
return RandomStrings.randomRealisticUnicodeOfLengthBetween(getRandom(),
|
return RandomizedTest.randomRealisticUnicodeOfLengthBetween(minCodeUnits, maxCodeUnits);
|
||||||
minCodeUnits, maxCodeUnits);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see StringGenerator#ofCodeUnitsLength(Random, int, int) */
|
/** @see StringGenerator#ofCodeUnitsLength(Random, int, int) */
|
||||||
public static String randomRealisticUnicodeOfLength(int codeUnits) {
|
public static String randomRealisticUnicodeOfLength(int codeUnits) {
|
||||||
return RandomStrings.randomRealisticUnicodeOfLength(getRandom(), codeUnits);
|
return RandomizedTest.randomRealisticUnicodeOfLength(codeUnits);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see StringGenerator#ofCodePointsLength(Random, int, int) */
|
/** @see StringGenerator#ofCodePointsLength(Random, int, int) */
|
||||||
public static String randomRealisticUnicodeOfCodepointLengthBetween(
|
public static String randomRealisticUnicodeOfCodepointLengthBetween(int minCodePoints, int maxCodePoints) {
|
||||||
int minCodePoints, int maxCodePoints) {
|
return RandomizedTest.randomRealisticUnicodeOfCodepointLengthBetween(minCodePoints, maxCodePoints);
|
||||||
return RandomStrings.randomRealisticUnicodeOfCodepointLengthBetween(
|
|
||||||
getRandom(), minCodePoints, maxCodePoints);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see StringGenerator#ofCodePointsLength(Random, int, int) */
|
/** @see StringGenerator#ofCodePointsLength(Random, int, int) */
|
||||||
public static String randomRealisticUnicodeOfCodepointLength(int codePoints) {
|
public static String randomRealisticUnicodeOfCodepointLength(int codePoints) {
|
||||||
return RandomStrings.randomRealisticUnicodeOfCodepointLength(getRandom(),
|
return RandomizedTest.randomRealisticUnicodeOfCodepointLength(codePoints);
|
||||||
codePoints);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a random TimeZone from the available timezones on the system.
|
|
||||||
*
|
|
||||||
* <p>Warning: This test assumes the returned array of time zones is repeatable from jvm execution
|
|
||||||
* to jvm execution. It _may_ be different from jvm to jvm and as such, it can render
|
|
||||||
* tests execute in a different way.</p>
|
|
||||||
*/
|
|
||||||
public static TimeZone randomTimeZone() {
|
|
||||||
final String[] availableIDs = TimeZone.getAvailableIDs();
|
|
||||||
Arrays.sort(availableIDs);
|
|
||||||
return TimeZone.getTimeZone(randomFrom(availableIDs));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shortcut for {@link RandomizedContext#current()}.
|
* Shortcut for {@link RandomizedContext#current()}.
|
||||||
*/
|
*/
|
||||||
public static RandomizedContext getContext() {
|
public static RandomizedContext getContext() {
|
||||||
return RandomizedContext.current();
|
return RandomizedTest.getContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -498,30 +440,15 @@ public abstract class ElasticsearchTestCase extends LuceneTestCase {
|
||||||
* @see Nightly
|
* @see Nightly
|
||||||
*/
|
*/
|
||||||
public static boolean isNightly() {
|
public static boolean isNightly() {
|
||||||
return getContext().isNightly();
|
return RandomizedTest.isNightly();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a non-negative random value smaller or equal <code>max</code>. The value
|
* Returns a non-negative random value smaller or equal <code>max</code>.
|
||||||
* picked is affected by {@link #isNightly()} and {@link #multiplier()}.
|
* @see RandomizedTest#atMost(int);
|
||||||
*
|
|
||||||
* <p>This method is effectively an alias to:
|
|
||||||
* <pre>
|
|
||||||
* scaledRandomIntBetween(0, max)
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @see #scaledRandomIntBetween(int, int)
|
|
||||||
*/
|
*/
|
||||||
public static int atMost(int max) {
|
public static int atMost(int max) {
|
||||||
if (max < 0) throw new IllegalArgumentException("atMost requires non-negative argument: " + max);
|
return RandomizedTest.atMost(max);
|
||||||
return scaledRandomIntBetween(0, max);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Making {@link Assume#assumeTrue(boolean)} directly available.
|
|
||||||
*/
|
|
||||||
public void assumeTrue(boolean condition) {
|
|
||||||
assumeTrue("caller was too lazy to provide a reason", condition);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Thread.UncaughtExceptionHandler defaultHandler;
|
private static Thread.UncaughtExceptionHandler defaultHandler;
|
||||||
|
|
Loading…
Reference in New Issue