Marvel: Fixes for Index Stats Collector tests

Original commit: elastic/x-pack-elasticsearch@4fdc11946e
This commit is contained in:
Tanguy Leroux 2015-08-27 14:14:07 +02:00
parent 38061c5f98
commit 64bbc110ff
1 changed files with 21 additions and 7 deletions

View File

@ -16,6 +16,8 @@ import org.junit.Test;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
@ -34,7 +36,7 @@ public class IndexStatsCollectorTests extends AbstractCollectorTestCase {
public void testIndexStatsCollectorOneIndex() throws Exception { public void testIndexStatsCollectorOneIndex() throws Exception {
waitForNoBlocksOnNodes(); waitForNoBlocksOnNodes();
final String indexName = "test_" + randomInt(); final String indexName = "one-index";
final int nbDocs = randomIntBetween(1, 20); final int nbDocs = randomIntBetween(1, 20);
for (int i = 0; i < nbDocs; i++) { for (int i = 0; i < nbDocs; i++) {
@ -45,8 +47,14 @@ public class IndexStatsCollectorTests extends AbstractCollectorTestCase {
waitForRelocation(); waitForRelocation();
Collection<MarvelDoc> results = newIndexStatsCollector().doCollect(); Collection<MarvelDoc> results = assertBusy(new Callable<Collection<MarvelDoc>>() {
assertThat(results, hasSize(1)); @Override
public Collection<MarvelDoc> call() throws Exception {
Collection<MarvelDoc> results = newIndexStatsCollector().doCollect();
assertThat(results, hasSize(1));
return results;
}
}, 30L, TimeUnit.SECONDS);
MarvelDoc marvelDoc = results.iterator().next(); MarvelDoc marvelDoc = results.iterator().next();
assertNotNull(marvelDoc); assertNotNull(marvelDoc);
@ -73,8 +81,8 @@ public class IndexStatsCollectorTests extends AbstractCollectorTestCase {
public void testIndexStatsCollectorMultipleIndices() throws Exception { public void testIndexStatsCollectorMultipleIndices() throws Exception {
waitForNoBlocksOnNodes(); waitForNoBlocksOnNodes();
final String indexPrefix = "test_" + randomInt() + "_"; final String indexPrefix = "multi-indices-";
int nbIndices = randomIntBetween(1, 5); final int nbIndices = randomIntBetween(1, 5);
int[] docsPerIndex = new int[nbIndices]; int[] docsPerIndex = new int[nbIndices];
for (int i = 0; i < nbIndices; i++) { for (int i = 0; i < nbIndices; i++) {
@ -92,8 +100,14 @@ public class IndexStatsCollectorTests extends AbstractCollectorTestCase {
waitForRelocation(); waitForRelocation();
Collection<MarvelDoc> results = newIndexStatsCollector().doCollect(); Collection<MarvelDoc> results = assertBusy(new Callable<Collection<MarvelDoc>>() {
assertThat(results, hasSize(nbIndices)); @Override
public Collection<MarvelDoc> call() throws Exception {
Collection<MarvelDoc> results = newIndexStatsCollector().doCollect();
assertThat(results, hasSize(nbIndices));
return results;
}
}, 30L, TimeUnit.SECONDS);
for (int i = 0; i < nbIndices; i++) { for (int i = 0; i < nbIndices; i++) {
String indexName = indexPrefix + i; String indexName = indexPrefix + i;