use of org.apache.flink.connector.pulsar.testutils.function.ControlSource in project flink by apache.
the class PulsarSinkITCase method writeRecordsToPulsar.
@ParameterizedTest
@EnumSource(DeliveryGuarantee.class)
void writeRecordsToPulsar(DeliveryGuarantee guarantee) throws Exception {
// A random topic with partition 1.
String topic = randomAlphabetic(8);
operator().createTopic(topic, 4);
int counts = ThreadLocalRandom.current().nextInt(100, 200);
ControlSource source = new ControlSource(sharedObjects, operator(), topic, guarantee, counts, Duration.ofMinutes(5));
PulsarSink<String> sink = PulsarSink.builder().setServiceUrl(operator().serviceUrl()).setAdminUrl(operator().adminUrl()).setDeliveryGuarantee(guarantee).setTopics(topic).setSerializationSchema(flinkSchema(new SimpleStringSchema())).build();
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(PARALLELISM);
env.enableCheckpointing(100L);
env.addSource(source).sinkTo(sink);
env.execute();
List<String> expectedRecords = source.getExpectedRecords();
List<String> consumedRecords = source.getConsumedRecords();
assertThat(consumedRecords).hasSameSizeAs(expectedRecords).containsExactlyInAnyOrderElementsOf(expectedRecords);
}
Aggregations