Github user zentol commented on a diff in the pull request:

    https://github.com/apache/flink/pull/1929#discussion_r60933644
  
    --- Diff: 
flink-streaming-java/src/test/java/org/apache/flink/streaming/api/functions/source/FileSplitMonitoringFunctionTest.java
 ---
    @@ -0,0 +1,371 @@
    +/*
    + * 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.commons.io.IOUtils;
    +import org.apache.flink.api.common.io.FileInputFormat;
    +import org.apache.flink.api.common.typeinfo.TypeInformation;
    +import org.apache.flink.api.java.typeutils.TypeExtractor;
    +import org.apache.flink.configuration.Configuration;
    +import org.apache.flink.core.fs.FileInputSplit;
    +import org.apache.flink.core.fs.Path;
    +import org.apache.flink.streaming.api.watermark.Watermark;
    +import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
    +import org.apache.flink.streaming.util.OneInputStreamOperatorTestHarness;
    +import org.apache.hadoop.fs.FSDataOutputStream;
    +import org.apache.hadoop.fs.FileUtil;
    +import org.apache.hadoop.hdfs.MiniDFSCluster;
    +import org.junit.After;
    +import org.junit.Assert;
    +import org.junit.Before;
    +import org.junit.Test;
    +
    +import java.io.File;
    +import java.io.IOException;
    +import java.io.StringWriter;
    +import java.util.HashMap;
    +import java.util.HashSet;
    +import java.util.Map;
    +import java.util.Queue;
    +import java.util.Set;
    +
    +public class FileSplitMonitoringFunctionTest {
    +
    +   private static final int NO_OF_FILES = 10;
    +   private static final int LINES_PER_FILE = 10;
    +
    +   private static final long INTERVAL = 200;
    +
    +   private File baseDir;
    +
    +   private org.apache.hadoop.fs.FileSystem hdfs;
    +   private String hdfsURI;
    +   private MiniDFSCluster hdfsCluster;
    +
    +   private Set<org.apache.hadoop.fs.Path> hdPaths = new HashSet<>();
    +   private Set<String> hdPathNames = new HashSet<>();
    +   private Map<Integer, String> hdPathContents = new HashMap<>();
    +
    +   //                                              PREPARING FOR THE TESTS
    +
    +   @Before
    +   public void createHDFS() {
    +           try {
    +                   baseDir = new 
File("./target/hdfs/hdfsTesting").getAbsoluteFile();
    +                   FileUtil.fullyDelete(baseDir);
    +
    +                   org.apache.hadoop.conf.Configuration hdConf = new 
org.apache.hadoop.conf.Configuration();
    +                   hdConf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, 
baseDir.getAbsolutePath());
    +                   hdConf.set("dfs.block.size", String.valueOf(1048576)); 
// this is the minimum we can set.
    +
    +                   MiniDFSCluster.Builder builder = new 
MiniDFSCluster.Builder(hdConf);
    +                   hdfsCluster = builder.build();
    +
    +                   hdfsURI = "hdfs://" + hdfsCluster.getURI().getHost() + 
":" + hdfsCluster.getNameNodePort() +"/";
    +                   hdfs = new 
org.apache.hadoop.fs.Path(hdfsURI).getFileSystem(hdConf);
    +
    +           } catch(Throwable e) {
    +                   e.printStackTrace();
    +                   Assert.fail("Test failed " + e.getMessage());
    +           }
    +   }
    +
    +   @After
    +   public void destroyHDFS() {
    +           try {
    +                   for(org.apache.hadoop.fs.Path file: hdPaths) {
    +                           hdfs.delete(file, false);
    +                   }
    +                   FileUtil.fullyDelete(baseDir);
    +                   hdfsCluster.shutdown();
    +           } catch (IOException e) {
    +                   throw new RuntimeException(e);
    +           }
    +   }
    +
    +   //                                              END OF PREPARATIONS
    +
    +   //                                              TESTS
    +
    +   @Test
    +   public void testFileContents() throws IOException {
    --- End diff --
    
    this test doesn't test anything in regards to the MonitoringFunction, does 
it?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to