use of io.confluent.ksql.rest.entity.KsqlHostInfoEntity in project ksql by confluentinc.
the class PullQueryRoutingFunctionalTest method shouldQueryActiveWhenActiveAliveStandbyDeadQueryIssuedToRouter.
@Test
public void shouldQueryActiveWhenActiveAliveStandbyDeadQueryIssuedToRouter() {
// Given:
ClusterFormation clusterFormation = findClusterFormation(TEST_APP_0, TEST_APP_1, TEST_APP_2);
waitForClusterToBeDiscovered(clusterFormation.router.getApp(), 3, USER_CREDS);
waitForRemoteServerToChangeStatus(clusterFormation.router.getApp(), clusterFormation.router.getHost(), HighAvailabilityTestUtil.lagsReported(3), USER_CREDS);
// Partition off the standby
clusterFormation.standBy.getShutoffs().shutOffAll();
waitForRemoteServerToChangeStatus(clusterFormation.router.getApp(), clusterFormation.active.getHost(), HighAvailabilityTestUtil::remoteServerIsUp, USER_CREDS);
waitForRemoteServerToChangeStatus(clusterFormation.router.getApp(), clusterFormation.standBy.getHost(), HighAvailabilityTestUtil::remoteServerIsDown, USER_CREDS);
// When:
final List<StreamedRow> rows_0 = makePullQueryRequest(clusterFormation.router.getApp(), sql, null, USER_CREDS);
// Then:
assertThat(rows_0, hasSize(HEADER + 1));
KsqlHostInfoEntity host = rows_0.get(1).getSourceHost().get();
assertThat(host.getHost(), is(clusterFormation.active.getHost().getHost()));
assertThat(host.getPort(), is(clusterFormation.active.getHost().getPort()));
assertThat(rows_0.get(1).getRow(), is(not(Optional.empty())));
assertThat(rows_0.get(1).getRow().get().getColumns(), is(ImmutableList.of(KEY, 1)));
}
use of io.confluent.ksql.rest.entity.KsqlHostInfoEntity in project ksql by confluentinc.
the class PullQueryRoutingFunctionalTest method shouldQueryActiveWhenActiveAliveQueryIssuedToStandby.
@Test
public void shouldQueryActiveWhenActiveAliveQueryIssuedToStandby() throws Exception {
// Given:
ClusterFormation clusterFormation = findClusterFormation(TEST_APP_0, TEST_APP_1, TEST_APP_2);
waitForClusterToBeDiscovered(clusterFormation.standBy.getApp(), 3, USER_CREDS);
waitForRemoteServerToChangeStatus(clusterFormation.router.getApp(), clusterFormation.router.getHost(), HighAvailabilityTestUtil.lagsReported(3), USER_CREDS);
waitForRemoteServerToChangeStatus(clusterFormation.standBy.getApp(), clusterFormation.active.getHost(), HighAvailabilityTestUtil::remoteServerIsUp, USER_CREDS);
// When:
List<StreamedRow> rows_0 = makePullQueryRequest(clusterFormation.standBy.getApp(), sql, null, USER_CREDS);
// Then:
assertThat(rows_0, hasSize(HEADER + 1));
KsqlHostInfoEntity host = rows_0.get(1).getSourceHost().get();
assertThat(host.getHost(), is(clusterFormation.active.getHost().getHost()));
assertThat(host.getPort(), is(clusterFormation.active.getHost().getPort()));
assertThat(rows_0.get(1).getRow(), is(not(Optional.empty())));
assertThat(rows_0.get(1).getRow().get().getColumns(), is(ImmutableList.of(KEY, 1)));
}
use of io.confluent.ksql.rest.entity.KsqlHostInfoEntity in project ksql by confluentinc.
the class PullQueryRoutingFunctionalTest method shouldFilterLaggyServers.
@Test
public void shouldFilterLaggyServers() throws Exception {
// Given:
ClusterFormation clusterFormation = findClusterFormation(TEST_APP_0, TEST_APP_1, TEST_APP_2);
waitForClusterToBeDiscovered(clusterFormation.router.getApp(), 3, USER_CREDS);
waitForRemoteServerToChangeStatus(clusterFormation.router.getApp(), clusterFormation.router.getHost(), HighAvailabilityTestUtil.lagsReported(3), USER_CREDS);
waitForRemoteServerToChangeStatus(clusterFormation.router.getApp(), clusterFormation.active.getHost(), HighAvailabilityTestUtil::remoteServerIsUp, USER_CREDS);
waitForRemoteServerToChangeStatus(clusterFormation.router.getApp(), clusterFormation.standBy.getHost(), HighAvailabilityTestUtil::remoteServerIsUp, USER_CREDS);
waitForRemoteServerToChangeStatus(clusterFormation.router.getApp(), clusterFormation.router.getHost(), HighAvailabilityTestUtil.lagsReported(clusterFormation.standBy.getHost(), Optional.of(5L), 5), USER_CREDS);
// Cut off standby from Kafka to simulate lag
clusterFormation.standBy.getShutoffs().setKafkaPauseOffset(0);
Thread.sleep(2000);
// Produce more data that will now only be available on active since standby is cut off
TEST_HARNESS.produceRows(topic, USER_PROVIDER, FormatFactory.KAFKA, FormatFactory.JSON, timestampSupplier::getAndIncrement);
// Make sure that the lags get reported before we kill active
waitForRemoteServerToChangeStatus(clusterFormation.router.getApp(), clusterFormation.router.getHost(), HighAvailabilityTestUtil.lagsReported(clusterFormation.active.getHost(), Optional.of(10L), 10), USER_CREDS);
// Partition active off
clusterFormation.active.getShutoffs().shutOffAll();
waitForRemoteServerToChangeStatus(clusterFormation.router.getApp(), clusterFormation.standBy.getHost(), HighAvailabilityTestUtil::remoteServerIsUp, USER_CREDS);
waitForRemoteServerToChangeStatus(clusterFormation.router.getApp(), clusterFormation.active.getHost(), HighAvailabilityTestUtil::remoteServerIsDown, USER_CREDS);
// When:
final List<StreamedRow> rows_0 = makePullQueryRequest(clusterFormation.router.getApp(), sql, LAG_FILTER_6, USER_CREDS);
// Then:
assertThat(rows_0, hasSize(HEADER + 1));
KsqlHostInfoEntity host = rows_0.get(1).getSourceHost().get();
assertThat(host.getHost(), is(clusterFormation.standBy.getHost().getHost()));
assertThat(host.getPort(), is(clusterFormation.standBy.getHost().getPort()));
assertThat(rows_0.get(1).getRow(), is(not(Optional.empty())));
// This line ensures that we've not processed the new data
assertThat(rows_0.get(1).getRow().get().getColumns(), is(ImmutableList.of(KEY, 1)));
KsqlErrorMessage errorMessage = makePullQueryRequestWithError(clusterFormation.router.getApp(), sql, LAG_FILTER_3);
Assert.assertEquals(40001, errorMessage.getErrorCode());
assertThat(errorMessage.getMessage(), containsString("Partition 0 failed to find valid host."));
assertThat(errorMessage.getMessage(), containsString("was not selected because Host is not alive as of "));
assertThat(errorMessage.getMessage(), containsString("was not selected because Host excluded because lag 5 exceeds maximum allowed lag 3"));
}
Aggregations