Search in sources :

Example 1 with TOPIC

use of io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.TOPIC in project ksql by confluentinc.

the class CatchupConsumerTest method shouldRunConsumer_success_waitForLatestAssignment.

@Test
public void shouldRunConsumer_success_waitForLatestAssignment() {
    // Given:
    PushOffsetRange offsetRange = new PushOffsetRange(Optional.empty(), new PushOffsetVector(ImmutableList.of(1L, 2L)));
    when(latestConsumer.getAssignment()).thenReturn(null);
    AtomicReference<CatchupConsumer> cRef = new AtomicReference<>();
    // Rather than wait, simulate the latest getting an assignment
    final BiConsumer<Object, Long> waitFn = (o, wait) -> cRef.get().newAssignment(ImmutableSet.of(TP0, TP1));
    try (CatchupConsumer consumer = new CatchupConsumer(TOPIC, false, SCHEMA, kafkaConsumer, () -> latestConsumer, catchupCoordinator, offsetRange, clock, sleepFn, waitFn, 0, pq -> caughtUp = true)) {
        cRef.set(consumer);
        runSuccessfulTest(consumer);
    }
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Mock(org.mockito.Mock) Assert.assertThrows(org.junit.Assert.assertThrows) RunWith(org.junit.runner.RunWith) RECORD0_1(io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.RECORD0_1) QR0_2(io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.QR0_2) ConsumerRecords(org.apache.kafka.clients.consumer.ConsumerRecords) QR1_2(io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.QR1_2) AtomicReference(java.util.concurrent.atomic.AtomicReference) QR1_3(io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.QR1_3) CommonTestUtil.verifyQueryRows(io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.verifyQueryRows) QR0_1(io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.QR0_1) PushOffsetRange(io.confluent.ksql.util.PushOffsetRange) ImmutableList(com.google.common.collect.ImmutableList) BiConsumer(java.util.function.BiConsumer) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) QueryId(io.confluent.ksql.query.QueryId) CommonTestUtil.expectPoll(io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.expectPoll) Before(org.junit.Before) ImmutableSet(com.google.common.collect.ImmutableSet) ProcessingQueue(io.confluent.ksql.physical.scalablepush.ProcessingQueue) ImmutableMap(com.google.common.collect.ImmutableMap) CommonTestUtil.offsetsRow(io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.offsetsRow) TP1(io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.TP1) EMPTY_RECORDS(io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.EMPTY_RECORDS) TP0(io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.TP0) Mockito.times(org.mockito.Mockito.times) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) PartitionInfo(org.apache.kafka.common.PartitionInfo) Mockito.verify(org.mockito.Mockito.verify) Consumer(java.util.function.Consumer) WAIT_FOR_ASSIGNMENT_MS(io.confluent.ksql.physical.scalablepush.consumer.CatchupConsumer.WAIT_FOR_ASSIGNMENT_MS) RECORD0_2(io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.RECORD0_2) RECORD1_2(io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.RECORD1_2) RECORD1_3(io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.RECORD1_3) GenericRow(io.confluent.ksql.GenericRow) TOPIC(io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.TOPIC) KsqlException(io.confluent.ksql.util.KsqlException) Clock(java.time.Clock) Optional(java.util.Optional) Matchers.is(org.hamcrest.Matchers.is) SCHEMA(io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.SCHEMA) Matchers.containsString(org.hamcrest.Matchers.containsString) PushOffsetVector(io.confluent.ksql.util.PushOffsetVector) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Mockito.mock(org.mockito.Mockito.mock) KafkaConsumer(org.apache.kafka.clients.consumer.KafkaConsumer) PushOffsetVector(io.confluent.ksql.util.PushOffsetVector) AtomicReference(java.util.concurrent.atomic.AtomicReference) PushOffsetRange(io.confluent.ksql.util.PushOffsetRange) Test(org.junit.Test)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 GenericRow (io.confluent.ksql.GenericRow)1 ProcessingQueue (io.confluent.ksql.physical.scalablepush.ProcessingQueue)1 WAIT_FOR_ASSIGNMENT_MS (io.confluent.ksql.physical.scalablepush.consumer.CatchupConsumer.WAIT_FOR_ASSIGNMENT_MS)1 EMPTY_RECORDS (io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.EMPTY_RECORDS)1 QR0_1 (io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.QR0_1)1 QR0_2 (io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.QR0_2)1 QR1_2 (io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.QR1_2)1 QR1_3 (io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.QR1_3)1 RECORD0_1 (io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.RECORD0_1)1 RECORD0_2 (io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.RECORD0_2)1 RECORD1_2 (io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.RECORD1_2)1 RECORD1_3 (io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.RECORD1_3)1 SCHEMA (io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.SCHEMA)1 TOPIC (io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.TOPIC)1 TP0 (io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.TP0)1 TP1 (io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.TP1)1 CommonTestUtil.expectPoll (io.confluent.ksql.physical.scalablepush.consumer.CommonTestUtil.expectPoll)1