|
@@ -2269,11 +2269,17 @@ public class IndexShardTests extends IndexShardTestCase {
|
|
final String id = Integer.toString(i);
|
|
final String id = Integer.toString(i);
|
|
indexDoc(indexShard, "test", id);
|
|
indexDoc(indexShard, "test", id);
|
|
}
|
|
}
|
|
-
|
|
|
|
- indexShard.refresh("test");
|
|
|
|
|
|
+ if (randomBoolean()) {
|
|
|
|
+ indexShard.refresh("test");
|
|
|
|
+ } else {
|
|
|
|
+ indexShard.flush(new FlushRequest());
|
|
|
|
+ }
|
|
{
|
|
{
|
|
final DocsStats docsStats = indexShard.docStats();
|
|
final DocsStats docsStats = indexShard.docStats();
|
|
assertThat(docsStats.getCount(), equalTo(numDocs));
|
|
assertThat(docsStats.getCount(), equalTo(numDocs));
|
|
|
|
+ try (Engine.Searcher searcher = indexShard.acquireSearcher("test")) {
|
|
|
|
+ assertTrue(searcher.reader().numDocs() <= docsStats.getCount());
|
|
|
|
+ }
|
|
assertThat(docsStats.getDeleted(), equalTo(0L));
|
|
assertThat(docsStats.getDeleted(), equalTo(0L));
|
|
assertThat(docsStats.getAverageSizeInBytes(), greaterThan(0L));
|
|
assertThat(docsStats.getAverageSizeInBytes(), greaterThan(0L));
|
|
}
|
|
}
|
|
@@ -2293,9 +2299,14 @@ public class IndexShardTests extends IndexShardTestCase {
|
|
flushRequest.waitIfOngoing(false);
|
|
flushRequest.waitIfOngoing(false);
|
|
indexShard.flush(flushRequest);
|
|
indexShard.flush(flushRequest);
|
|
|
|
|
|
- indexShard.refresh("test");
|
|
|
|
|
|
+ if (randomBoolean()) {
|
|
|
|
+ indexShard.refresh("test");
|
|
|
|
+ }
|
|
{
|
|
{
|
|
final DocsStats docStats = indexShard.docStats();
|
|
final DocsStats docStats = indexShard.docStats();
|
|
|
|
+ try (Engine.Searcher searcher = indexShard.acquireSearcher("test")) {
|
|
|
|
+ assertTrue(searcher.reader().numDocs() <= docStats.getCount());
|
|
|
|
+ }
|
|
assertThat(docStats.getCount(), equalTo(numDocs));
|
|
assertThat(docStats.getCount(), equalTo(numDocs));
|
|
// Lucene will delete a segment if all docs are deleted from it; this means that we lose the deletes when deleting all docs
|
|
// Lucene will delete a segment if all docs are deleted from it; this means that we lose the deletes when deleting all docs
|
|
assertThat(docStats.getDeleted(), equalTo(numDocsToDelete == numDocs ? 0 : numDocsToDelete));
|
|
assertThat(docStats.getDeleted(), equalTo(numDocsToDelete == numDocs ? 0 : numDocsToDelete));
|
|
@@ -2307,7 +2318,11 @@ public class IndexShardTests extends IndexShardTestCase {
|
|
forceMergeRequest.maxNumSegments(1);
|
|
forceMergeRequest.maxNumSegments(1);
|
|
indexShard.forceMerge(forceMergeRequest);
|
|
indexShard.forceMerge(forceMergeRequest);
|
|
|
|
|
|
- indexShard.refresh("test");
|
|
|
|
|
|
+ if (randomBoolean()) {
|
|
|
|
+ indexShard.refresh("test");
|
|
|
|
+ } else {
|
|
|
|
+ indexShard.flush(new FlushRequest());
|
|
|
|
+ }
|
|
{
|
|
{
|
|
final DocsStats docStats = indexShard.docStats();
|
|
final DocsStats docStats = indexShard.docStats();
|
|
assertThat(docStats.getCount(), equalTo(numDocs));
|
|
assertThat(docStats.getCount(), equalTo(numDocs));
|
|
@@ -2338,8 +2353,11 @@ public class IndexShardTests extends IndexShardTestCase {
|
|
assertThat("Without flushing, segment sizes should be zero",
|
|
assertThat("Without flushing, segment sizes should be zero",
|
|
indexShard.docStats().getTotalSizeInBytes(), equalTo(0L));
|
|
indexShard.docStats().getTotalSizeInBytes(), equalTo(0L));
|
|
|
|
|
|
- indexShard.flush(new FlushRequest());
|
|
|
|
- indexShard.refresh("test");
|
|
|
|
|
|
+ if (randomBoolean()) {
|
|
|
|
+ indexShard.flush(new FlushRequest());
|
|
|
|
+ } else {
|
|
|
|
+ indexShard.refresh("test");
|
|
|
|
+ }
|
|
{
|
|
{
|
|
final DocsStats docsStats = indexShard.docStats();
|
|
final DocsStats docsStats = indexShard.docStats();
|
|
final StoreStats storeStats = indexShard.storeStats();
|
|
final StoreStats storeStats = indexShard.storeStats();
|
|
@@ -2359,9 +2377,11 @@ public class IndexShardTests extends IndexShardTestCase {
|
|
indexDoc(indexShard, "doc", Integer.toString(i), "{\"foo\": \"bar\"}");
|
|
indexDoc(indexShard, "doc", Integer.toString(i), "{\"foo\": \"bar\"}");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- indexShard.flush(new FlushRequest());
|
|
|
|
- indexShard.refresh("test");
|
|
|
|
|
|
+ if (randomBoolean()) {
|
|
|
|
+ indexShard.flush(new FlushRequest());
|
|
|
|
+ } else {
|
|
|
|
+ indexShard.refresh("test");
|
|
|
|
+ }
|
|
{
|
|
{
|
|
final DocsStats docsStats = indexShard.docStats();
|
|
final DocsStats docsStats = indexShard.docStats();
|
|
final StoreStats storeStats = indexShard.storeStats();
|
|
final StoreStats storeStats = indexShard.storeStats();
|