use of org.apache.kafka.test.InternalMockProcessorContext in project kafka by apache.
the class ListValueStoreTest method setup.
@Before
public void setup() {
listStore = buildStore(Serdes.Integer(), Serdes.String());
final MockRecordCollector recordCollector = new MockRecordCollector();
final InternalMockProcessorContext<Integer, String> context = new InternalMockProcessorContext<>(baseDir, Serdes.String(), Serdes.Integer(), recordCollector, new ThreadCache(new LogContext("testCache"), 0, new MockStreamsMetrics(new Metrics())));
context.setTime(1L);
listStore.init((StateStoreContext) context, listStore);
}
use of org.apache.kafka.test.InternalMockProcessorContext in project kafka by apache.
the class RocksDBStoreTest method shouldThrowProcessorStateExceptionOnOpeningReadOnlyDir.
@Test
public void shouldThrowProcessorStateExceptionOnOpeningReadOnlyDir() {
final File tmpDir = TestUtils.tempDirectory();
final InternalMockProcessorContext tmpContext = new InternalMockProcessorContext(tmpDir, new StreamsConfig(StreamsTestUtils.getStreamsConfig()));
assertTrue(tmpDir.setReadOnly());
assertThrows(ProcessorStateException.class, () -> rocksDBStore.openDB(tmpContext.appConfigs(), tmpContext.stateDir()));
}
use of org.apache.kafka.test.InternalMockProcessorContext in project kafka by apache.
the class RocksDBStoreTest method shouldCallRocksDbConfigSetter.
@Test
public void shouldCallRocksDbConfigSetter() {
MockRocksDbConfigSetter.called = false;
final Properties props = StreamsTestUtils.getStreamsConfig();
props.put(StreamsConfig.ROCKSDB_CONFIG_SETTER_CLASS_CONFIG, MockRocksDbConfigSetter.class);
final Object param = new Object();
props.put("abc.def", param);
final InternalMockProcessorContext context = new InternalMockProcessorContext(dir, Serdes.String(), Serdes.String(), new StreamsConfig(props));
rocksDBStore.init((StateStoreContext) context, rocksDBStore);
assertTrue(MockRocksDbConfigSetter.called);
assertThat(MockRocksDbConfigSetter.configMap.get("abc.def"), equalTo(param));
}
use of org.apache.kafka.test.InternalMockProcessorContext in project kafka by apache.
the class RocksDBStoreTest method shouldHandleToggleOfEnablingBloomFilters.
@Test
public void shouldHandleToggleOfEnablingBloomFilters() {
final Properties props = StreamsTestUtils.getStreamsConfig();
props.put(StreamsConfig.ROCKSDB_CONFIG_SETTER_CLASS_CONFIG, TestingBloomFilterRocksDBConfigSetter.class);
dir = TestUtils.tempDirectory();
context = new InternalMockProcessorContext(dir, Serdes.String(), Serdes.String(), new StreamsConfig(props));
enableBloomFilters = false;
rocksDBStore.init((StateStoreContext) context, rocksDBStore);
final List<String> expectedValues = new ArrayList<>();
expectedValues.add("a");
expectedValues.add("b");
expectedValues.add("c");
final List<KeyValue<byte[], byte[]>> keyValues = getKeyValueEntries();
for (final KeyValue<byte[], byte[]> keyValue : keyValues) {
rocksDBStore.put(new Bytes(keyValue.key), keyValue.value);
}
int expectedIndex = 0;
for (final KeyValue<byte[], byte[]> keyValue : keyValues) {
final byte[] valBytes = rocksDBStore.get(new Bytes(keyValue.key));
assertThat(new String(valBytes, UTF_8), is(expectedValues.get(expectedIndex++)));
}
assertFalse(TestingBloomFilterRocksDBConfigSetter.bloomFiltersSet);
rocksDBStore.close();
expectedIndex = 0;
// reopen with Bloom Filters enabled
// should open fine without errors
enableBloomFilters = true;
rocksDBStore.init((StateStoreContext) context, rocksDBStore);
for (final KeyValue<byte[], byte[]> keyValue : keyValues) {
final byte[] valBytes = rocksDBStore.get(new Bytes(keyValue.key));
assertThat(new String(valBytes, UTF_8), is(expectedValues.get(expectedIndex++)));
}
assertTrue(TestingBloomFilterRocksDBConfigSetter.bloomFiltersSet);
}
Aggregations