diff options
author | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2018-10-16 18:54:08 +0200 |
---|---|---|
committer | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2018-10-16 18:54:08 +0200 |
commit | a81b7fff7f4006ab8fe1b89a0a50d84af734b10f (patch) | |
tree | c7d85f2c0aaa792cf0af066e41027e78c93f88e6 /vespa-http-client/src/test | |
parent | b1915fc0c68d732870b2bc68706dcf9cf6c5da29 (diff) |
Look at oldest send operation, rather than number of running ones
Diffstat (limited to 'vespa-http-client/src/test')
2 files changed, 13 insertions, 6 deletions
diff --git a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/api/FeedClientImplTest.java b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/api/FeedClientImplTest.java index 2eb4d243ee3..b8470fd489f 100644 --- a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/api/FeedClientImplTest.java +++ b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/api/FeedClientImplTest.java @@ -17,16 +17,12 @@ public class FeedClientImplTest { @Test public void testCloseWaitTimeOldTimestamp() { - assertThat(FeedClientImpl.waitForOperations(Instant.now().minusSeconds(1000), 1, sleepValueMillis, 10), is(false)); + assertThat(FeedClientImpl.waitForOperations(Instant.now().minusSeconds(1000), sleepValueMillis, 10), is(false)); } @Test public void testCloseWaitTimeOutInFutureStillOperations() { - assertThat(FeedClientImpl.waitForOperations(Instant.now(), 1, sleepValueMillis, 2000), is(true)); + assertThat(FeedClientImpl.waitForOperations(Instant.now(), sleepValueMillis, 2000), is(true)); } - @Test - public void testCloseWaitZeroOperations() { - assertThat(FeedClientImpl.waitForOperations(Instant.now(), 0, sleepValueMillis, 2000), is(false)); - } } diff --git a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/operationProcessor/OperationProcessorTest.java b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/operationProcessor/OperationProcessorTest.java index 774a516cc14..3a335aa5da0 100644 --- a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/operationProcessor/OperationProcessorTest.java +++ b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/core/operationProcessor/OperationProcessorTest.java @@ -11,6 +11,7 @@ import com.yahoo.vespa.http.client.core.EndpointResult; import org.junit.Test; import java.util.ArrayDeque; +import java.util.Optional; import java.util.Queue; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ScheduledThreadPoolExecutor; @@ -19,6 +20,7 @@ import java.util.concurrent.TimeUnit; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyLong; import static org.mockito.Mockito.mock; @@ -173,12 +175,15 @@ public class OperationProcessorTest { assertThat(queue.size(), is(0)); // Only one operations should be in flight. assertThat(operationProcessor.getIncompleteResultQueueSize(), is(1)); + assertThat(operationProcessor.oldestIncompleteResultId(), is(Optional.of(doc1.getOperationId()))); operationProcessor.resultReceived(new EndpointResult(doc1.getOperationId(), new Result.Detail(Endpoint.create("host"))), 0); assertThat(queue.size(), is(1)); assertThat(operationProcessor.getIncompleteResultQueueSize(), is(1)); + assertThat(operationProcessor.oldestIncompleteResultId(), is(Optional.of(doc1b.getOperationId()))); operationProcessor.resultReceived(new EndpointResult(doc1b.getOperationId(), new Result.Detail(Endpoint.create("host"))), 0); assertThat(queue.size(), is(2)); assertThat(operationProcessor.getIncompleteResultQueueSize(), is(0)); + assertThat(operationProcessor.oldestIncompleteResultId(), is(Optional.empty())); // This should have no effect. operationProcessor.resultReceived(new EndpointResult(doc1.getOperationId(), new Result.Detail(Endpoint.create("host"))), 0); operationProcessor.resultReceived(new EndpointResult(doc1b.getOperationId(), new Result.Detail(Endpoint.create("host"))), 0); @@ -239,18 +244,24 @@ public class OperationProcessorTest { assertThat(queue.size(), is(0)); assertThat(operationProcessor.getIncompleteResultQueueSize(), is(3)); + assertThat(operationProcessor.oldestIncompleteResultId(), is(Optional.of(doc1.getOperationId()))); // This should have no effect since it should not be sent. operationProcessor.resultReceived(new EndpointResult(doc1b.getOperationId(), new Result.Detail(endpoint)), 0); assertThat(operationProcessor.getIncompleteResultQueueSize(), is(3)); + assertThat(operationProcessor.oldestIncompleteResultId(), is(Optional.of(doc1.getOperationId()))); operationProcessor.resultReceived(new EndpointResult(doc3.getOperationId(), new Result.Detail(endpoint)), 0); assertThat(operationProcessor.getIncompleteResultQueueSize(), is(2)); + assertThat(operationProcessor.oldestIncompleteResultId(), is(Optional.of(doc1.getOperationId()))); operationProcessor.resultReceived(new EndpointResult(doc2.getOperationId(), new Result.Detail(endpoint)), 0); assertThat(operationProcessor.getIncompleteResultQueueSize(), is(1)); + assertThat(operationProcessor.oldestIncompleteResultId(), is(Optional.of(doc1.getOperationId()))); operationProcessor.resultReceived(new EndpointResult(doc1.getOperationId(), new Result.Detail(endpoint)), 0); assertThat(operationProcessor.getIncompleteResultQueueSize(), is(1)); + assertThat(operationProcessor.oldestIncompleteResultId(), is(Optional.of(doc1b.getOperationId()))); operationProcessor.resultReceived(new EndpointResult(doc1b.getOperationId(), new Result.Detail(endpoint)), 0); assertThat(operationProcessor.getIncompleteResultQueueSize(), is(0)); + assertThat(operationProcessor.oldestIncompleteResultId(), is(Optional.empty())); } @Test |