You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ma...@apache.org on 2019/03/13 17:40:57 UTC
[hadoop] branch trunk updated: HADOOP-16166.
TestRawLocalFileSystemContract fails with build Docker container running on
Mac. Also provided similar fix for Windows.
This is an automated email from the ASF dual-hosted git repository.
mattf pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push:
new f74159c HADOOP-16166. TestRawLocalFileSystemContract fails with build Docker container running on Mac. Also provided similar fix for Windows.
f74159c is described below
commit f74159c8fc5e7fd0c4357d6dc95ce05f94e60145
Author: Matt Foley <ma...@apple.com>
AuthorDate: Tue Mar 5 02:40:13 2019 -0800
HADOOP-16166. TestRawLocalFileSystemContract fails with build Docker container running on Mac.
Also provided similar fix for Windows.
---
.../hadoop/fs/TestRawLocalFileSystemContract.java | 42 ++++++++++++++++++++--
1 file changed, 39 insertions(+), 3 deletions(-)
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestRawLocalFileSystemContract.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestRawLocalFileSystemContract.java
index 908e330..2e514c4 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestRawLocalFileSystemContract.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestRawLocalFileSystemContract.java
@@ -18,6 +18,8 @@
package org.apache.hadoop.fs;
import java.io.File;
+import java.io.IOException;
+import java.util.regex.Pattern;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.test.GenericTestUtils;
@@ -44,6 +46,18 @@ public class TestRawLocalFileSystemContract extends FileSystemContractBaseTest {
private final static Path TEST_BASE_DIR =
new Path(GenericTestUtils.getRandomizedTestDir().getAbsolutePath());
+ // These are the string values that DF sees as "Filesystem" for a
+ // Docker container accessing a Mac or Windows host's filesystem.
+ private static final String FS_TYPE_MAC = "osxfs";
+ private static boolean looksLikeMac(String filesys) {
+ return filesys.toLowerCase().contains(FS_TYPE_MAC.toLowerCase());
+ }
+ private static final Pattern HAS_DRIVE_LETTER_SPECIFIER =
+ Pattern.compile("^/?[a-zA-Z]:");
+ private static boolean looksLikeWindows(String filesys) {
+ return HAS_DRIVE_LETTER_SPECIFIER.matcher(filesys).find();
+ }
+
@Before
public void setUp() throws Exception {
Configuration conf = new Configuration();
@@ -84,7 +98,29 @@ public class TestRawLocalFileSystemContract extends FileSystemContractBaseTest {
@Override
protected boolean filesystemIsCaseSensitive() {
- return !(Shell.WINDOWS || Shell.MAC);
+ if (Shell.WINDOWS || Shell.MAC) {
+ return false;
+ }
+ // osType is linux or unix-like, but it might be in a container mounting a
+ // Mac or Windows volume. Use DF to try to determine if this is the case.
+ String rfsPathStr = "uninitialized";
+ String rfsType;
+ try {
+ RawLocalFileSystem rfs = new RawLocalFileSystem();
+ Configuration conf = new Configuration();
+ rfs.initialize(rfs.getUri(), conf);
+ rfsPathStr = Path.getPathWithoutSchemeAndAuthority(
+ rfs.getWorkingDirectory()).toString();
+ File rfsPath = new File(rfsPathStr);
+ // DF.getFilesystem() only provides indirect info about FS type, but it's
+ // the best we have. `df -T` would be better, but isn't cross-platform.
+ rfsType = (new DF(rfsPath, conf)).getFilesystem();
+ LOG.info("DF.Filesystem is {} for path {}", rfsType, rfsPath);
+ } catch (IOException ex) {
+ LOG.error("DF failed on path {}", rfsPathStr);
+ rfsType = Shell.osType.toString();
+ }
+ return !(looksLikeMac(rfsType) || looksLikeWindows(rfsType));
}
// cross-check getPermission using both native/non-native
@@ -107,8 +143,8 @@ public class TestRawLocalFileSystemContract extends FileSystemContractBaseTest {
// test initial permission
//
RawLocalFileSystem.DeprecatedRawLocalFileStatus fsNIO =
- new RawLocalFileSystem.DeprecatedRawLocalFileStatus(
- file, defaultBlockSize, rfs);
+ new RawLocalFileSystem.DeprecatedRawLocalFileStatus(
+ file, defaultBlockSize, rfs);
fsNIO.loadPermissionInfoByNativeIO();
RawLocalFileSystem.DeprecatedRawLocalFileStatus fsnonNIO =
new RawLocalFileSystem.DeprecatedRawLocalFileStatus(
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org