Search in sources :

Example 1 with IsolationLevel

use of org.apache.kafka.common.requests.IsolationLevel in project apache-kafka-on-k8s by banzaicloud.

the class FetcherTest method testListOffsetsSendsIsolationLevel.

@Test
public void testListOffsetsSendsIsolationLevel() {
    for (final IsolationLevel isolationLevel : IsolationLevel.values()) {
        Fetcher<byte[], byte[]> fetcher = createFetcher(subscriptions, new Metrics(), new ByteArrayDeserializer(), new ByteArrayDeserializer(), Integer.MAX_VALUE, isolationLevel);
        subscriptions.assignFromUser(singleton(tp0));
        subscriptions.requestOffsetReset(tp0, OffsetResetStrategy.LATEST);
        client.prepareResponse(new MockClient.RequestMatcher() {

            @Override
            public boolean matches(AbstractRequest body) {
                ListOffsetRequest request = (ListOffsetRequest) body;
                return request.isolationLevel() == isolationLevel;
            }
        }, listOffsetResponse(Errors.NONE, 1L, 5L));
        fetcher.resetOffsetsIfNeeded();
        consumerClient.pollNoWakeup();
        assertFalse(subscriptions.isOffsetResetNeeded(tp0));
        assertTrue(subscriptions.isFetchable(tp0));
        assertEquals(5, subscriptions.position(tp0).longValue());
    }
}
Also used : Metrics(org.apache.kafka.common.metrics.Metrics) IsolationLevel(org.apache.kafka.common.requests.IsolationLevel) AbstractRequest(org.apache.kafka.common.requests.AbstractRequest) ListOffsetRequest(org.apache.kafka.common.requests.ListOffsetRequest) ByteArrayDeserializer(org.apache.kafka.common.serialization.ByteArrayDeserializer) MockClient(org.apache.kafka.clients.MockClient) Test(org.junit.Test)

Aggregations

MockClient (org.apache.kafka.clients.MockClient)1 Metrics (org.apache.kafka.common.metrics.Metrics)1 AbstractRequest (org.apache.kafka.common.requests.AbstractRequest)1 IsolationLevel (org.apache.kafka.common.requests.IsolationLevel)1 ListOffsetRequest (org.apache.kafka.common.requests.ListOffsetRequest)1 ByteArrayDeserializer (org.apache.kafka.common.serialization.ByteArrayDeserializer)1 Test (org.junit.Test)1