use of com.yahoo.vespa.http.client.handlers.V3MockParsingRequestHandler in project vespa by vespa-engine.
the class V3HttpAPIMultiClusterTest method requireThatAllWrongSessionIdWorks.
@Test
public void requireThatAllWrongSessionIdWorks() throws Exception {
try (Server serverA = new Server(new V3MockParsingRequestHandler(200, V3MockParsingRequestHandler.Scenario.RETURN_WRONG_SESSION_ID), 0);
Server serverB = new Server(new V3MockParsingRequestHandler(200, V3MockParsingRequestHandler.Scenario.RETURN_WRONG_SESSION_ID), 0);
Server serverC = new Server(new V3MockParsingRequestHandler(200, V3MockParsingRequestHandler.Scenario.RETURN_WRONG_SESSION_ID), 0);
Session session = SessionFactory.create(new SessionParams.Builder().addCluster(new Cluster.Builder().addEndpoint(Endpoint.create("localhost", serverA.getPort(), false)).build()).addCluster(new Cluster.Builder().addEndpoint(Endpoint.create("localhost", serverB.getPort(), false)).build()).addCluster(new Cluster.Builder().addEndpoint(Endpoint.create("localhost", serverC.getPort(), false)).build()).setFeedParams(new FeedParams.Builder().setMaxSleepTimeMs(0).setMaxChunkSizeBytes(1).setServerTimeout(2, TimeUnit.SECONDS).setClientTimeout(2, TimeUnit.SECONDS).setLocalQueueTimeOut(2000).build()).setConnectionParams(new ConnectionParams.Builder().setNumPersistentConnectionsPerEndpoint(1).setMaxRetries(0).build()).build())) {
writeDocuments(session);
Map<String, Result> results = getResults(session, documents.size());
assertThat(results.size(), is(documents.size()));
for (TestDocument document : documents) {
Result r = results.remove(document.getDocumentId());
assertThat(r, not(nullValue()));
// assertThat(r.getDetails().toString(), r.isSuccess(), is(false));
assertThat(r.getDetails().size(), is(3));
Map<Endpoint, Result.Detail> details = new HashMap<>();
for (Result.Detail detail : r.getDetails()) {
details.put(detail.getEndpoint(), detail);
}
assertThat(details.get(Endpoint.create("localhost", serverA.getPort(), false)).getResultType(), is(Result.ResultType.TRANSITIVE_ERROR));
assertThat(details.get(Endpoint.create("localhost", serverB.getPort(), false)).getResultType(), is(Result.ResultType.TRANSITIVE_ERROR));
assertThat(details.get(Endpoint.create("localhost", serverC.getPort(), false)).getResultType(), is(Result.ResultType.TRANSITIVE_ERROR));
}
assertThat(results.isEmpty(), is(true));
}
}
use of com.yahoo.vespa.http.client.handlers.V3MockParsingRequestHandler in project vespa by vespa-engine.
the class V3HttpAPIMultiClusterTest method testPriorityAndTraceFlag.
@Test
public void testPriorityAndTraceFlag() throws Exception {
try (Server serverA = new Server(new V3MockParsingRequestHandler(200, V3MockParsingRequestHandler.Scenario.EXPECT_HIGHEST_PRIORITY_AND_TRACELEVEL_123), 0);
Session session = SessionFactory.create(new SessionParams.Builder().addCluster(new Cluster.Builder().addEndpoint(Endpoint.create("localhost", serverA.getPort(), false)).build()).setConnectionParams(new ConnectionParams.Builder().setTraceLevel(123).build()).setFeedParams(new FeedParams.Builder().setMaxSleepTimeMs(0).setPriority("HIGHEST").build()).build())) {
writeDocuments(session);
Map<String, Result> results = getResults(session, documents.size());
assertThat("Results received: " + results.values(), results.size(), is(documents.size()));
for (TestDocument document : documents) {
Result r = results.remove(document.getDocumentId());
assertThat(r.getDetails().toString(), r.isSuccess(), is(true));
}
}
}
use of com.yahoo.vespa.http.client.handlers.V3MockParsingRequestHandler in project vespa by vespa-engine.
the class V3HttpAPIMultiClusterTest method requireThatOneNonAcceptedVersionWorks.
@Test
public void requireThatOneNonAcceptedVersionWorks() throws Exception {
try (Server serverA = new Server(new V3MockParsingRequestHandler(200, V3MockParsingRequestHandler.Scenario.ALL_OK), 0);
Server serverB = new Server(new V3MockParsingRequestHandler(200, V3MockParsingRequestHandler.Scenario.ALL_OK), 0);
Server serverC = new Server(new V3MockParsingRequestHandler(200, V3MockParsingRequestHandler.Scenario.DONT_ACCEPT_VERSION), 0);
Session session = SessionFactory.create(new SessionParams.Builder().addCluster(new Cluster.Builder().addEndpoint(Endpoint.create("localhost", serverA.getPort(), false)).build()).addCluster(new Cluster.Builder().addEndpoint(Endpoint.create("localhost", serverB.getPort(), false)).build()).addCluster(new Cluster.Builder().addEndpoint(Endpoint.create("localhost", serverC.getPort(), false)).build()).setFeedParams(new FeedParams.Builder().setMaxSleepTimeMs(0).setMaxChunkSizeBytes(1).setLocalQueueTimeOut(2000).build()).setConnectionParams(new ConnectionParams.Builder().setNumPersistentConnectionsPerEndpoint(1).setMaxRetries(0).build()).build())) {
writeDocument(session);
Map<String, Result> results = getResults(session, 1);
assertThat(results.size(), is(1));
Result r = results.values().iterator().next();
assertThat(r, not(nullValue()));
assertThat(r.getDetails().toString(), r.isSuccess(), is(false));
Map<Endpoint, Result.Detail> details = new HashMap<>();
for (Result.Detail detail : r.getDetails()) {
details.put(detail.getEndpoint(), detail);
}
Result.Detail failed = details.remove(Endpoint.create("localhost", serverC.getPort(), false));
assertThat(failed.getResultType(), is(Result.ResultType.TRANSITIVE_ERROR));
for (Result.Detail detail : details.values()) {
assertThat(detail.getResultType(), is(Result.ResultType.OPERATION_EXECUTED));
}
}
}
use of com.yahoo.vespa.http.client.handlers.V3MockParsingRequestHandler in project vespa by vespa-engine.
the class V3HttpAPIMultiClusterTest method requireThatOneInternalServerErrorWorks.
@Test
public void requireThatOneInternalServerErrorWorks() throws Exception {
try (Server serverA = new Server(new V3MockParsingRequestHandler(200, V3MockParsingRequestHandler.Scenario.ALL_OK), 0);
Server serverB = new Server(new V3MockParsingRequestHandler(200, V3MockParsingRequestHandler.Scenario.ALL_OK), 0);
Server serverC = new Server(new V3MockParsingRequestHandler(200, V3MockParsingRequestHandler.Scenario.INTERNAL_SERVER_ERROR), 0);
Session session = SessionFactory.create(new SessionParams.Builder().addCluster(new Cluster.Builder().addEndpoint(Endpoint.create("localhost", serverA.getPort(), false)).build()).addCluster(new Cluster.Builder().addEndpoint(Endpoint.create("localhost", serverB.getPort(), false)).build()).addCluster(new Cluster.Builder().addEndpoint(Endpoint.create("localhost", serverC.getPort(), false)).build()).setFeedParams(new FeedParams.Builder().setMaxSleepTimeMs(0).setMaxChunkSizeBytes(1).setLocalQueueTimeOut(2000).build()).setConnectionParams(new ConnectionParams.Builder().setNumPersistentConnectionsPerEndpoint(1).setMaxRetries(0).build()).build())) {
writeDocument(session);
Map<String, Result> results = getResults(session, 1);
assertThat(results.size(), is(1));
Result r = results.values().iterator().next();
assertThat(r, not(nullValue()));
assertThat(r.getDetails().toString(), r.isSuccess(), is(false));
Map<Endpoint, Result.Detail> details = new HashMap<>();
for (Result.Detail detail : r.getDetails()) {
details.put(detail.getEndpoint(), detail);
}
Result.Detail failed = details.remove(Endpoint.create("localhost", serverC.getPort(), false));
assertThat(failed.getResultType(), is(Result.ResultType.TRANSITIVE_ERROR));
for (Result.Detail detail : details.values()) {
assertThat(detail.getResultType(), is(Result.ResultType.OPERATION_EXECUTED));
}
}
}
use of com.yahoo.vespa.http.client.handlers.V3MockParsingRequestHandler in project vespa by vespa-engine.
the class V3HttpAPIMultiClusterTest method requireThatOneTimeoutWorks.
@Test
public void requireThatOneTimeoutWorks() throws Exception {
try (Server serverA = new Server(new V3MockParsingRequestHandler(200, V3MockParsingRequestHandler.Scenario.ALL_OK), 0);
Server serverB = new Server(new V3MockParsingRequestHandler(200, V3MockParsingRequestHandler.Scenario.ALL_OK), 0);
Server serverC = new Server(new V3MockParsingRequestHandler(200, V3MockParsingRequestHandler.Scenario.NEVER_RETURN_ANY_RESULTS), 0);
Session session = SessionFactory.create(new SessionParams.Builder().addCluster(new Cluster.Builder().addEndpoint(Endpoint.create("localhost", serverA.getPort(), false)).build()).addCluster(new Cluster.Builder().addEndpoint(Endpoint.create("localhost", serverB.getPort(), false)).build()).addCluster(new Cluster.Builder().addEndpoint(Endpoint.create("localhost", serverC.getPort(), false)).build()).setFeedParams(new FeedParams.Builder().setMaxSleepTimeMs(0).setMaxChunkSizeBytes(10000).setServerTimeout(2, TimeUnit.SECONDS).setClientTimeout(2, TimeUnit.SECONDS).setLocalQueueTimeOut(2000).build()).setConnectionParams(new ConnectionParams.Builder().setNumPersistentConnectionsPerEndpoint(1).setMaxRetries(1).build()).build())) {
waitForHandshakesOk(3, session);
writeDocuments(session);
Map<String, Result> results = getResults(session, documents.size());
assertThat(results.size(), is(documents.size()));
for (TestDocument document : documents) {
Result r = results.remove(document.getDocumentId());
assertThat(r, not(nullValue()));
// assertThat(r.getDetails().toString(), r.isSuccess(), is(false));
assertThat(r.getDetails().size(), is(3));
Map<Endpoint, Result.Detail> details = new HashMap<>();
for (Result.Detail detail : r.getDetails()) {
details.put(detail.getEndpoint(), detail);
}
assertThat(details.get(Endpoint.create("localhost", serverA.getPort(), false)).getResultType(), is(Result.ResultType.OPERATION_EXECUTED));
assertThat(details.get(Endpoint.create("localhost", serverB.getPort(), false)).getResultType(), is(Result.ResultType.OPERATION_EXECUTED));
assertThat(details.get(Endpoint.create("localhost", serverC.getPort(), false)).getResultType(), is(Result.ResultType.TRANSITIVE_ERROR));
assertThat(details.get(Endpoint.create("localhost", serverC.getPort(), false)).getResultType(), is(Result.ResultType.TRANSITIVE_ERROR));
}
assertThat(results.isEmpty(), is(true));
}
}
Aggregations