fix tests
This commit is contained in:
parent
1ad1e2730d
commit
7a6f56a692
|
@ -106,6 +106,7 @@ import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.test.IndexSettingsModule;
|
import org.elasticsearch.test.IndexSettingsModule;
|
||||||
import org.elasticsearch.threadpool.TestThreadPool;
|
import org.elasticsearch.threadpool.TestThreadPool;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
|
import org.hamcrest.CoreMatchers;
|
||||||
import org.hamcrest.MatcherAssert;
|
import org.hamcrest.MatcherAssert;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -1308,7 +1309,7 @@ public class InternalEngineTests extends ESTestCase {
|
||||||
ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), B_1, null);
|
ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), B_1, null);
|
||||||
Engine.Index index = new Engine.Index(newUid("1"), doc);
|
Engine.Index index = new Engine.Index(newUid("1"), doc);
|
||||||
Engine.IndexResult indexResult = engine.index(index);
|
Engine.IndexResult indexResult = engine.index(index);
|
||||||
assertThat(indexResult.getFailure(), equalTo(1L));
|
assertThat(indexResult.getVersion(), equalTo(1L));
|
||||||
|
|
||||||
index = new Engine.Index(newUid("1"), doc);
|
index = new Engine.Index(newUid("1"), doc);
|
||||||
indexResult = engine.index(index);
|
indexResult = engine.index(index);
|
||||||
|
@ -1914,17 +1915,17 @@ public class InternalEngineTests extends ESTestCase {
|
||||||
String uuidValue = "test#" + Integer.toString(randomId);
|
String uuidValue = "test#" + Integer.toString(randomId);
|
||||||
ParsedDocument doc = testParsedDocument(uuidValue, Integer.toString(randomId), "test", null, -1, -1, testDocument(), new BytesArray("{}"), null);
|
ParsedDocument doc = testParsedDocument(uuidValue, Integer.toString(randomId), "test", null, -1, -1, testDocument(), new BytesArray("{}"), null);
|
||||||
Engine.Index firstIndexRequest = new Engine.Index(newUid(uuidValue), doc, 1, VersionType.EXTERNAL, PRIMARY, System.nanoTime(), -1, false);
|
Engine.Index firstIndexRequest = new Engine.Index(newUid(uuidValue), doc, 1, VersionType.EXTERNAL, PRIMARY, System.nanoTime(), -1, false);
|
||||||
engine.index(firstIndexRequest);
|
Engine.IndexResult indexResult = engine.index(firstIndexRequest);
|
||||||
assertThat(firstIndexRequest.version(), equalTo(1L));
|
assertThat(indexResult.getVersion(), equalTo(1L));
|
||||||
if (flush) {
|
if (flush) {
|
||||||
engine.flush();
|
engine.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
doc = testParsedDocument(uuidValue, Integer.toString(randomId), "test", null, -1, -1, testDocument(), new BytesArray("{}"), null);
|
doc = testParsedDocument(uuidValue, Integer.toString(randomId), "test", null, -1, -1, testDocument(), new BytesArray("{}"), null);
|
||||||
Engine.Index idxRequest = new Engine.Index(newUid(uuidValue), doc, 2, VersionType.EXTERNAL, PRIMARY, System.nanoTime(), -1, false);
|
Engine.Index idxRequest = new Engine.Index(newUid(uuidValue), doc, 2, VersionType.EXTERNAL, PRIMARY, System.nanoTime(), -1, false);
|
||||||
engine.index(idxRequest);
|
Engine.IndexResult result = engine.index(idxRequest);
|
||||||
engine.refresh("test");
|
engine.refresh("test");
|
||||||
assertThat(idxRequest.version(), equalTo(2L));
|
assertThat(result.getVersion(), equalTo(2L));
|
||||||
try (Engine.Searcher searcher = engine.acquireSearcher("test")) {
|
try (Engine.Searcher searcher = engine.acquireSearcher("test")) {
|
||||||
TopDocs topDocs = searcher.searcher().search(new MatchAllDocsQuery(), numDocs + 1);
|
TopDocs topDocs = searcher.searcher().search(new MatchAllDocsQuery(), numDocs + 1);
|
||||||
assertThat(topDocs.totalHits, equalTo(numDocs + 1));
|
assertThat(topDocs.totalHits, equalTo(numDocs + 1));
|
||||||
|
@ -1990,8 +1991,8 @@ public class InternalEngineTests extends ESTestCase {
|
||||||
for (int i = 0; i < numDocs; i++) {
|
for (int i = 0; i < numDocs; i++) {
|
||||||
ParsedDocument doc = testParsedDocument(Integer.toString(i), Integer.toString(i), "test", null, -1, -1, testDocument(), new BytesArray("{}"), null);
|
ParsedDocument doc = testParsedDocument(Integer.toString(i), Integer.toString(i), "test", null, -1, -1, testDocument(), new BytesArray("{}"), null);
|
||||||
Engine.Index firstIndexRequest = new Engine.Index(newUid(Integer.toString(i)), doc, Versions.MATCH_DELETED, VersionType.INTERNAL, PRIMARY, System.nanoTime(), -1, false);
|
Engine.Index firstIndexRequest = new Engine.Index(newUid(Integer.toString(i)), doc, Versions.MATCH_DELETED, VersionType.INTERNAL, PRIMARY, System.nanoTime(), -1, false);
|
||||||
engine.index(firstIndexRequest);
|
Engine.IndexResult index = engine.index(firstIndexRequest);
|
||||||
assertThat(firstIndexRequest.version(), equalTo(1L));
|
assertThat(index.getVersion(), equalTo(1L));
|
||||||
}
|
}
|
||||||
engine.refresh("test");
|
engine.refresh("test");
|
||||||
try (Engine.Searcher searcher = engine.acquireSearcher("test")) {
|
try (Engine.Searcher searcher = engine.acquireSearcher("test")) {
|
||||||
|
@ -2138,8 +2139,8 @@ public class InternalEngineTests extends ESTestCase {
|
||||||
for (int i = 0; i < numDocs; i++) {
|
for (int i = 0; i < numDocs; i++) {
|
||||||
ParsedDocument doc = testParsedDocument(Integer.toString(i), Integer.toString(i), "test", null, -1, -1, testDocument(), new BytesArray("{}"), null);
|
ParsedDocument doc = testParsedDocument(Integer.toString(i), Integer.toString(i), "test", null, -1, -1, testDocument(), new BytesArray("{}"), null);
|
||||||
Engine.Index firstIndexRequest = new Engine.Index(newUid(Integer.toString(i)), doc, Versions.MATCH_ANY, VersionType.INTERNAL, PRIMARY, System.nanoTime(), -1, false);
|
Engine.Index firstIndexRequest = new Engine.Index(newUid(Integer.toString(i)), doc, Versions.MATCH_ANY, VersionType.INTERNAL, PRIMARY, System.nanoTime(), -1, false);
|
||||||
engine.index(firstIndexRequest);
|
Engine.IndexResult indexResult = engine.index(firstIndexRequest);
|
||||||
assertThat(firstIndexRequest.version(), equalTo(1L));
|
assertThat(indexResult.getVersion(), equalTo(1L));
|
||||||
}
|
}
|
||||||
DocsStats docStats = engine.getDocStats();
|
DocsStats docStats = engine.getDocStats();
|
||||||
assertEquals(numDocs, docStats.getCount());
|
assertEquals(numDocs, docStats.getCount());
|
||||||
|
@ -2148,8 +2149,8 @@ public class InternalEngineTests extends ESTestCase {
|
||||||
|
|
||||||
ParsedDocument doc = testParsedDocument(Integer.toString(0), Integer.toString(0), "test", null, -1, -1, testDocument(), new BytesArray("{}"), null);
|
ParsedDocument doc = testParsedDocument(Integer.toString(0), Integer.toString(0), "test", null, -1, -1, testDocument(), new BytesArray("{}"), null);
|
||||||
Engine.Index firstIndexRequest = new Engine.Index(newUid(Integer.toString(0)), doc, Versions.MATCH_ANY, VersionType.INTERNAL, PRIMARY, System.nanoTime(), -1, false);
|
Engine.Index firstIndexRequest = new Engine.Index(newUid(Integer.toString(0)), doc, Versions.MATCH_ANY, VersionType.INTERNAL, PRIMARY, System.nanoTime(), -1, false);
|
||||||
engine.index(firstIndexRequest);
|
Engine.IndexResult index = engine.index(firstIndexRequest);
|
||||||
assertThat(firstIndexRequest.version(), equalTo(2L));
|
assertThat(index.getVersion(), equalTo(2L));
|
||||||
engine.flush(); // flush - buffered deletes are not counted
|
engine.flush(); // flush - buffered deletes are not counted
|
||||||
docStats = engine.getDocStats();
|
docStats = engine.getDocStats();
|
||||||
assertEquals(1, docStats.getDeleted());
|
assertEquals(1, docStats.getDeleted());
|
||||||
|
@ -2222,25 +2223,26 @@ public class InternalEngineTests extends ESTestCase {
|
||||||
long autoGeneratedIdTimestamp = 0;
|
long autoGeneratedIdTimestamp = 0;
|
||||||
|
|
||||||
Engine.Index index = new Engine.Index(newUid("1"), doc, Versions.MATCH_ANY, VersionType.INTERNAL, PRIMARY, System.nanoTime(), autoGeneratedIdTimestamp, isRetry);
|
Engine.Index index = new Engine.Index(newUid("1"), doc, Versions.MATCH_ANY, VersionType.INTERNAL, PRIMARY, System.nanoTime(), autoGeneratedIdTimestamp, isRetry);
|
||||||
engine.index(index);
|
Engine.IndexResult indexResult = engine.index(index);
|
||||||
assertThat(index.version(), equalTo(1L));
|
assertThat(indexResult.getVersion(), equalTo(1L));
|
||||||
|
|
||||||
index = new Engine.Index(newUid("1"), doc, index.version(), index.versionType().versionTypeForReplicationAndRecovery(), REPLICA, System.nanoTime(), autoGeneratedIdTimestamp, isRetry);
|
index = new Engine.Index(newUid("1"), doc, indexResult.getVersion(), index.versionType().versionTypeForReplicationAndRecovery(), REPLICA, System.nanoTime(), autoGeneratedIdTimestamp, isRetry);
|
||||||
replicaEngine.index(index);
|
indexResult = replicaEngine.index(index);
|
||||||
assertThat(index.version(), equalTo(1L));
|
assertThat(indexResult.getVersion(), equalTo(1L));
|
||||||
|
|
||||||
isRetry = true;
|
isRetry = true;
|
||||||
index = new Engine.Index(newUid("1"), doc, Versions.MATCH_ANY, VersionType.INTERNAL, PRIMARY, System.nanoTime(), autoGeneratedIdTimestamp, isRetry);
|
index = new Engine.Index(newUid("1"), doc, Versions.MATCH_ANY, VersionType.INTERNAL, PRIMARY, System.nanoTime(), autoGeneratedIdTimestamp, isRetry);
|
||||||
engine.index(index);
|
indexResult = engine.index(index);
|
||||||
assertThat(index.version(), equalTo(1L));
|
assertThat(indexResult.getVersion(), equalTo(1L));
|
||||||
engine.refresh("test");
|
engine.refresh("test");
|
||||||
try (Engine.Searcher searcher = engine.acquireSearcher("test")) {
|
try (Engine.Searcher searcher = engine.acquireSearcher("test")) {
|
||||||
TopDocs topDocs = searcher.searcher().search(new MatchAllDocsQuery(), 10);
|
TopDocs topDocs = searcher.searcher().search(new MatchAllDocsQuery(), 10);
|
||||||
assertEquals(1, topDocs.totalHits);
|
assertEquals(1, topDocs.totalHits);
|
||||||
}
|
}
|
||||||
|
|
||||||
index = new Engine.Index(newUid("1"), doc, index.version(), index.versionType().versionTypeForReplicationAndRecovery(), REPLICA, System.nanoTime(), autoGeneratedIdTimestamp, isRetry);
|
index = new Engine.Index(newUid("1"), doc, indexResult.getVersion(), index.versionType().versionTypeForReplicationAndRecovery(), REPLICA, System.nanoTime(), autoGeneratedIdTimestamp, isRetry);
|
||||||
replicaEngine.index(index);
|
indexResult = replicaEngine.index(index);
|
||||||
|
assertThat(indexResult.hasFailure(), equalTo(false));
|
||||||
replicaEngine.refresh("test");
|
replicaEngine.refresh("test");
|
||||||
try (Engine.Searcher searcher = replicaEngine.acquireSearcher("test")) {
|
try (Engine.Searcher searcher = replicaEngine.acquireSearcher("test")) {
|
||||||
TopDocs topDocs = searcher.searcher().search(new MatchAllDocsQuery(), 10);
|
TopDocs topDocs = searcher.searcher().search(new MatchAllDocsQuery(), 10);
|
||||||
|
@ -2256,12 +2258,12 @@ public class InternalEngineTests extends ESTestCase {
|
||||||
|
|
||||||
|
|
||||||
Engine.Index firstIndexRequest = new Engine.Index(newUid("1"), doc, Versions.MATCH_ANY, VersionType.INTERNAL, PRIMARY, System.nanoTime(), autoGeneratedIdTimestamp, isRetry);
|
Engine.Index firstIndexRequest = new Engine.Index(newUid("1"), doc, Versions.MATCH_ANY, VersionType.INTERNAL, PRIMARY, System.nanoTime(), autoGeneratedIdTimestamp, isRetry);
|
||||||
engine.index(firstIndexRequest);
|
Engine.IndexResult result = engine.index(firstIndexRequest);
|
||||||
assertThat(firstIndexRequest.version(), equalTo(1L));
|
assertThat(result.getVersion(), equalTo(1L));
|
||||||
|
|
||||||
Engine.Index firstIndexRequestReplica = new Engine.Index(newUid("1"), doc, firstIndexRequest.version(), firstIndexRequest.versionType().versionTypeForReplicationAndRecovery(), REPLICA, System.nanoTime(), autoGeneratedIdTimestamp, isRetry);
|
Engine.Index firstIndexRequestReplica = new Engine.Index(newUid("1"), doc, result.getVersion(), firstIndexRequest.versionType().versionTypeForReplicationAndRecovery(), REPLICA, System.nanoTime(), autoGeneratedIdTimestamp, isRetry);
|
||||||
replicaEngine.index(firstIndexRequestReplica);
|
Engine.IndexResult indexReplicaResult = replicaEngine.index(firstIndexRequestReplica);
|
||||||
assertThat(firstIndexRequestReplica.version(), equalTo(1L));
|
assertThat(indexReplicaResult.getVersion(), equalTo(1L));
|
||||||
|
|
||||||
isRetry = false;
|
isRetry = false;
|
||||||
Engine.Index secondIndexRequest = new Engine.Index(newUid("1"), doc, Versions.MATCH_ANY, VersionType.INTERNAL, PRIMARY, System.nanoTime(), autoGeneratedIdTimestamp, isRetry);
|
Engine.Index secondIndexRequest = new Engine.Index(newUid("1"), doc, Versions.MATCH_ANY, VersionType.INTERNAL, PRIMARY, System.nanoTime(), autoGeneratedIdTimestamp, isRetry);
|
||||||
|
@ -2273,7 +2275,7 @@ public class InternalEngineTests extends ESTestCase {
|
||||||
assertEquals(1, topDocs.totalHits);
|
assertEquals(1, topDocs.totalHits);
|
||||||
}
|
}
|
||||||
|
|
||||||
Engine.Index secondIndexRequestReplica = new Engine.Index(newUid("1"), doc, firstIndexRequest.version(), firstIndexRequest.versionType().versionTypeForReplicationAndRecovery(), REPLICA, System.nanoTime(), autoGeneratedIdTimestamp, isRetry);
|
Engine.Index secondIndexRequestReplica = new Engine.Index(newUid("1"), doc, result.getVersion(), firstIndexRequest.versionType().versionTypeForReplicationAndRecovery(), REPLICA, System.nanoTime(), autoGeneratedIdTimestamp, isRetry);
|
||||||
replicaEngine.index(secondIndexRequestReplica);
|
replicaEngine.index(secondIndexRequestReplica);
|
||||||
replicaEngine.refresh("test");
|
replicaEngine.refresh("test");
|
||||||
try (Engine.Searcher searcher = replicaEngine.acquireSearcher("test")) {
|
try (Engine.Searcher searcher = replicaEngine.acquireSearcher("test")) {
|
||||||
|
|
|
@ -988,8 +988,8 @@ public class ShadowEngineTests extends ESTestCase {
|
||||||
for (int i = 0; i < numDocs; i++) {
|
for (int i = 0; i < numDocs; i++) {
|
||||||
ParsedDocument doc = testParsedDocument(Integer.toString(i), Integer.toString(i), "test", null, -1, -1, testDocument(), new BytesArray("{}"), null);
|
ParsedDocument doc = testParsedDocument(Integer.toString(i), Integer.toString(i), "test", null, -1, -1, testDocument(), new BytesArray("{}"), null);
|
||||||
Engine.Index firstIndexRequest = new Engine.Index(newUid(Integer.toString(i)), doc, Versions.MATCH_ANY, VersionType.INTERNAL, PRIMARY, System.nanoTime(), -1, false);
|
Engine.Index firstIndexRequest = new Engine.Index(newUid(Integer.toString(i)), doc, Versions.MATCH_ANY, VersionType.INTERNAL, PRIMARY, System.nanoTime(), -1, false);
|
||||||
primaryEngine.index(firstIndexRequest);
|
Engine.IndexResult indexResult = primaryEngine.index(firstIndexRequest);
|
||||||
assertThat(firstIndexRequest.version(), equalTo(1L));
|
assertThat(indexResult.getVersion(), equalTo(1L));
|
||||||
}
|
}
|
||||||
DocsStats docStats = primaryEngine.getDocStats();
|
DocsStats docStats = primaryEngine.getDocStats();
|
||||||
assertEquals(numDocs, docStats.getCount());
|
assertEquals(numDocs, docStats.getCount());
|
||||||
|
|
Loading…
Reference in New Issue