use of com.carrotsearch.randomizedtesting.annotations.Repeat in project lucene-solr by apache.
the class HeatmapFacetCounterTest method testRandom.
@Test
@Repeat(iterations = 20)
public void testRandom() throws IOException {
// Tests using random index shapes & query shapes. This has found all sorts of edge case bugs (e.g. dateline,
// cell border, overflow(?)).
final int numIndexedShapes = 1 + atMost(9);
List<Shape> indexedShapes = new ArrayList<>(numIndexedShapes);
for (int i = 0; i < numIndexedShapes; i++) {
indexedShapes.add(randomIndexedShape());
}
//Main index loop:
for (int i = 0; i < indexedShapes.size(); i++) {
Shape shape = indexedShapes.get(i);
adoc("" + i, shape);
if (random().nextInt(10) == 0)
//intermediate commit, produces extra segments
commit();
}
//delete some documents randomly
for (int id = 0; id < indexedShapes.size(); id++) {
if (random().nextInt(10) == 0) {
deleteDoc("" + id);
indexedShapes.set(id, null);
}
}
commit();
// once without dateline wrap
final Rectangle rect = randomRectangle();
queryHeatmapRecursive(usually() ? ctx.getWorldBounds() : rect, 1);
// and once with dateline wrap
if (rect.getWidth() > 0) {
double shift = random().nextDouble() % rect.getWidth();
queryHeatmapRecursive(ctx.makeRectangle(DistanceUtils.normLonDEG(rect.getMinX() - shift), DistanceUtils.normLonDEG(rect.getMaxX() - shift), rect.getMinY(), rect.getMaxY()), 1);
}
}
use of com.carrotsearch.randomizedtesting.annotations.Repeat in project lucene-solr by apache.
the class CompositeStrategyTest method testOperations.
@Test
@Repeat(iterations = 20)
public void testOperations() throws IOException {
//setup
if (randomBoolean()) {
setupQuadGrid(-1);
} else {
setupGeohashGrid(-1);
}
SerializedDVStrategy serializedDVStrategy = new SerializedDVStrategy(ctx, getClass().getSimpleName() + "_sdv");
this.strategy = new CompositeSpatialStrategy("composite_" + getClass().getSimpleName(), rptStrategy, serializedDVStrategy);
for (SpatialOperation pred : SpatialOperation.values()) {
if (pred == SpatialOperation.BBoxIntersects || pred == SpatialOperation.BBoxWithin) {
continue;
}
if (pred == SpatialOperation.IsDisjointTo) {
//TODO
continue;
}
testOperationRandomShapes(pred);
deleteAll();
commit();
}
}
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();
}
}
use of com.carrotsearch.randomizedtesting.annotations.Repeat in project lucene-solr by apache.
the class TestTlogReplica 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:
CollectionAdminRequest.createCollection(collectionName, "conf", 2, 0, 4, 0).setMaxShardsPerNode(100).process(cluster.getSolrClient());
break;
case 1:
// Sometimes don't use SolrJ
String url = String.format(Locale.ROOT, "%s/admin/collections?action=CREATE&name=%s&numShards=%s&tlogReplicas=%s&maxShardsPerNode=%s", cluster.getRandomJetty(random()).getBaseUrl(), collectionName, // numShards
2, // tlogReplicas
4, // maxShardsPerNode
100);
HttpGet createCollectionGet = new HttpGet(url);
HttpResponse httpResponse = cluster.getSolrClient().getHttpClient().execute(createCollectionGet);
assertEquals(200, httpResponse.getStatusLine().getStatusCode());
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, tlogReplicas:%s, maxShardsPerNode:%s}}", collectionName, // numShards
2, // tlogReplicas
4, // maxShardsPerNode
100);
HttpPost createCollectionPost = new HttpPost(url);
createCollectionPost.setHeader("Content-type", "application/json");
createCollectionPost.setEntity(new StringEntity(requestBody));
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 2 shards", 2, docCollection.getSlices().size());
assertEquals("Expecting 4 relpicas per shard", 8, docCollection.getReplicas().size());
assertEquals("Expecting 8 tlog replicas, 4 per shard", 8, docCollection.getReplicas(EnumSet.of(Replica.Type.TLOG)).size());
assertEquals("Expecting no nrt replicas", 0, docCollection.getReplicas(EnumSet.of(Replica.Type.NRT)).size());
assertEquals("Expecting no pull replicas", 0, docCollection.getReplicas(EnumSet.of(Replica.Type.PULL)).size());
for (Slice s : docCollection.getSlices()) {
assertTrue(s.getLeader().getType() == Replica.Type.TLOG);
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()), 4, 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();
}
}
use of com.carrotsearch.randomizedtesting.annotations.Repeat in project randomizedtesting by randomizedtesting.
the class TestBiasedNumbers method biasedFloats.
@Test
@Repeat(iterations = 100)
public void biasedFloats() {
Random r = getRandom();
// Some sanity checks.
sanityCheck(r, Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY);
sanityCheck(r, Float.NEGATIVE_INFINITY, 0);
sanityCheck(r, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY);
sanityCheck(r, 0, Float.POSITIVE_INFINITY);
sanityCheck(r, 0f, 0);
sanityCheck(r, 0f, 1);
sanityCheck(r, -1f, 1);
sanityCheck(r, 1f, 2);
}
Aggregations