use of com.yahoo.vespa.http.client.handlers.V3MockParsingRequestHandler in project vespa by vespa-engine.
the class V3HttpAPIMultiClusterTest method requireThatAllNonAcceptedVersionWorks.
@Test
public void requireThatAllNonAcceptedVersionWorks() throws Exception {
try (Server serverA = new Server(new V3MockParsingRequestHandler(200, V3MockParsingRequestHandler.Scenario.DONT_ACCEPT_VERSION), 0);
Server serverB = new Server(new V3MockParsingRequestHandler(200, V3MockParsingRequestHandler.Scenario.DONT_ACCEPT_VERSION), 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(1).build()).build())) {
// cannot fail here, they are just enqueued
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 requireThatAllImmediateDisconnectWorks.
@Test
public void requireThatAllImmediateDisconnectWorks() throws Exception {
try (Server serverA = new Server(new V3MockParsingRequestHandler(200, V3MockParsingRequestHandler.Scenario.DISCONNECT_IMMEDIATELY), 0);
Server serverB = new Server(new V3MockParsingRequestHandler(200, V3MockParsingRequestHandler.Scenario.DISCONNECT_IMMEDIATELY), 0);
Server serverC = new Server(new V3MockParsingRequestHandler(200, V3MockParsingRequestHandler.Scenario.DISCONNECT_IMMEDIATELY), 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(1000).build()).setConnectionParams(new ConnectionParams.Builder().setNumPersistentConnectionsPerEndpoint(1).setMaxRetries(1).build()).build())) {
// cannot fail here, they are just enqueued
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 requireThatAllMbusErrorWorks.
@Test
public void requireThatAllMbusErrorWorks() throws Exception {
try (Server serverA = new Server(new V3MockParsingRequestHandler(200, V3MockParsingRequestHandler.Scenario.MBUS_RETURNED_ERROR), 0);
Server serverB = new Server(new V3MockParsingRequestHandler(200, V3MockParsingRequestHandler.Scenario.MBUS_RETURNED_ERROR), 0);
Server serverC = new Server(new V3MockParsingRequestHandler(200, V3MockParsingRequestHandler.Scenario.MBUS_RETURNED_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).build()).setConnectionParams(new ConnectionParams.Builder().setNumPersistentConnectionsPerEndpoint(1).setMaxRetries(0).build()).build())) {
// cannot fail here, they are just enqueued
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.FATAL_ERROR));
assertThat(details.get(Endpoint.create("localhost", serverB.getPort(), false)).getResultType(), is(Result.ResultType.FATAL_ERROR));
assertThat(details.get(Endpoint.create("localhost", serverC.getPort(), false)).getResultType(), is(Result.ResultType.FATAL_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 requireThatOneWrongSessionIdWorks.
@Test
public void requireThatOneWrongSessionIdWorks() 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.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(1000).setServerTimeout(2, TimeUnit.SECONDS).setClientTimeout(2, TimeUnit.SECONDS).setLocalQueueTimeOut(2000).build()).setConnectionParams(new ConnectionParams.Builder().setNumPersistentConnectionsPerEndpoint(1).setMaxRetries(0).build()).build())) {
waitForHandshakesOk(2, 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(results.isEmpty(), is(true));
}
}
use of com.yahoo.vespa.http.client.handlers.V3MockParsingRequestHandler in project vespa by vespa-engine.
the class V3HttpAPIMultiClusterTest method requireThatFeedingWorks.
@Test
public void requireThatFeedingWorks() 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.ALL_OK), 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()).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, not(nullValue()));
assertThat(r.getDetails().toString(), r.isSuccess(), is(true));
assertThat(r.getDetails().size(), is(3));
assertThat(r.getDetails().get(0).getTraceMessage(), is("Trace message"));
}
assertThat(results.isEmpty(), is(true));
final String stats = session.getStatsAsJson();
assertThat(stats, containsString("maxChunkSizeBytes\":51200"));
}
}
Aggregations