use of org.apache.kafka.common.utils.MockTime in project apache-kafka-on-k8s by banzaicloud.
the class MeteredKeyValueBytesStoreTest method before.
@Before
public void before() {
metered = new MeteredKeyValueBytesStore<>(inner, "scope", new MockTime(), Serdes.String(), Serdes.String());
tags.put("task-id", taskId.toString());
tags.put("scope-id", "metered");
metrics.config().recordLevel(Sensor.RecordingLevel.DEBUG);
EasyMock.expect(context.metrics()).andReturn(new MockStreamsMetrics(metrics));
EasyMock.expect(context.taskId()).andReturn(taskId);
EasyMock.expect(inner.name()).andReturn("metered").anyTimes();
}
use of org.apache.kafka.common.utils.MockTime in project apache-kafka-on-k8s by banzaicloud.
the class MeteredSessionStoreTest method before.
@Before
public void before() {
metered = new MeteredSessionStore<>(inner, "scope", Serdes.String(), Serdes.String(), new MockTime());
tags.put("task-id", taskId.toString());
tags.put("scope-id", "metered");
metrics.config().recordLevel(Sensor.RecordingLevel.DEBUG);
EasyMock.expect(context.metrics()).andReturn(new MockStreamsMetrics(metrics));
EasyMock.expect(context.taskId()).andReturn(taskId);
EasyMock.expect(inner.name()).andReturn("metered").anyTimes();
}
use of org.apache.kafka.common.utils.MockTime in project apache-kafka-on-k8s by banzaicloud.
the class FileRecordsTest method setup.
@Before
public void setup() throws IOException {
this.fileRecords = createFileRecords(values);
this.time = new MockTime();
}
use of org.apache.kafka.common.utils.MockTime in project apache-kafka-on-k8s by banzaicloud.
the class SslTransportLayerTest method testIOExceptionsDuringHandshake.
private void testIOExceptionsDuringHandshake(boolean failRead, boolean failWrite) throws Exception {
server = createEchoServer(SecurityProtocol.SSL);
TestSslChannelBuilder channelBuilder = new TestSslChannelBuilder(Mode.CLIENT);
boolean done = false;
for (int i = 1; i <= 100; i++) {
int readFailureIndex = failRead ? i : Integer.MAX_VALUE;
int flushFailureIndex = failWrite ? i : Integer.MAX_VALUE;
String node = String.valueOf(i);
channelBuilder.readFailureIndex = readFailureIndex;
channelBuilder.flushFailureIndex = flushFailureIndex;
channelBuilder.configure(sslClientConfigs);
this.selector = new Selector(5000, new Metrics(), new MockTime(), "MetricGroup", channelBuilder, new LogContext());
InetSocketAddress addr = new InetSocketAddress("localhost", server.port());
selector.connect(node, addr, BUFFER_SIZE, BUFFER_SIZE);
for (int j = 0; j < 30; j++) {
selector.poll(1000L);
KafkaChannel channel = selector.channel(node);
if (channel != null && channel.ready()) {
done = true;
break;
}
if (selector.disconnected().containsKey(node)) {
assertEquals(ChannelState.State.AUTHENTICATE, selector.disconnected().get(node).state());
break;
}
}
KafkaChannel channel = selector.channel(node);
if (channel != null)
assertTrue("Channel not ready or disconnected:" + channel.state().state(), channel.ready());
}
assertTrue("Too many invocations of read/write during SslTransportLayer.handshake()", done);
}
use of org.apache.kafka.common.utils.MockTime in project apache-kafka-on-k8s by banzaicloud.
the class SelectorTest method setUp.
@Before
public void setUp() throws Exception {
Map<String, Object> configs = new HashMap<>();
this.server = new EchoServer(SecurityProtocol.PLAINTEXT, configs);
this.server.start();
this.time = new MockTime();
this.channelBuilder = new PlaintextChannelBuilder();
this.channelBuilder.configure(configs);
this.metrics = new Metrics();
this.selector = new Selector(5000, this.metrics, time, "MetricGroup", channelBuilder, new LogContext());
}
Aggregations