Skip to content

Commit c058a95

Browse files
committed
Add changes to the build and integration files for manual testing. Be sure to remove these later as they cannot stay.
1 parent d642870 commit c058a95

2 files changed

Lines changed: 92 additions & 0 deletions

File tree

sdks/java/io/kafka/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ dependencies {
108108
testRuntimeOnly library.java.slf4j_jdk14
109109
testRuntimeOnly project(path: ":runners:direct-java", configuration: "shadow")
110110
kafkaVersions.each {"kafkaVersion$it.key" "org.apache.kafka:kafka-clients:$it.value"}
111+
implementation 'com.google.cloud:google-cloud-secretmanager:2.72.0'
112+
testImplementation project(path: ":runners:google-cloud-dataflow-java")
113+
testImplementation project(path: ":sdks:java:extensions:google-cloud-platform-core")
114+
testImplementation project(path: ":sdks:java:io:google-cloud-platform")
111115
}
112116

113117
kafkaVersions.each { kv ->

sdks/java/io/kafka/src/test/java/org/apache/beam/sdk/io/kafka/KafkaIOIT.java

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@
2626
import com.fasterxml.jackson.databind.ObjectMapper;
2727
import java.io.IOException;
2828
import java.time.Instant;
29+
import java.util.ArrayList;
2930
import java.util.Collection;
3031
import java.util.Collections;
3132
import java.util.HashMap;
3233
import java.util.HashSet;
34+
import java.util.List;
3335
import java.util.Map;
3436
import java.util.Objects;
3537
import java.util.Random;
@@ -38,6 +40,8 @@
3840
import java.util.function.BiFunction;
3941
import java.util.stream.Collectors;
4042
import java.util.stream.LongStream;
43+
import org.apache.beam.runners.dataflow.DataflowRunner;
44+
import org.apache.beam.runners.dataflow.options.DataflowPipelineOptions;
4145
import org.apache.beam.sdk.Pipeline;
4246
import org.apache.beam.sdk.PipelineResult;
4347
import org.apache.beam.sdk.coders.ByteArrayCoder;
@@ -221,6 +225,7 @@ public static void afterClass() {
221225
}
222226
}
223227

