flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [flink] StefanRRichter commented on a change in pull request #7896: [FLINK-9007] [kinesis] [e2e] Add Kinesis end-to-end test
Date Mon, 11 Mar 2019 17:45:15 GMT
StefanRRichter 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_r264350717
 
 

 ##########
 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:
   I would suggest to also join on this thread somewhere later, maybe before we enter the
readMessages part (assuming the generator will not block, if it does join can still happen
somewhere later).

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message