use of io.confluent.ksql.rest.entity.StateStoreLags in project ksql by confluentinc.
the class LagReportingAgentFunctionalTest method shouldExchangeLags.
@Test(timeout = 60000)
public void shouldExchangeLags() {
// Given:
waitForClusterCondition(LagReportingAgentFunctionalTest::allServersDiscovered);
// When:
ClusterStatusResponse resp = waitForClusterCondition(LagReportingAgentFunctionalTest::allLagsReported);
StateStoreLags stateStoreLags = resp.getClusterStatus().entrySet().iterator().next().getValue().getHostStoreLags().getStateStoreLags(STORE_0).get();
// Then:
// Read the raw Kafka data from the topic to verify the reported lags
final List<ConsumerRecord<byte[], byte[]>> records = TEST_HARNESS.verifyAvailableRecords("_confluent-ksql-default_query_CTAS_USER_VIEWS_3-" + "Aggregate-Aggregate-Materialize-changelog", NUM_ROWS);
Map<Integer, Optional<ConsumerRecord<byte[], byte[]>>> partitionToMaxOffset = records.stream().collect(Collectors.groupingBy(ConsumerRecord::partition, Collectors.maxBy(Comparator.comparingLong(ConsumerRecord::offset))));
Assert.assertEquals(2, partitionToMaxOffset.size());
Optional<LagInfoEntity> lagInfoEntity0 = stateStoreLags.getLagByPartition(0);
Optional<LagInfoEntity> lagInfoEntity1 = stateStoreLags.getLagByPartition(1);
long partition0Offset = lagInfoEntity0.get().getCurrentOffsetPosition();
long partition1Offset = lagInfoEntity1.get().getCurrentOffsetPosition();
Assert.assertEquals(partition0Offset, partitionToMaxOffset.get(0).get().offset() + 1);
Assert.assertEquals(partition1Offset, partitionToMaxOffset.get(1).get().offset() + 1);
}
use of io.confluent.ksql.rest.entity.StateStoreLags in project ksql by confluentinc.
the class LagReportingAgentFunctionalTest method arePartitionsCurrent.
private static boolean arePartitionsCurrent(HostStoreLags stores) {
if (stores.getStateStoreLags().size() < 2) {
return false;
}
StateStoreLags stateStoreLags0 = stores.getStateStoreLags(STORE_0).get();
StateStoreLags stateStoreLags1 = stores.getStateStoreLags(STORE_1).get();
return stateStoreLags0.getSize() == 2 && stateStoreLags1.getSize() == 2 && isCurrent(stateStoreLags0, 0) && isCurrent(stateStoreLags0, 1) && isCurrent(stateStoreLags1, 0) && isCurrent(stateStoreLags1, 1) && (numMessages(stateStoreLags0, 0) + numMessages(stateStoreLags0, 1) == NUM_ROWS) && (numMessages(stateStoreLags1, 0) + numMessages(stateStoreLags1, 1) == NUM_ROWS);
}
Aggregations