|
@@ -111,7 +111,6 @@ import static java.util.Collections.synchronizedSet;
|
|
|
import static org.apache.lucene.util.TestUtil.randomSimpleString;
|
|
|
import static org.elasticsearch.action.bulk.BackoffPolicy.constantBackoff;
|
|
|
import static org.elasticsearch.common.unit.TimeValue.timeValueMillis;
|
|
|
-import static org.elasticsearch.common.unit.TimeValue.timeValueNanos;
|
|
|
import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds;
|
|
|
import static org.hamcrest.Matchers.contains;
|
|
|
import static org.hamcrest.Matchers.containsString;
|
|
@@ -255,7 +254,7 @@ public class AsyncBulkByScrollActionTests extends ESTestCase {
|
|
|
|
|
|
long total = randomIntBetween(0, Integer.MAX_VALUE);
|
|
|
ScrollableHitSource.Response response = new ScrollableHitSource.Response(false, emptyList(), total, emptyList(), null);
|
|
|
- simulateScrollResponse(new DummyAsyncBulkByScrollAction(), timeValueSeconds(0), 0, response);
|
|
|
+ simulateScrollResponse(new DummyAsyncBulkByScrollAction(), 0, 0, response);
|
|
|
assertEquals(total, testTask.getStatus().getTotal());
|
|
|
}
|
|
|
|
|
@@ -268,7 +267,7 @@ public class AsyncBulkByScrollActionTests extends ESTestCase {
|
|
|
Hit hit = new ScrollableHitSource.BasicHit("index", "id", 0);
|
|
|
ScrollableHitSource.Response response = new ScrollableHitSource.Response(false, emptyList(), 1, singletonList(hit), null);
|
|
|
DummyAsyncBulkByScrollAction action = new DummyAsyncBulkByScrollAction();
|
|
|
- simulateScrollResponse(action, timeValueNanos(System.nanoTime()), 0, response);
|
|
|
+ simulateScrollResponse(action, System.nanoTime(), 0, response);
|
|
|
|
|
|
// Use assert busy because the update happens on another thread
|
|
|
final int expectedBatches = batches;
|
|
@@ -354,7 +353,7 @@ public class AsyncBulkByScrollActionTests extends ESTestCase {
|
|
|
}
|
|
|
});
|
|
|
ScrollableHitSource.Response response = new ScrollableHitSource.Response(false, emptyList(), 0, emptyList(), null);
|
|
|
- simulateScrollResponse(new DummyAsyncBulkByScrollAction(), timeValueNanos(System.nanoTime()), 10, response);
|
|
|
+ simulateScrollResponse(new DummyAsyncBulkByScrollAction(), System.nanoTime(), 10, response);
|
|
|
ExecutionException e = expectThrows(ExecutionException.class, () -> listener.get());
|
|
|
assertThat(e.getCause(), instanceOf(EsRejectedExecutionException.class));
|
|
|
assertThat(e.getCause(), hasToString(containsString("test")));
|
|
@@ -372,7 +371,7 @@ public class AsyncBulkByScrollActionTests extends ESTestCase {
|
|
|
SearchFailure shardFailure = new SearchFailure(new RuntimeException("test"));
|
|
|
ScrollableHitSource.Response scrollResponse = new ScrollableHitSource.Response(false, singletonList(shardFailure), 0,
|
|
|
emptyList(), null);
|
|
|
- simulateScrollResponse(new DummyAsyncBulkByScrollAction(), timeValueNanos(System.nanoTime()), 0, scrollResponse);
|
|
|
+ simulateScrollResponse(new DummyAsyncBulkByScrollAction(), System.nanoTime(), 0, scrollResponse);
|
|
|
BulkByScrollResponse response = listener.get();
|
|
|
assertThat(response.getBulkFailures(), empty());
|
|
|
assertThat(response.getSearchFailures(), contains(shardFailure));
|
|
@@ -386,7 +385,7 @@ public class AsyncBulkByScrollActionTests extends ESTestCase {
|
|
|
*/
|
|
|
public void testSearchTimeoutsAbortRequest() throws Exception {
|
|
|
ScrollableHitSource.Response scrollResponse = new ScrollableHitSource.Response(true, emptyList(), 0, emptyList(), null);
|
|
|
- simulateScrollResponse(new DummyAsyncBulkByScrollAction(), timeValueNanos(System.nanoTime()), 0, scrollResponse);
|
|
|
+ simulateScrollResponse(new DummyAsyncBulkByScrollAction(), System.nanoTime(), 0, scrollResponse);
|
|
|
BulkByScrollResponse response = listener.get();
|
|
|
assertThat(response.getBulkFailures(), empty());
|
|
|
assertThat(response.getSearchFailures(), empty());
|
|
@@ -423,7 +422,7 @@ public class AsyncBulkByScrollActionTests extends ESTestCase {
|
|
|
ScrollableHitSource.BasicHit hit = new ScrollableHitSource.BasicHit("index", "id", 0);
|
|
|
hit.setSource(new BytesArray("{}"), XContentType.JSON);
|
|
|
ScrollableHitSource.Response response = new ScrollableHitSource.Response(false, emptyList(), 1, singletonList(hit), null);
|
|
|
- simulateScrollResponse(action, timeValueNanos(System.nanoTime()), 0, response);
|
|
|
+ simulateScrollResponse(action, System.nanoTime(), 0, response);
|
|
|
ExecutionException e = expectThrows(ExecutionException.class, () -> listener.get());
|
|
|
assertThat(e.getCause(), instanceOf(RuntimeException.class));
|
|
|
assertThat(e.getCause().getMessage(), equalTo("surprise"));
|
|
@@ -619,7 +618,7 @@ public class AsyncBulkByScrollActionTests extends ESTestCase {
|
|
|
}
|
|
|
|
|
|
public void testCancelBeforeScrollResponse() throws Exception {
|
|
|
- cancelTaskCase((DummyAsyncBulkByScrollAction action) -> simulateScrollResponse(action, timeValueNanos(System.nanoTime()), 1,
|
|
|
+ cancelTaskCase((DummyAsyncBulkByScrollAction action) -> simulateScrollResponse(action, System.nanoTime(), 1,
|
|
|
new ScrollableHitSource.Response(false, emptyList(), between(1, 100000), emptyList(), null)));
|
|
|
}
|
|
|
|
|
@@ -634,7 +633,7 @@ public class AsyncBulkByScrollActionTests extends ESTestCase {
|
|
|
}
|
|
|
|
|
|
public void testCancelBeforeStartNextScroll() throws Exception {
|
|
|
- TimeValue now = timeValueNanos(System.nanoTime());
|
|
|
+ long now = System.nanoTime();
|
|
|
cancelTaskCase((DummyAsyncBulkByScrollAction action) -> action.notifyDone(now, null, 0));
|
|
|
}
|
|
|
|
|
@@ -683,7 +682,7 @@ public class AsyncBulkByScrollActionTests extends ESTestCase {
|
|
|
ScrollableHitSource.Response response = new ScrollableHitSource.Response(false, emptyList(), total, emptyList(), null);
|
|
|
// Use a long delay here so the test will time out if the cancellation doesn't reschedule the throttled task
|
|
|
worker.rethrottle(1);
|
|
|
- simulateScrollResponse(action, timeValueNanos(System.nanoTime()), 1000, response);
|
|
|
+ simulateScrollResponse(action, System.nanoTime(), 1000, response);
|
|
|
|
|
|
// Now that we've got our cancel we'll just verify that it all came through all right
|
|
|
assertEquals(reason, listener.get(10, TimeUnit.SECONDS).getReasonCancelled());
|
|
@@ -712,7 +711,7 @@ public class AsyncBulkByScrollActionTests extends ESTestCase {
|
|
|
/**
|
|
|
* Simulate a scroll response by setting the scroll id and firing the onScrollResponse method.
|
|
|
*/
|
|
|
- private void simulateScrollResponse(DummyAsyncBulkByScrollAction action, TimeValue lastBatchTime, int lastBatchSize,
|
|
|
+ private void simulateScrollResponse(DummyAsyncBulkByScrollAction action, long lastBatchTime, int lastBatchSize,
|
|
|
ScrollableHitSource.Response response) {
|
|
|
action.setScroll(scrollId());
|
|
|
action.onScrollResponse(lastBatchTime, lastBatchSize, new ScrollableHitSource.AsyncResponse() {
|