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

    https://github.com/apache/flink/pull/3388#discussion_r103194179
  
    --- Diff: 
flink-fs-tests/src/test/java/org/apache/flink/hdfstests/FileUtilsTest.java ---
    @@ -0,0 +1,117 @@
    +/*
    + * 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.hdfstests;
    +
    +import org.apache.flink.core.fs.FSDataInputStream;
    +import org.apache.flink.core.fs.FSDataOutputStream;
    +import org.apache.flink.core.fs.FileSystem;
    +import org.apache.flink.core.fs.Path;
    +import org.apache.flink.test.util.AbstractTestBase;
    +import org.apache.flink.util.FileUtils;
    +import org.apache.hadoop.conf.Configuration;
    +import org.apache.hadoop.hdfs.MiniDFSCluster;
    +import org.junit.*;
    +import org.junit.rules.TemporaryFolder;
    +
    +import java.io.File;
    +import java.io.IOException;
    +import java.net.URI;
    +
    +import static org.junit.Assert.fail;
    +
    +/**
    + * Created by wenlong.lwl on 2017/2/21.
    + */
    +public class FileUtilsTest {
    +   @ClassRule
    +   public static TemporaryFolder temporaryFolder = new TemporaryFolder();
    +
    +   private static File TEMP_DIR;
    +
    +   private static String HDFS_ROOT_URI;
    +
    +   private static MiniDFSCluster HDFS_CLUSTER;
    +
    +   private static FileSystem FS;
    +
    +   // 
------------------------------------------------------------------------
    +   //  startup / shutdown
    +   // 
------------------------------------------------------------------------
    +
    +   @BeforeClass
    +   public static void createHDFS() {
    +           try {
    +                   TEMP_DIR = temporaryFolder.newFolder();
    +
    +                   Configuration hdConf = new Configuration();
    +                   hdConf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, 
TEMP_DIR.getAbsolutePath());
    +                   MiniDFSCluster.Builder builder = new 
MiniDFSCluster.Builder(hdConf);
    +                   HDFS_CLUSTER = builder.build();
    +
    +                   HDFS_ROOT_URI = "hdfs://" + 
HDFS_CLUSTER.getURI().getHost() + ":"
    +                           + HDFS_CLUSTER.getNameNodePort() + "/";
    +
    +                   FS = FileSystem.get(new URI(HDFS_ROOT_URI));
    +           }
    +           catch (Exception e) {
    +                   e.printStackTrace();
    +                   fail("Could not create HDFS mini cluster " + 
e.getMessage());
    +           }
    +   }
    +
    +   @AfterClass
    +   public static void destroyHDFS() {
    +           try {
    +                   HDFS_CLUSTER.shutdown();
    +           }
    +           catch (Exception ignored) {}
    +   }
    +
    +   @Test
    +   public void testCompareFs() throws IOException {
    +           File localDir = temporaryFolder.newFolder();
    +           Assert.assertFalse(FileUtils.compareFs(new 
Path(localDir.toURI()).getFileSystem(), FS));
    --- End diff --
    
    For this test, I think we don't have to create a HDFSCluster to obtain an 
HDFS `FileSystem`. Can't we create the respective URIs?


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