You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/04/20 14:58:33 UTC

[GitHub] [flink] pnowojski commented on a change in pull request #11802: [FLINK-17197][runtime] switch ContinuousFileReaderOperator state to FAILED on error

pnowojski commented on a change in pull request #11802:
URL: https://github.com/apache/flink/pull/11802#discussion_r411444322



##########
File path: flink-streaming-java/src/main/java/org/apache/flink/streaming/api/functions/source/ContinuousFileReaderOperator.java
##########
@@ -160,10 +169,11 @@ public boolean prepareToProcessRecord(ContinuousFileReaderOperator<?> op) {
 		private static final Map<ReaderState, Set<ReaderState>> TRANSITIONS;

Review comment:
       nit: `POSSIBLE_TRANSITIONS `?

##########
File path: flink-streaming-java/src/test/java/org/apache/flink/streaming/api/functions/source/ContinuousFileReaderOperatorTest.java
##########
@@ -0,0 +1,72 @@
+/*
+ * 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.api.functions.source;
+
+import org.apache.flink.api.common.io.FileInputFormat;
+import org.apache.flink.core.fs.FileInputSplit;
+import org.apache.flink.core.fs.Path;
+import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
+import org.apache.flink.streaming.runtime.tasks.StreamTaskActionExecutor;
+import org.apache.flink.streaming.runtime.tasks.TestProcessingTimeService;
+import org.apache.flink.streaming.runtime.tasks.mailbox.Mail;
+import org.apache.flink.streaming.runtime.tasks.mailbox.MailboxExecutorImpl;
+import org.apache.flink.streaming.runtime.tasks.mailbox.TaskMailboxImpl;
+
+import org.junit.Test;
+
+/**
+ * {@link ContinuousFileReaderOperator} test.
+ */
+public class ContinuousFileReaderOperatorTest {
+
+	@Test(expected = TestException.class)
+	public void testExceptionRethrown() throws Exception {
+		final TaskMailboxImpl mailbox = new TaskMailboxImpl();
+		final ContinuousFileReaderOperator<String> op = new ContinuousFileReaderOperator<>(
+				failingFormat(),
+				new TestProcessingTimeService(),
+				new MailboxExecutorImpl(mailbox, 0, StreamTaskActionExecutor.IMMEDIATE)
+		);
+		op.processElement(new StreamRecord<>(new TimestampedFileInputSplit(0L, 1, new Path(), 0L, 0L, new String[]{})));
+		for (Mail m : mailbox.drain()) {
+			m.run();
+		}

Review comment:
       This test is violating the operator's contract here, by not calling `open()` and `initializeState()` methods. As it is know, it relays on the private implementation detail that those method are not doing anything important for this particular test case. It could lead to false positive errors if someone would add some valid logic to the `ContinuousFileReaderOperator#processElement()`, which would (legally) relay on any logic being done in those two methods.
   
   Couldn't you re-use pattern from `org.apache.flink.hdfstests.ContinuousFileProcessingTest#testExceptionHandling`?
   
   

##########
File path: flink-streaming-java/src/test/java/org/apache/flink/streaming/api/functions/source/ContinuousFileReaderOperatorTest.java
##########
@@ -0,0 +1,72 @@
+/*
+ * 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.api.functions.source;
+
+import org.apache.flink.api.common.io.FileInputFormat;
+import org.apache.flink.core.fs.FileInputSplit;
+import org.apache.flink.core.fs.Path;
+import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
+import org.apache.flink.streaming.runtime.tasks.StreamTaskActionExecutor;
+import org.apache.flink.streaming.runtime.tasks.TestProcessingTimeService;
+import org.apache.flink.streaming.runtime.tasks.mailbox.Mail;
+import org.apache.flink.streaming.runtime.tasks.mailbox.MailboxExecutorImpl;
+import org.apache.flink.streaming.runtime.tasks.mailbox.TaskMailboxImpl;
+
+import org.junit.Test;
+
+/**
+ * {@link ContinuousFileReaderOperator} test.
+ */
+public class ContinuousFileReaderOperatorTest {

Review comment:
       Why have you created a separate class to add this unit test? There is already a similar test `org.apache.flink.hdfstests.ContinuousFileProcessingTest#testExceptionHandling` so definitely those two should be together. 
   
   A good questions is why is the test for a class `ContinuousFileReaderOperator` named `ContinuousFileProcessingTest` but I guess that's a story for another time. (I would be +1 for renaming all `ContinuousFileProcessing***` classes to `ContinuousFileReaderOperator***`)




----------------------------------------------------------------
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