|
8 | 8 | import org.apache.kafka.clients.admin.AdminClient;
|
9 | 9 | import org.apache.kafka.clients.admin.AdminClientConfig;
|
10 | 10 | import org.apache.kafka.clients.admin.NewTopic;
|
11 |
| -import org.apache.kafka.clients.consumer.ConsumerConfig; |
12 |
| -import org.apache.kafka.clients.consumer.ConsumerRecord; |
13 |
| -import org.apache.kafka.clients.consumer.ConsumerRecords; |
14 |
| -import org.apache.kafka.clients.consumer.KafkaConsumer; |
15 |
| -import org.apache.kafka.clients.producer.KafkaProducer; |
16 |
| -import org.apache.kafka.clients.producer.ProducerConfig; |
17 |
| -import org.apache.kafka.clients.producer.ProducerRecord; |
18 | 11 | import org.apache.kafka.common.config.SaslConfigs;
|
19 | 12 | import org.apache.kafka.common.errors.SaslAuthenticationException;
|
20 | 13 | import org.apache.kafka.common.errors.TopicAuthorizationException;
|
21 |
| -import org.apache.kafka.common.serialization.StringDeserializer; |
22 |
| -import org.apache.kafka.common.serialization.StringSerializer; |
23 | 14 | import org.awaitility.Awaitility;
|
24 | 15 | import org.junit.Test;
|
25 |
| -import org.rnorth.ducttape.unreliables.Unreliables; |
26 | 16 | import org.testcontainers.containers.GenericContainer;
|
27 | 17 | import org.testcontainers.containers.Network;
|
28 | 18 | import org.testcontainers.images.builder.Transferable;
|
29 | 19 | import org.testcontainers.utility.DockerImageName;
|
30 | 20 |
|
31 |
| -import java.time.Duration; |
32 | 21 | import java.util.Collection;
|
33 | 22 | import java.util.Collections;
|
34 | 23 | import java.util.HashMap;
|
|
39 | 28 |
|
40 | 29 | import static org.assertj.core.api.Assertions.assertThat;
|
41 | 30 | import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
42 |
| -import static org.assertj.core.api.Assertions.tuple; |
43 | 31 |
|
44 |
| -public class RedpandaContainerTest { |
| 32 | +public class RedpandaContainerTest extends AbstractRedpanda { |
45 | 33 |
|
46 | 34 | private static final String REDPANDA_IMAGE = "docker.redpanda.com/redpandadata/redpanda:v22.2.1";
|
47 | 35 |
|
@@ -78,6 +66,20 @@ public void testNotCompatibleVersion() {
|
78 | 66 | .hasMessageContaining("Redpanda version must be >= v22.2.1");
|
79 | 67 | }
|
80 | 68 |
|
| 69 | + @Test |
| 70 | + public void vectorizedRedpandaImageVersion2221ShouldNotBeCompatible() { |
| 71 | + assertThatThrownBy(() -> new RedpandaContainer("docker.redpanda.com/vectorized/redpanda:v21.11.19")) |
| 72 | + .isInstanceOf(IllegalArgumentException.class) |
| 73 | + .hasMessageContaining("Redpanda version must be >= v22.2.1"); |
| 74 | + } |
| 75 | + |
| 76 | + @Test |
| 77 | + public void redpandadataRedpandaImageVersion2221ShouldNotBeCompatible() { |
| 78 | + assertThatThrownBy(() -> new RedpandaContainer("redpandadata/redpanda:v21.11.19")) |
| 79 | + .isInstanceOf(IllegalArgumentException.class) |
| 80 | + .hasMessageContaining("Redpanda version must be >= v22.2.1"); |
| 81 | + } |
| 82 | + |
81 | 83 | @Test
|
82 | 84 | public void testSchemaRegistry() {
|
83 | 85 | try (RedpandaContainer container = new RedpandaContainer(REDPANDA_DOCKER_IMAGE)) {
|
@@ -359,70 +361,6 @@ public void testRestProxy() {
|
359 | 361 | }
|
360 | 362 | }
|
361 | 363 |
|
362 |
| - private void testKafkaFunctionality(String bootstrapServers) throws Exception { |
363 |
| - testKafkaFunctionality(bootstrapServers, 1, 1); |
364 |
| - } |
365 |
| - |
366 |
| - private void testKafkaFunctionality(String bootstrapServers, int partitions, int rf) throws Exception { |
367 |
| - try ( |
368 |
| - AdminClient adminClient = AdminClient.create( |
369 |
| - ImmutableMap.of(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers) |
370 |
| - ); |
371 |
| - KafkaProducer<String, String> producer = new KafkaProducer<>( |
372 |
| - ImmutableMap.of( |
373 |
| - ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, |
374 |
| - bootstrapServers, |
375 |
| - ProducerConfig.CLIENT_ID_CONFIG, |
376 |
| - UUID.randomUUID().toString() |
377 |
| - ), |
378 |
| - new StringSerializer(), |
379 |
| - new StringSerializer() |
380 |
| - ); |
381 |
| - KafkaConsumer<String, String> consumer = new KafkaConsumer<>( |
382 |
| - ImmutableMap.of( |
383 |
| - ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, |
384 |
| - bootstrapServers, |
385 |
| - ConsumerConfig.GROUP_ID_CONFIG, |
386 |
| - "tc-" + UUID.randomUUID(), |
387 |
| - ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, |
388 |
| - "earliest" |
389 |
| - ), |
390 |
| - new StringDeserializer(), |
391 |
| - new StringDeserializer() |
392 |
| - ); |
393 |
| - ) { |
394 |
| - String topicName = "messages-" + UUID.randomUUID(); |
395 |
| - |
396 |
| - Collection<NewTopic> topics = Collections.singletonList(new NewTopic(topicName, partitions, (short) rf)); |
397 |
| - adminClient.createTopics(topics).all().get(30, TimeUnit.SECONDS); |
398 |
| - |
399 |
| - consumer.subscribe(Collections.singletonList(topicName)); |
400 |
| - |
401 |
| - producer.send(new ProducerRecord<>(topicName, "testcontainers", "rulezzz")).get(); |
402 |
| - |
403 |
| - Unreliables.retryUntilTrue( |
404 |
| - 10, |
405 |
| - TimeUnit.SECONDS, |
406 |
| - () -> { |
407 |
| - ConsumerRecords<String, String> records = consumer.poll(Duration.ofMillis(100)); |
408 |
| - |
409 |
| - if (records.isEmpty()) { |
410 |
| - return false; |
411 |
| - } |
412 |
| - |
413 |
| - assertThat(records) |
414 |
| - .hasSize(1) |
415 |
| - .extracting(ConsumerRecord::topic, ConsumerRecord::key, ConsumerRecord::value) |
416 |
| - .containsExactly(tuple(topicName, "testcontainers", "rulezzz")); |
417 |
| - |
418 |
| - return true; |
419 |
| - } |
420 |
| - ); |
421 |
| - |
422 |
| - consumer.unsubscribe(); |
423 |
| - } |
424 |
| - } |
425 |
| - |
426 | 364 | private AdminClient getAdminClient(RedpandaContainer redpanda) {
|
427 | 365 | String bootstrapServer = String.format("%s:%s", redpanda.getHost(), redpanda.getMappedPort(9092));
|
428 | 366 | // createAdminClient {
|
|
0 commit comments