use of com.carrotsearch.randomizedtesting.annotations.Repeat in project randomizedtesting by randomizedtesting.
the class TestBiasedNumbers method biasedDoubles.
@Test
@Repeat(iterations = 100)
public void biasedDoubles() {
Random r = getRandom();
// Some sanity checks.
sanityCheck(r, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
sanityCheck(r, Double.NEGATIVE_INFINITY, 0);
sanityCheck(r, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
sanityCheck(r, 0, Double.POSITIVE_INFINITY);
sanityCheck(r, 0d, 0);
sanityCheck(r, 0d, 1);
sanityCheck(r, -1d, 1);
sanityCheck(r, 1d, 2);
}
use of com.carrotsearch.randomizedtesting.annotations.Repeat in project randomizedtesting by randomizedtesting.
the class TestHookMethodOrderWithExceptions method checkOrderSameAsJUnit.
@Test
@Repeat(iterations = 20)
public void checkOrderSameAsJUnit() throws Exception {
long seed = RandomizedContext.current().getRandomness().getSeed();
callOrder.clear();
Super.rnd = new Random(seed);
FullResult r1 = WithNestedTestClass.runTests(WithRegularRunner.class);
List<String> junitOrder = new ArrayList<String>(callOrder);
callOrder.clear();
Super.rnd = new Random(seed);
FullResult r2 = WithNestedTestClass.runTests(WithRandomizedRunner.class);
List<String> rrunnerOrder = new ArrayList<String>(callOrder);
Assert.assertEquals(junitOrder, rrunnerOrder);
Assertions.assertThat(r1.getRunCount()).isEqualTo(r2.getRunCount());
}
use of com.carrotsearch.randomizedtesting.annotations.Repeat in project randomizedtesting by randomizedtesting.
the class TestManyThreadsOOM method testSpawnManyThreads.
@Test
@Repeat(iterations = 10)
public void testSpawnManyThreads() throws Exception {
// touch the context from within a thread and die.
for (int i = 0; i < 500; i++) {
final Thread t = new Thread() {
final byte[] hold = new byte[1024 * 1024 * 10];
public void run() {
Random rnd = RandomizedContext.current().getRandom();
guard += rnd.nextInt() + hold.length;
}
};
t.start();
t.join();
}
}
use of com.carrotsearch.randomizedtesting.annotations.Repeat in project randomizedtesting by randomizedtesting.
the class TestXmlStringsRoundtrip method testRoundTrip.
@Test
@Repeat(iterations = 100)
public void testRoundTrip() throws Exception {
char[] chars = new char[randomIntBetween(0, 1024)];
Random random = getRandom();
for (int i = 0; i < chars.length; i++) {
chars[i] = (char) random.nextInt();
}
check(chars);
}
use of com.carrotsearch.randomizedtesting.annotations.Repeat in project lucene-solr by apache.
the class TestPullReplica method testCreateDelete.
// 2 times to make sure cleanup is complete and we can create the same collection
@Repeat(iterations = 2)
public void testCreateDelete() throws Exception {
try {
switch(random().nextInt(3)) {
case 0:
// Sometimes use SolrJ
CollectionAdminRequest.createCollection(collectionName, "conf", 2, 1, 0, 3).setMaxShardsPerNode(100).process(cluster.getSolrClient());
break;
case 1:
// Sometimes use v1 API
String url = String.format(Locale.ROOT, "%s/admin/collections?action=CREATE&name=%s&numShards=%s&pullReplicas=%s&maxShardsPerNode=%s", cluster.getRandomJetty(random()).getBaseUrl(), collectionName, // numShards
2, // pullReplicas
3, // maxShardsPerNode
100);
// These options should all mean the same
url = url + pickRandom("", "&nrtReplicas=1", "&replicationFactor=1");
HttpGet createCollectionGet = new HttpGet(url);
cluster.getSolrClient().getHttpClient().execute(createCollectionGet);
break;
case 2:
// Sometimes use V2 API
url = cluster.getRandomJetty(random()).getBaseUrl().toString() + "/____v2/c";
String requestBody = String.format(Locale.ROOT, "{create:{name:%s, numShards:%s, pullReplicas:%s, maxShardsPerNode:%s %s}}", collectionName, // numShards
2, // pullReplicas
3, // maxShardsPerNode
100, // These options should all mean the same
pickRandom("", ", nrtReplicas:1", ", replicationFactor:1"));
HttpPost createCollectionPost = new HttpPost(url);
createCollectionPost.setHeader("Content-type", "application/json");
createCollectionPost.setEntity(new StringEntity(requestBody));
HttpResponse httpResponse = cluster.getSolrClient().getHttpClient().execute(createCollectionPost);
assertEquals(200, httpResponse.getStatusLine().getStatusCode());
break;
}
boolean reloaded = false;
while (true) {
DocCollection docCollection = getCollectionState(collectionName);
assertNotNull(docCollection);
assertEquals("Expecting 4 relpicas per shard", 8, docCollection.getReplicas().size());
assertEquals("Expecting 6 pull replicas, 3 per shard", 6, docCollection.getReplicas(EnumSet.of(Replica.Type.PULL)).size());
assertEquals("Expecting 2 writer replicas, one per shard", 2, docCollection.getReplicas(EnumSet.of(Replica.Type.NRT)).size());
for (Slice s : docCollection.getSlices()) {
// read-only replicas can never become leaders
assertFalse(s.getLeader().getType() == Replica.Type.PULL);
List<String> shardElectionNodes = cluster.getZkClient().getChildren(ZkStateReader.getShardLeadersElectPath(collectionName, s.getName()), null, true);
assertEquals("Unexpected election nodes for Shard: " + s.getName() + ": " + Arrays.toString(shardElectionNodes.toArray()), 1, shardElectionNodes.size());
}
assertUlogPresence(docCollection);
if (reloaded) {
break;
} else {
// reload
CollectionAdminResponse response = CollectionAdminRequest.reloadCollection(collectionName).process(cluster.getSolrClient());
assertEquals(0, response.getStatus());
reloaded = true;
}
}
} finally {
zkClient().printLayoutToStdOut();
}
}
Aggregations