228+
@Ignore
224229
@Test
225230
public void testKafkaIOFailsFastWithInvalidPartitions() throws IOException {
226231
thrown.expect(Pipeline.PipelineExecutionException.class);
@@ -245,6 +250,7 @@ public void testKafkaIOFailsFastWithInvalidPartitions() throws IOException {
245250
cancelIfTimeouted(readResult, readState);
246251
}
247252

253+
@Ignore
248254
@Test
249255
public void testKafkaIOFailsFastWithInvalidPartitionsAndFlagExplicitlySet() throws IOException {
250256
thrown.expect(Pipeline.PipelineExecutionException.class);
@@ -271,6 +277,7 @@ public void testKafkaIOFailsFastWithInvalidPartitionsAndFlagExplicitlySet() thro
271277
cancelIfTimeouted(readResult, readState);
272278
}
273279

280+
@Ignore
274281
@Test
275282
public void testKafkaIODoesNotFailFastWithInvalidPartitionsAndFlagExplicitlyNotSet()
276283
throws IOException {
@@ -298,6 +305,7 @@ public void testKafkaIODoesNotFailFastWithInvalidPartitionsAndFlagExplicitlyNotS
298305
cancelIfTimeouted(readResult, readState);
299306
}
300307

308+
@Ignore
301309
@Test
302310
public void testKafkaIOFailsFastWithInvalidTopics() throws IOException {
303311
// This test will fail on versions before 2.3.0 due to the non-existence of the
@@ -332,6 +340,7 @@ public void testKafkaIOFailsFastWithInvalidTopics() throws IOException {
332340
cancelIfTimeouted(readResult, readState);
333341
}
334342

343+
@Ignore
335344
@Test
336345
public void testKafkaIOFailsFastWithInvalidTopicsAndDynamicRead() throws IOException {
337346
// This test will fail on versions before 2.3.0 due to the non-existence of the
@@ -367,6 +376,7 @@ public void testKafkaIOFailsFastWithInvalidTopicsAndDynamicRead() throws IOExcep
367376
cancelIfTimeouted(readResult, readState);
368377
}
369378

379+
@Ignore
370380
@Test
371381
public void testKafkaIOLogsTopicVerificationWithDynamicRead() throws IOException {
372382
// This test will fail on versions before 2.3.0 due to the non-existence of the
@@ -403,6 +413,7 @@ public void testKafkaIOLogsTopicVerificationWithDynamicRead() throws IOException
403413
cancelIfTimeouted(readResult, readState);
404414
}
405415

416+
@Ignore
406417
@Test
407418
public void testKafkaIODoesNotErrorAtValidationWithBadBootstrapServer() throws IOException {
408419
// expect an error during execution that the bootstrap server is bad, not during validation
@@ -428,6 +439,7 @@ public void testKafkaIODoesNotErrorAtValidationWithBadBootstrapServer() throws I
428439
cancelIfTimeouted(readResult, readState);
429440
}
430441

442+
@Ignore
431443
@Test
432444
public void testKafkaIOReadsAndWritesCorrectlyInStreaming() throws IOException {
433445
// Use batch pipeline to write records.
@@ -470,6 +482,7 @@ public void testKafkaIOReadsAndWritesCorrectlyInStreaming() throws IOException {
470482
assertNotEquals(PipelineResult.State.FAILED, readState);
471483
}
472484

485+
@Ignore
473486
@Test
474487
public void testKafkaIOReadsAndWritesCorrectlyInBatch() throws IOException {
475488
writePipeline
@@ -511,6 +524,7 @@ public void testKafkaIOReadsAndWritesCorrectlyInBatch() throws IOException {
511524
// DoFns. CrashOnExtra will throw an exception if we see any extra records beyond those we
512525
// expect, and LogFn acts as a sink we can inspect using ExpectedLogs to verify that we got all
513526
// those we expect.
527+
@Ignore
514528
@Test
515529
public void testKafkaIOSDFResumesCorrectly() throws IOException {
516530
roundtripElements("first-pass", 4, writePipeline, sdfReadPipeline);
@@ -599,6 +613,7 @@ public void processElement(@Element String element, OutputReceiver<String> outpu
599613
}
600614

601615
// This test verifies that bad data from Kafka is properly sent to the error handler
616+
@Ignore
602617
@Test
603618
public void testKafkaIOSDFReadWithErrorHandler() throws IOException {
604619
// TODO(https://github.com/apache/beam/issues/32704) re-enable when fixed, or remove the support
@@ -640,6 +655,7 @@ public void testKafkaIOSDFReadWithErrorHandler() throws IOException {
640655
assertNotEquals(PipelineResult.State.FAILED, readState);
641656
}
642657

658+
@Ignore
643659
@Test
644660
public void testKafkaIOWriteWithErrorHandler() throws IOException {
645661

@@ -666,6 +682,7 @@ public void testKafkaIOWriteWithErrorHandler() throws IOException {
666682

667683
// This test roundtrips a single KV<Null,Null> to verify that externalWithMetadata
668684
// can handle null keys and values correctly.
685+
@Ignore
669686
@Test
670687
public void testKafkaIOExternalRoundtripWithMetadataAndNullKeysAndValues() throws IOException {
671688

@@ -705,6 +722,7 @@ public void testKafkaIOExternalRoundtripWithMetadataAndNullKeysAndValues() throw
705722
cancelIfTimeouted(readResult, readState);
706723
}
707724

725+
@Ignore
708726
@Test
709727
public void testKafkaWithDynamicPartitions() throws IOException {
710728
AdminClient client =
@@ -792,6 +810,7 @@ public void testKafkaWithDynamicPartitions() throws IOException {
792810
}
793811
}
794812

813+
@Ignore
795814
@Test
796815
public void testKafkaWithStopReadingFunction() {
797816
AlwaysStopCheckStopReadingFn checkStopReadingFn = new AlwaysStopCheckStopReadingFn();
@@ -806,6 +825,7 @@ public Boolean apply(TopicPartition input) {
806825
}
807826
}
808827

828+
@Ignore
809829
@Test
810830
public void testKafkaWithDelayedStopReadingFunction() {
811831
DelayedCheckStopReadingFn checkStopReadingFn = new DelayedCheckStopReadingFn();
@@ -853,12 +873,14 @@ public void testKafkaWithDelayedStopReadingFunction() {
853873

854874
private static final int FIVE_MINUTES_IN_MS = 5 * 60 * 1000;
855875

876+
@Ignore
856877
@Test(timeout = FIVE_MINUTES_IN_MS)
857878
public void testKafkaViaManagedSchemaTransformJson() {
858879
runReadWriteKafkaViaManagedSchemaTransforms(
859880
"JSON", SCHEMA_IN_JSON, JsonUtils.beamSchemaFromJsonSchema(SCHEMA_IN_JSON));
860881
}
861882

883+
@Ignore
862884
@Test(timeout = FIVE_MINUTES_IN_MS)
863885
public void testKafkaViaManagedSchemaTransformAvro() {
864886
runReadWriteKafkaViaManagedSchemaTransforms(
@@ -997,6 +1019,7 @@ private void runWithStopReadingFn(
9971019
readResult.waitUntilFinish(Duration.standardSeconds(options.getReadTimeout()));
9981020
}
9991021

1022+
@Ignore
10001023
@Test
10011024
public void testWatermarkUpdateWithSparseMessages() throws IOException, InterruptedException {
10021025
AdminClient client =
@@ -1117,6 +1140,70 @@ public void testReadAndWriteFromKafkaIOWithGCPApplicationDefaultCredentials() th
11171140
}
11181141
}
11191142

1143+
@Test
1144+
public void testReadFromKafkaWithKerberosAuthentication() throws IOException {
1145+
DataflowPipelineOptions pReadOptions =
1146+
PipelineOptionsFactory.create().as(DataflowPipelineOptions.class);
1147+
pReadOptions.setAppName("KafkaIOIT-testReadFromKafkaWithKerberosAuthentication");
1148+
List<String> experiments = new ArrayList<>();
1149+
experiments.add("use_sdf_read");
1150+
experiments.add("beam_fn_api");
1151+
experiments.add("use_staged_dataflow_worker_jar");
1152+
// experiments.add("java_worker_options=-Djava.security.krb5.conf=/tmp/krb5.conf");
1153+
pReadOptions.setExperiments(experiments);
1154+
pReadOptions.setRunner(DataflowRunner.class);
1155+
pReadOptions.setProject("dataflow-testing-311516");
1156+
pReadOptions.setRegion("us-central1");
1157+
pReadOptions.setJobName("testReadFromKafkaWithKerberosAuthentication" + UUID.randomUUID());
1158+
pReadOptions.setNetwork("fozzie-test-vpc");
1159+
pReadOptions.setSubnetwork("regions/us-central1/subnetworks/fozzie-test-vpc-subnet");
1160+
1161+
Pipeline pRead = Pipeline.create(pReadOptions);
1162+
String topicName = "fozzie_test_kerberos_topic";
1163+
String bootstrapServer =
1164+
"fozzie-test-kafka-broker.us-central1-c.c.dataflow-testing-311516.internal:9092";
1165+
String saslJaasConfig =
1166+
"com.sun.security.auth.module.Krb5LoginModule required "
1167+
+ "useTicketCache=false "
1168+
+ "useKeyTab=true "
1169+
+ "storeKey=true "
1170+
+ "keyTab=\"secretValue:projects/dataflow-testing-311516/secrets/kafka-client-keytab/versions/latest\" "
1171+
+ "principal=\"kafka-client@US-CENTRAL1-B.C.DATAFLOW-TESTING-311516.INTERNAL\";";
1172+
1173+
Map<String, Object> consumerConfig = new HashMap<>();
1174+
1175+
consumerConfig.put("security.protocol", "SASL_PLAINTEXT");
1176+
consumerConfig.put("sasl.mechanism", "GSSAPI");
1177+
consumerConfig.put("sasl.kerberos.service.name", "kafka");
1178+
consumerConfig.put("auto.offset.reset", "earliest");
1179+
consumerConfig.put("sasl.jaas.config", saslJaasConfig);
1180+
1181+
PCollection<Long> count =
1182+
pRead
1183+
.apply(
1184+
"Read from Kafka",
1185+
KafkaIO.<String, String>read()
1186+
.withBootstrapServers(bootstrapServer)
1187+
.withConsumerConfigUpdates(consumerConfig)
1188+
.withTopic(topicName)
1189+
.withKeyDeserializer(StringDeserializer.class)
1190+
.withValueDeserializer(StringDeserializer.class)
1191+
.withConsumerFactoryFn(
1192+
new KerberosConsumerFactoryFn(
1193+
"gs://fozzie_testing_bucket/kerberos/krb5.conf"))
1194+
.withMaxNumRecords((long) 11))
1195+
.apply("Counting element", Count.globally());
1196+
1197+
PipelineResult readResult = pRead.run();
1198+
1199+
// Only waiting 5 seconds here because we don't expect any processing at this point
1200+
PipelineResult.State readState = readResult.waitUntilFinish(Duration.standardMinutes(15));
1201+
cancelIfTimeouted(readResult, readState);
1202+
assertNotEquals(PipelineResult.State.FAILED, readState);
1203+
assertNotEquals(PipelineResult.State.CANCELLED, readState);
1204+
PAssert.thatSingleton(count).isEqualTo((long) 11);
1205+
}
1206+
11201207
private static class KeyByPartition
11211208
extends DoFn<KafkaRecord<Integer, String>, KV<Integer, KafkaRecord<Integer, String>>> {
11221209

@@ -1240,6 +1327,7 @@ private static void setupKafkaContainer() {
12401327
options.setKafkaBootstrapServerAddresses(kafkaContainer.getBootstrapServers());
12411328
}
12421329

1330+
@Ignore
12431331
@Test
12441332
public void testCustomRowDeserializerWithViaSDF() throws IOException {
12451333
// This test verifies that the SDF implementation of KafkaIO correctly handles

0 commit comments

Comments
 (0)