|
21 | 21 | import java.util.ArrayList; |
22 | 22 | import java.util.Collections; |
23 | 23 | import java.util.List; |
24 | | -import java.util.Map; |
25 | 24 | import java.util.Properties; |
26 | 25 | import java.util.concurrent.TimeUnit; |
27 | | -import org.apache.flink.configuration.Configuration; |
28 | 26 | import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; |
29 | 27 | import org.apache.flink.table.api.ResultKind; |
30 | 28 | import org.apache.flink.table.api.bridge.java.StreamTableEnvironment; |
|
36 | 34 | import org.junit.jupiter.api.AfterAll; |
37 | 35 | import org.junit.jupiter.api.BeforeAll; |
38 | 36 | import org.junit.jupiter.api.Test; |
39 | | -import org.testcontainers.containers.KafkaContainer; |
40 | | -import org.testcontainers.utility.DockerImageName; |
| 37 | +import org.testcontainers.kafka.KafkaContainer; |
41 | 38 |
|
42 | | -// @ExtendWith(MiniClusterExtension.class) |
43 | 39 | class FlinkKafkaIntegrationIT { |
44 | 40 |
|
45 | 41 | private static KafkaContainer kafkaContainer; |
46 | 42 |
|
47 | | - @SuppressWarnings("resource") |
48 | 43 | @BeforeAll |
49 | 44 | static void setup() { |
50 | 45 | kafkaContainer = |
51 | | - new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:7.9.2")) |
| 46 | + new KafkaContainer("apache/kafka-native:4.3.1") |
52 | 47 | .withEnv( |
53 | 48 | "KAFKA_MESSAGE_MAX_BYTES", |
54 | 49 | "50000000") // Increase broker's max message size to 50 MB |
@@ -83,12 +78,15 @@ void flinkKafkaLargeMessage() throws Exception { |
83 | 78 | consumerProps.put(ConsumerConfig.FETCH_MAX_BYTES_CONFIG, "50000000"); |
84 | 79 | consumerProps.put(ConsumerConfig.MAX_PARTITION_FETCH_BYTES_CONFIG, "50000000"); |
85 | 80 |
|
86 | | - AdminClient.create(consumerProps) |
87 | | - .createTopics(List.of(new NewTopic("test-topic", 1, (short) 1))); |
| 81 | + try (var adminClient = AdminClient.create(consumerProps)) { |
| 82 | + adminClient |
| 83 | + .createTopics(List.of(new NewTopic("test-topic", 1, (short) 1))) |
| 84 | + .all() |
| 85 | + .get(10, TimeUnit.SECONDS); |
| 86 | + } |
88 | 87 |
|
89 | 88 | // Set up Flink execution environments |
90 | | - var env = |
91 | | - StreamExecutionEnvironment.createLocalEnvironmentWithWebUI(Configuration.fromMap(Map.of())); |
| 89 | + var env = StreamExecutionEnvironment.createLocalEnvironment(); |
92 | 90 | var tableEnv = StreamTableEnvironment.create(env); |
93 | 91 |
|
94 | 92 | // Define the DataGen source table with a large message field |
@@ -172,7 +170,5 @@ var record = recordsList.get(0); |
172 | 170 | // For this example, we'll check the lengths |
173 | 171 | // Since the 'large_message' field is 1 MB, the value should be at least 1 MB in size |
174 | 172 | assertThat(value).hasSizeGreaterThanOrEqualTo(1048576); |
175 | | - |
176 | | - System.out.println("Message successfully written and read from Kafka."); |
177 | 173 | } |
178 | 174 | } |
0 commit comments