tweise commented on a change in pull request #7896: [FLINK-9007] [kinesis] 
[e2e] Add Kinesis end-to-end test
URL: https://github.com/apache/flink/pull/7896#discussion_r264372875
 
 

 ##########
 File path: 
flink-end-to-end-tests/flink-streaming-kinesis-test/src/main/java/org/apache/flink/streaming/kinesis/test/KinesisExampleTest.java
 ##########
 @@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.streaming.kinesis.test;
+
+import org.apache.flink.api.common.time.Deadline;
+import org.apache.flink.api.java.utils.ParameterTool;
+
+import org.junit.Assert;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.time.Duration;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicReference;
+
+/**
+ * Test driver for {@link KinesisExample#main}.
+ */
+public class KinesisExampleTest {
+       private static final Logger LOG = 
LoggerFactory.getLogger(KinesisExampleTest.class);
+
+       /**
+        * Interface to the pubsub system for this test.
+        */
+       interface PubsubClient {
+               void createTopic(String topic, int partitions, Properties 
props) throws Exception;
+
+               void sendMessage(String topic, String msg);
+
+               List<String> readAllMessages(String streamName) throws 
Exception;
+       }
+
+       public static void main(String[] args) throws Exception {
+               LOG.info("System properties: {}", System.getProperties());
+               final ParameterTool parameterTool = 
ParameterTool.fromArgs(args);
+
+               String inputStream = parameterTool.getRequired("input-stream");
+               String outputStream = 
parameterTool.getRequired("output-stream");
+
+               PubsubClient pubsub = new 
KinesisPubsubClient(parameterTool.getProperties());
+               pubsub.createTopic(inputStream, 2, 
parameterTool.getProperties());
+               pubsub.createTopic(outputStream, 2, 
parameterTool.getProperties());
+
+               // job and test driver need to run in parallel
+               final AtomicReference<Exception> executeException = new 
AtomicReference<>();
+               Thread executeThread =
+                       new Thread(
+                               () -> {
+                                       try {
+                                               KinesisExample.main(args);
+                                               LOG.info("executed program");
+                                       } catch (Exception e) {
+                                               executeException.set(e);
+                                       }
+                               });
+               executeThread.start();
 
 Review comment:
   The thread that runs the job does not terminate (I don't have a reference to 
the job and cannot cancel it). The job needs to start after the streams are 
created and run in parallel to the validation logic. Once the expected results 
are in, the driver exits and the job/cluster is terminated from the script, 
prior to terminating Kinesalite.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to