use of io.confluent.ksql.physical.scalablepush.PushRouting.PushConnectionsHandle in project ksql by confluentinc.
the class PushRoutingTest method shouldFail_duringPlanExecute.
@Test
public void shouldFail_duringPlanExecute() throws ExecutionException, InterruptedException {
// Given:
when(pushRoutingOptions.getHasBeenForwarded()).thenReturn(true);
final PushRouting routing = new PushRouting();
when(pushPhysicalPlanManager.execute()).thenThrow(new RuntimeException("Error!"));
// When:
final PushConnectionsHandle handle = handlePushRouting(routing);
// Then:
assertThat(handle.getError().getMessage(), containsString("Error!"));
}
use of io.confluent.ksql.physical.scalablepush.PushRouting.PushConnectionsHandle in project ksql by confluentinc.
the class PushRoutingTest method shouldFail_hitRequestLimitLocal.
@Test
public void shouldFail_hitRequestLimitLocal() throws ExecutionException, InterruptedException {
// Given:
transientQueryQueue = new TransientQueryQueue(OptionalInt.empty(), 1, 100);
when(pushRoutingOptions.getHasBeenForwarded()).thenReturn(true);
final PushRouting routing = new PushRouting();
BufferedPublisher<QueryRow> localPublisher = new BufferedPublisher<>(context);
when(pushPhysicalPlanManager.execute()).thenReturn(localPublisher);
// When:
final PushConnectionsHandle handle = handlePushRouting(routing);
context.runOnContext(v -> {
localPublisher.accept(LOCAL_ROW1);
localPublisher.accept(LOCAL_ROW2);
});
// Then:
Set<List<?>> rows = waitOnRows(1);
handle.close();
assertThat(rows.contains(LOCAL_ROW1.value().values()), is(true));
assertThat(handle.getError().getMessage(), containsString("Hit limit of request queue"));
}
use of io.confluent.ksql.physical.scalablepush.PushRouting.PushConnectionsHandle in project ksql by confluentinc.
the class PushRoutingTest method shouldSucceed_remoteNodeComplete.
@Test
public void shouldSucceed_remoteNodeComplete() throws ExecutionException, InterruptedException {
// Given:
final AtomicReference<Set<KsqlNode>> nodes = new AtomicReference<>(ImmutableSet.of(ksqlNodeLocal, ksqlNodeRemote));
final PushRouting routing = new PushRouting(sqr -> nodes.get(), 50, false);
// When:
final PushConnectionsHandle handle = handlePushRouting(routing);
context.runOnContext(v -> {
localPublisher.accept(LOCAL_ROW1);
localPublisher.accept(LOCAL_ROW2);
remotePublisher.accept(REMOTE_ROW1);
remotePublisher.accept(REMOTE_ROW2);
remotePublisher.complete();
});
Set<List<?>> rows = waitOnRows(4);
waitOnNodeStatus(handle, ksqlNodeRemote, RoutingResultStatus.COMPLETE);
handle.close();
// Then:
assertThat(rows.contains(LOCAL_ROW1.value().values()), is(true));
assertThat(rows.contains(LOCAL_ROW2.value().values()), is(true));
assertThat(rows.contains(REMOTE_ROW1.getRow().get().getColumns()), is(true));
assertThat(rows.contains(REMOTE_ROW2.getRow().get().getColumns()), is(true));
assertThat(handle.get(ksqlNodeRemote).get().getStatus(), is(RoutingResultStatus.COMPLETE));
}
use of io.confluent.ksql.physical.scalablepush.PushRouting.PushConnectionsHandle in project ksql by confluentinc.
the class PushRoutingTest method shouldSucceed_addRemoteNode.
@Test
public void shouldSucceed_addRemoteNode() throws ExecutionException, InterruptedException {
// Given:
final AtomicReference<Set<KsqlNode>> nodes = new AtomicReference<>(ImmutableSet.of(ksqlNodeLocal));
final PushRouting routing = new PushRouting(sqr -> nodes.get(), 50, true);
// When:
final PushConnectionsHandle handle = handlePushRouting(routing);
context.runOnContext(v -> {
localPublisher.accept(LOCAL_ROW1);
localPublisher.accept(LOCAL_ROW2);
});
Set<List<?>> rows = waitOnRows(2);
nodes.set(ImmutableSet.of(ksqlNodeLocal, ksqlNodeRemote));
context.runOnContext(v -> {
remotePublisher.accept(REMOTE_ROW1);
remotePublisher.accept(REMOTE_ROW2);
});
// Then:
rows.addAll(waitOnRows(2));
handle.close();
assertThat(rows.contains(LOCAL_ROW1.value().values()), is(true));
assertThat(rows.contains(LOCAL_ROW2.value().values()), is(true));
assertThat(rows.contains(REMOTE_ROW1.getRow().get().getColumns()), is(true));
assertThat(rows.contains(REMOTE_ROW2.getRow().get().getColumns()), is(true));
}
use of io.confluent.ksql.physical.scalablepush.PushRouting.PushConnectionsHandle in project ksql by confluentinc.
the class PushRoutingTest method shouldFail_non200RemoteCall.
@Test
public void shouldFail_non200RemoteCall() throws ExecutionException, InterruptedException {
// Given:
when(locator.locate()).thenReturn(ImmutableList.of(ksqlNodeRemote));
final PushRouting routing = new PushRouting();
when(simpleKsqlClient.makeQueryRequestStreamed(any(), any(), any(), any())).thenReturn(createFuture(RestResponse.erroneous(500, "Error response!")));
// When:
final PushConnectionsHandle handle = handlePushRouting(routing);
// Then:
assertThat(handle.getError().getMessage(), containsString("Error response!"));
}
Aggregations