use of com.bakdata.quick.common.config.KafkaConfig in project quick by bakdata.
the class TopicRegistryInitializerTest method shouldCreateSchema.
@Test
void shouldCreateSchema() throws IOException, RestClientException {
final String topicName = UUID.randomUUID().toString();
this.successfulMock();
final KafkaConfig kafkaConfig = new KafkaConfig(kafkaCluster.getBrokerList(), this.schemaRegistry.getUrl());
final TopicRegistryConfig registryConfig = new TopicRegistryConfig(topicName, TEST_NAME, 3, (short) 1);
final TopicRegistryInitializer topicRegistryInitializer = new TopicRegistryInitializer(kafkaConfig, registryConfig, this.mock);
topicRegistryInitializer.onStartUp(new StartupEvent(this.applicationContext));
final SchemaRegistryClient registryClient = this.schemaRegistry.getSchemaRegistryClient();
final String subject = topicName + "-value";
assertThat(registryClient.getAllSubjects()).containsExactly(subject);
assertThat(registryClient.getBySubjectAndId(subject, 1)).isEqualTo(AvroTopicData.getClassSchema());
}
use of com.bakdata.quick.common.config.KafkaConfig in project quick by bakdata.
the class TopicRegistryInitializerTest method shouldNotFailIfSchemaExists.
@Test
void shouldNotFailIfSchemaExists() {
final String topicName = UUID.randomUUID().toString();
this.successfulMock();
final KafkaConfig kafkaConfig = new KafkaConfig(kafkaCluster.getBrokerList(), this.schemaRegistry.getUrl());
final TopicRegistryConfig registryConfig = new TopicRegistryConfig(topicName, TEST_NAME, 3, (short) 1);
final TopicRegistryInitializer topicRegistryInitializer = new TopicRegistryInitializer(kafkaConfig, registryConfig, this.mock);
assertThatCode(() -> {
topicRegistryInitializer.onStartUp(new StartupEvent(this.applicationContext));
}).doesNotThrowAnyException();
}
use of com.bakdata.quick.common.config.KafkaConfig in project quick by bakdata.
the class MirrorApplication method addKafkaConfigToArgs.
/**
* Adds Kafka specific configurations to CLI args
*
* <p>
* {@link KafkaStreamsApplication} handles reading common settings like bootstrap server and schema registry url for
* us. With this, we enable it to properly populate these.
*
* @param context current context
* @param args existing CLI args
*/
private static String[] addKafkaConfigToArgs(final ApplicationContext context, final String[] args) {
final KafkaConfig kafkaConfig = context.getBean(KafkaConfig.class);
final List<String> allArgs = CliArgHandler.convertArgs(kafkaConfig);
allArgs.addAll(Arrays.asList(args));
return allArgs.toArray(String[]::new);
}
use of com.bakdata.quick.common.config.KafkaConfig in project quick by bakdata.
the class SubscriptionFetcherTest method shouldFetchValuesForGivenKey.
@ParameterizedTest(name = "shouldFetchValuesForGivenKey ({0})")
@MethodSource("provideValueArgumentsForKey")
<K, V> void shouldFetchValuesForGivenKey(final String topic, final List<KeyValue<K, V>> keyValues, final QuickData<K> keyInfo, final QuickData<V> valueInfo, final K key, final List<V> expected) throws InterruptedException {
final QuickTopicData<K, V> info = new QuickTopicData<>(topic, TopicWriteType.IMMUTABLE, keyInfo, valueInfo);
final KafkaConfig kafkaConfig = new KafkaConfig(kafkaCluster.getBrokerList(), "http://no");
kafkaCluster.createTopic(TopicConfig.withName(topic).useDefaults());
final SendKeyValuesTransactional<K, V> sendRequest = SendKeyValuesTransactional.inTransaction(topic, keyValues).with(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, keyInfo.getSerde().serializer().getClass()).with(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, valueInfo.getSerde().serializer().getClass()).build();
kafkaCluster.send(sendRequest);
final String argumentName = "id";
final SubscriptionFetcher<K, V> subscriptionFetcher = new SubscriptionFetcher<>(kafkaConfig, new Lazy<>(() -> info), "key-query", OffsetStrategy.EARLIEST, argumentName);
final DataFetchingEnvironment fetchingEnvironment = DataFetchingEnvironmentImpl.newDataFetchingEnvironment().arguments(Map.of(argumentName, key)).build();
final Publisher<V> publisher = subscriptionFetcher.get(fetchingEnvironment);
final TestSubscriber<V> testSubscriber = TestSubscriber.create();
publisher.subscribe(testSubscriber);
await().atMost(Duration.ofSeconds(10)).untilAsserted(() -> assertThat(testSubscriber.values()).containsExactlyElementsOf(expected));
}
use of com.bakdata.quick.common.config.KafkaConfig in project quick by bakdata.
the class KafkaIngestServiceTest method setUp.
@BeforeEach
void setUp() {
this.schemaRegistry.start();
this.kafkaCluster = provisionWith(EmbeddedKafkaClusterConfig.defaultClusterConfig());
this.kafkaCluster.start();
this.kafkaCluster.createTopic(TopicConfig.withName(TOPIC).useDefaults());
final KafkaConfig kafkaConfig = new KafkaConfig(this.kafkaCluster.getBrokerList(), this.schemaRegistry.getUrl());
this.service = new KafkaIngestService(this.typeService, kafkaConfig);
}
Aggregations