use of io.confluent.ksql.physical.scalablepush.PushRouting.RoutingResult in project ksql by confluentinc.
the class PushRoutingTest method shouldSucceed_removeRemoteNode.
@Test
public void shouldSucceed_removeRemoteNode() throws ExecutionException, InterruptedException {
// Given:
final AtomicReference<Set<KsqlNode>> nodes = new AtomicReference<>(ImmutableSet.of(ksqlNodeLocal, ksqlNodeRemote));
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);
remotePublisher.accept(REMOTE_ROW1);
remotePublisher.accept(REMOTE_ROW2);
});
Set<List<?>> rows = waitOnRows(4);
final RoutingResult result = handle.get(ksqlNodeRemote).get();
nodes.set(ImmutableSet.of(ksqlNodeLocal));
while (handle.get(ksqlNodeRemote).isPresent()) {
Thread.sleep(100);
continue;
}
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(result.getStatus(), is(RoutingResultStatus.REMOVED));
}
Aggregations