You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by ra...@apache.org on 2021/02/25 04:40:08 UTC
[ozone] branch HDDS-2939 updated: HDDS-4513.[FSO]OzoneContract unit
test case fixes (#1945)
This is an automated email from the ASF dual-hosted git repository.
rakeshr pushed a commit to branch HDDS-2939
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/HDDS-2939 by this push:
new 818e5ef HDDS-4513.[FSO]OzoneContract unit test case fixes (#1945)
818e5ef is described below
commit 818e5ef07f597e8cbc9a73534a080a6d6a8f5dcc
Author: Sadanand Shenoy <sa...@gmail.com>
AuthorDate: Thu Feb 25 10:09:42 2021 +0530
HDDS-4513.[FSO]OzoneContract unit test case fixes (#1945)
---
.../hadoop/fs/ozone/TestOzoneFileSystemV1.java | 61 +++-------------------
.../ozone/contract/ITestOzoneContractCreate.java | 26 +++++++--
.../ozone/contract/ITestOzoneContractDelete.java | 26 +++++++--
.../contract/ITestOzoneContractGetFileStatus.java | 27 ++++++++--
.../fs/ozone/contract/ITestOzoneContractMkdir.java | 26 +++++++--
.../fs/ozone/contract/ITestOzoneContractOpen.java | 27 ++++++++--
.../ozone/contract/ITestOzoneContractRename.java | 26 +++++++--
.../ozone/contract/ITestOzoneContractRootDir.java | 26 +++++++--
.../fs/ozone/contract/ITestOzoneContractSeek.java | 27 ++++++++--
.../ozone/contract/ITestOzoneContractUnbuffer.java | 26 +++++++--
.../fs/ozone/contract/ITestOzoneContractUtils.java | 60 +++++++++++++++++++++
.../hadoop/fs/ozone/contract/OzoneContract.java | 13 +++++
.../hadoop/fs/ozone/BasicOzoneFileSystem.java | 11 ++--
13 files changed, 288 insertions(+), 94 deletions(-)
diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystemV1.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystemV1.java
index eb7eaca..ed62990 100644
--- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystemV1.java
+++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystemV1.java
@@ -24,7 +24,6 @@ import org.apache.hadoop.fs.LocatedFileStatus;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.RemoteIterator;
import org.apache.hadoop.fs.contract.ContractTestUtils;
-import org.apache.hadoop.ozone.om.exceptions.OMException;
import org.junit.Assert;
import org.junit.After;
import org.junit.BeforeClass;
@@ -278,36 +277,6 @@ public class TestOzoneFileSystemV1 extends TestOzoneFileSystem {
}
/**
- * Case-1) fromKeyName should exist, otw throws exception.
- */
- @Test
- public void testRenameWithNonExistentSource() throws Exception {
- // Skip as this will run only in new layout
- if (!isEnabledFileSystemPaths()) {
- return;
- }
-
- final String root = "/root";
- final String dir1 = root + "/dir1";
- final String dir2 = root + "/dir2";
- final Path source = new Path(getFs().getUri().toString() + dir1);
- final Path destin = new Path(getFs().getUri().toString() + dir2);
-
- // creates destin
- getFs().mkdirs(destin);
- LOG.info("Created destin dir: {}", destin);
-
- LOG.info("Rename op-> source:{} to destin:{}}", source, destin);
- try {
- getFs().rename(source, destin);
- Assert.fail("Should throw exception : Source doesn't exist!");
- } catch (OMException ome) {
- // expected
- assertEquals(ome.getResult(), OMException.ResultCodes.KEY_NOT_FOUND);
- }
- }
-
- /**
* Case-2) Cannot rename a directory to its own subdirectory.
*/
@Test
@@ -327,14 +296,8 @@ public class TestOzoneFileSystemV1 extends TestOzoneFileSystem {
final Path sourceRoot = new Path(getFs().getUri().toString() + root);
LOG.info("Rename op-> source:{} to destin:{}", sourceRoot, subDir1);
- try {
- getFs().rename(sourceRoot, subDir1);
- Assert.fail("Should throw exception : Cannot rename a directory to" +
- " its own subdirectory");
- } catch (OMException ome) {
- // expected
- assertEquals(ome.getResult(), OMException.ResultCodes.KEY_RENAME_ERROR);
- }
+ // rename should fail and return false
+ Assert.assertFalse(getFs().rename(sourceRoot, subDir1));
}
/**
@@ -354,30 +317,18 @@ public class TestOzoneFileSystemV1 extends TestOzoneFileSystem {
final String dir2 = dir1 + "/dir2";
final Path dir2SourcePath = new Path(getFs().getUri().toString() + dir2);
getFs().mkdirs(dir2SourcePath);
-
// (a) parent of dst does not exist. /root_dir/b/c
final Path destinPath = new Path(getFs().getUri().toString()
+ root + "/b/c");
- try {
- getFs().rename(dir2SourcePath, destinPath);
- Assert.fail("Should fail as parent of dst does not exist!");
- } catch (OMException ome) {
- // expected
- assertEquals(ome.getResult(), OMException.ResultCodes.KEY_RENAME_ERROR);
- }
+ // rename should fail and return false
+ Assert.assertFalse(getFs().rename(dir2SourcePath, destinPath));
// (b) parent of dst is a file. /root_dir/file1/c
Path filePath = new Path(getFs().getUri().toString() + root + "/file1");
ContractTestUtils.touch(getFs(), filePath);
-
Path newDestinPath = new Path(filePath, "c");
- try {
- getFs().rename(dir2SourcePath, newDestinPath);
- Assert.fail("Should fail as parent of dst is a file!");
- } catch (OMException ome) {
- // expected
- assertEquals(ome.getResult(), OMException.ResultCodes.KEY_RENAME_ERROR);
- }
+ // rename should fail and return false
+ Assert.assertFalse(getFs().rename(dir2SourcePath, newDestinPath));
}
@Override
diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractCreate.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractCreate.java
index 19ff428..034cf1e 100644
--- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractCreate.java
+++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractCreate.java
@@ -19,22 +19,35 @@
package org.apache.hadoop.fs.ozone.contract;
import java.io.IOException;
+import java.util.Collection;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.contract.AbstractContractCreateTest;
import org.apache.hadoop.fs.contract.AbstractFSContract;
import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
/**
* Ozone contract tests creating files.
*/
+@RunWith(Parameterized.class)
public class ITestOzoneContractCreate extends AbstractContractCreateTest {
- @BeforeClass
- public static void createCluster() throws IOException {
- OzoneContract.createCluster();
+ private static boolean fsOptimizedServer;
+
+ public ITestOzoneContractCreate(boolean fsoServer)
+ throws IOException {
+ if (fsOptimizedServer != fsoServer) {
+ setFsOptimizedServer(fsoServer);
+ ITestOzoneContractUtils.restartCluster(
+ fsOptimizedServer);
+ }
+ }
+
+ public static void setFsOptimizedServer(boolean fsOptimizedServer) {
+ ITestOzoneContractCreate.fsOptimizedServer = fsOptimizedServer;
}
@AfterClass
@@ -46,4 +59,9 @@ public class ITestOzoneContractCreate extends AbstractContractCreateTest {
protected AbstractFSContract createContract(Configuration conf) {
return new OzoneContract(conf);
}
+
+ @Parameterized.Parameters
+ public static Collection data() {
+ return ITestOzoneContractUtils.getFsoCombinations();
+ }
}
diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractDelete.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractDelete.java
index 33e6260..1381a2c 100644
--- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractDelete.java
+++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractDelete.java
@@ -19,22 +19,35 @@
package org.apache.hadoop.fs.ozone.contract;
import java.io.IOException;
+import java.util.Collection;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.contract.AbstractContractDeleteTest;
import org.apache.hadoop.fs.contract.AbstractFSContract;
import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
/**
* Ozone contract tests covering deletes.
*/
+@RunWith(Parameterized.class)
public class ITestOzoneContractDelete extends AbstractContractDeleteTest {
- @BeforeClass
- public static void createCluster() throws IOException {
- OzoneContract.createCluster();
+ private static boolean fsOptimizedServer;
+
+ public ITestOzoneContractDelete(boolean fsoServer)
+ throws IOException {
+ if (fsOptimizedServer != fsoServer) {
+ setFsOptimizedServer(fsoServer);
+ ITestOzoneContractUtils.restartCluster(
+ fsOptimizedServer);
+ }
+ }
+
+ public static void setFsOptimizedServer(boolean fsOptimizedServer) {
+ ITestOzoneContractDelete.fsOptimizedServer = fsOptimizedServer;
}
@AfterClass
@@ -46,4 +59,9 @@ public class ITestOzoneContractDelete extends AbstractContractDeleteTest {
protected AbstractFSContract createContract(Configuration conf) {
return new OzoneContract(conf);
}
+
+ @Parameterized.Parameters
+ public static Collection data() {
+ return ITestOzoneContractUtils.getFsoCombinations();
+ }
}
diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractGetFileStatus.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractGetFileStatus.java
index 9d9aa56..04a3fb5 100644
--- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractGetFileStatus.java
+++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractGetFileStatus.java
@@ -19,28 +19,42 @@
package org.apache.hadoop.fs.ozone.contract;
import java.io.IOException;
+import java.util.Collection;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.contract.AbstractContractGetFileStatusTest;
import org.apache.hadoop.fs.contract.AbstractFSContract;
import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Ozone contract tests covering getFileStatus.
*/
+@RunWith(Parameterized.class)
public class ITestOzoneContractGetFileStatus
extends AbstractContractGetFileStatusTest {
+ private static boolean fsOptimizedServer;
+
+ public ITestOzoneContractGetFileStatus(boolean fsoServer)
+ throws IOException {
+ if (fsOptimizedServer != fsoServer) {
+ setFsOptimizedServer(fsoServer);
+ ITestOzoneContractUtils.restartCluster(
+ fsOptimizedServer);
+ }
+ }
+
private static final Logger LOG =
LoggerFactory.getLogger(ITestOzoneContractGetFileStatus.class);
- @BeforeClass
- public static void createCluster() throws IOException {
- OzoneContract.createCluster();
+
+ public static void setFsOptimizedServer(boolean fsOptimizedServer) {
+ ITestOzoneContractGetFileStatus.fsOptimizedServer = fsOptimizedServer;
}
@AfterClass
@@ -63,4 +77,9 @@ public class ITestOzoneContractGetFileStatus
protected Configuration createConfiguration() {
return super.createConfiguration();
}
+
+ @Parameterized.Parameters
+ public static Collection data() {
+ return ITestOzoneContractUtils.getFsoCombinations();
+ }
}
diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractMkdir.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractMkdir.java
index 305164c..862b2b9 100644
--- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractMkdir.java
+++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractMkdir.java
@@ -19,22 +19,35 @@
package org.apache.hadoop.fs.ozone.contract;
import java.io.IOException;
+import java.util.Collection;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.contract.AbstractContractMkdirTest;
import org.apache.hadoop.fs.contract.AbstractFSContract;
import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
/**
* Test dir operations on Ozone.
*/
+@RunWith(Parameterized.class)
public class ITestOzoneContractMkdir extends AbstractContractMkdirTest {
- @BeforeClass
- public static void createCluster() throws IOException {
- OzoneContract.createCluster();
+ private static boolean fsOptimizedServer;
+
+ public ITestOzoneContractMkdir(boolean fsoServer)
+ throws IOException {
+ if (fsOptimizedServer != fsoServer) {
+ setFsOptimizedServer(fsoServer);
+ ITestOzoneContractUtils.restartCluster(
+ fsOptimizedServer);
+ }
+ }
+
+ public static void setFsOptimizedServer(boolean fsOptimizedServer) {
+ ITestOzoneContractMkdir.fsOptimizedServer = fsOptimizedServer;
}
@AfterClass
@@ -46,4 +59,9 @@ public class ITestOzoneContractMkdir extends AbstractContractMkdirTest {
protected AbstractFSContract createContract(Configuration conf) {
return new OzoneContract(conf);
}
+
+ @Parameterized.Parameters
+ public static Collection data() {
+ return ITestOzoneContractUtils.getFsoCombinations();
+ }
}
diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractOpen.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractOpen.java
index aa81965..83a6306 100644
--- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractOpen.java
+++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractOpen.java
@@ -19,21 +19,35 @@
package org.apache.hadoop.fs.ozone.contract;
import java.io.IOException;
+import java.util.Collection;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.contract.AbstractContractOpenTest;
import org.apache.hadoop.fs.contract.AbstractFSContract;
import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
/**
* Ozone contract tests opening files.
*/
+@RunWith(Parameterized.class)
public class ITestOzoneContractOpen extends AbstractContractOpenTest {
- @BeforeClass
- public static void createCluster() throws IOException {
- OzoneContract.createCluster();
+
+ private static boolean fsOptimizedServer;
+
+ public ITestOzoneContractOpen(boolean fsoServer)
+ throws IOException {
+ if (fsOptimizedServer != fsoServer) {
+ setFsOptimizedServer(fsoServer);
+ ITestOzoneContractUtils.restartCluster(
+ fsOptimizedServer);
+ }
+ }
+
+ public static void setFsOptimizedServer(boolean fsOptimizedServer) {
+ ITestOzoneContractOpen.fsOptimizedServer = fsOptimizedServer;
}
@AfterClass
@@ -45,4 +59,9 @@ public class ITestOzoneContractOpen extends AbstractContractOpenTest {
protected AbstractFSContract createContract(Configuration conf) {
return new OzoneContract(conf);
}
+
+ @Parameterized.Parameters
+ public static Collection data() {
+ return ITestOzoneContractUtils.getFsoCombinations();
+ }
}
diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractRename.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractRename.java
index 3660d81..2fa1c64 100644
--- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractRename.java
+++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractRename.java
@@ -19,22 +19,35 @@
package org.apache.hadoop.fs.ozone.contract;
import java.io.IOException;
+import java.util.Collection;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.contract.AbstractContractRenameTest;
import org.apache.hadoop.fs.contract.AbstractFSContract;
import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
/**
* Ozone contract tests covering rename.
*/
+@RunWith(Parameterized.class)
public class ITestOzoneContractRename extends AbstractContractRenameTest {
- @BeforeClass
- public static void createCluster() throws IOException {
- OzoneContract.createCluster();
+ private static boolean fsOptimizedServer;
+
+ public ITestOzoneContractRename(boolean fsoServer)
+ throws IOException {
+ if (fsOptimizedServer != fsoServer) {
+ setFsOptimizedServer(fsoServer);
+ ITestOzoneContractUtils.restartCluster(
+ fsOptimizedServer);
+ }
+ }
+
+ public static void setFsOptimizedServer(boolean fsOptimizedServer) {
+ ITestOzoneContractRename.fsOptimizedServer = fsOptimizedServer;
}
@AfterClass
@@ -47,4 +60,9 @@ public class ITestOzoneContractRename extends AbstractContractRenameTest {
return new OzoneContract(conf);
}
+
+ @Parameterized.Parameters
+ public static Collection data() {
+ return ITestOzoneContractUtils.getFsoCombinations();
+ }
}
diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractRootDir.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractRootDir.java
index c64dafa..5ca5bc3 100644
--- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractRootDir.java
+++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractRootDir.java
@@ -19,23 +19,36 @@
package org.apache.hadoop.fs.ozone.contract;
import java.io.IOException;
+import java.util.Collection;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.contract.AbstractContractRootDirectoryTest;
import org.apache.hadoop.fs.contract.AbstractFSContract;
import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
/**
* Ozone contract test for ROOT directory operations.
*/
+@RunWith(Parameterized.class)
public class ITestOzoneContractRootDir extends
AbstractContractRootDirectoryTest {
- @BeforeClass
- public static void createCluster() throws IOException {
- OzoneContract.createCluster();
+ private static boolean fsOptimizedServer;
+
+ public ITestOzoneContractRootDir(boolean fsoServer)
+ throws IOException {
+ if (fsOptimizedServer != fsoServer) {
+ setFsOptimizedServer(fsoServer);
+ ITestOzoneContractUtils.restartCluster(
+ fsOptimizedServer);
+ }
+ }
+
+ public static void setFsOptimizedServer(boolean fsOptimizedServer) {
+ ITestOzoneContractRootDir.fsOptimizedServer = fsOptimizedServer;
}
@AfterClass
@@ -48,4 +61,9 @@ public class ITestOzoneContractRootDir extends
return new OzoneContract(conf);
}
+ @Parameterized.Parameters
+ public static Collection data() {
+ return ITestOzoneContractUtils.getFsoCombinations();
+ }
+
}
diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractSeek.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractSeek.java
index 2f22025..9457bb8 100644
--- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractSeek.java
+++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractSeek.java
@@ -19,21 +19,35 @@
package org.apache.hadoop.fs.ozone.contract;
import java.io.IOException;
+import java.util.Collection;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.contract.AbstractContractSeekTest;
import org.apache.hadoop.fs.contract.AbstractFSContract;
import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
/**
* Ozone contract tests covering file seek.
*/
+@RunWith(Parameterized.class)
public class ITestOzoneContractSeek extends AbstractContractSeekTest {
- @BeforeClass
- public static void createCluster() throws IOException {
- OzoneContract.createCluster();
+
+ private static boolean fsOptimizedServer;
+
+ public ITestOzoneContractSeek(boolean fsoServer)
+ throws IOException {
+ if (fsOptimizedServer != fsoServer) {
+ setFsOptimizedServer(fsoServer);
+ ITestOzoneContractUtils.restartCluster(
+ fsOptimizedServer);
+ }
+ }
+
+ public static void setFsOptimizedServer(boolean fsOptimizedServer) {
+ ITestOzoneContractSeek.fsOptimizedServer = fsOptimizedServer;
}
@AfterClass
@@ -45,4 +59,9 @@ public class ITestOzoneContractSeek extends AbstractContractSeekTest {
protected AbstractFSContract createContract(Configuration conf) {
return new OzoneContract(conf);
}
+
+ @Parameterized.Parameters
+ public static Collection data() {
+ return ITestOzoneContractUtils.getFsoCombinations();
+ }
}
diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractUnbuffer.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractUnbuffer.java
index e40b22e..7f55774 100644
--- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractUnbuffer.java
+++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractUnbuffer.java
@@ -21,18 +21,31 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.contract.AbstractContractUnbufferTest;
import org.apache.hadoop.fs.contract.AbstractFSContract;
import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
import java.io.IOException;
+import java.util.Collection;
/**
* Ozone contract tests for {@link org.apache.hadoop.fs.CanUnbuffer#unbuffer}.
*/
+@RunWith(Parameterized.class)
public class ITestOzoneContractUnbuffer extends AbstractContractUnbufferTest {
- @BeforeClass
- public static void createCluster() throws IOException {
- OzoneContract.createCluster();
+ private static boolean fsOptimizedServer;
+
+ public ITestOzoneContractUnbuffer(boolean fsoServer)
+ throws IOException {
+ if (fsOptimizedServer != fsoServer) {
+ setFsOptimizedServer(fsoServer);
+ ITestOzoneContractUtils.restartCluster(
+ fsOptimizedServer);
+ }
+ }
+
+ public static void setFsOptimizedServer(boolean fsOptimizedServer) {
+ ITestOzoneContractUnbuffer.fsOptimizedServer = fsOptimizedServer;
}
@AfterClass
@@ -44,4 +57,9 @@ public class ITestOzoneContractUnbuffer extends AbstractContractUnbufferTest {
protected AbstractFSContract createContract(Configuration conf) {
return new OzoneContract(conf);
}
+
+ @Parameterized.Parameters
+ public static Collection data() {
+ return ITestOzoneContractUtils.getFsoCombinations();
+ }
}
\ No newline at end of file
diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractUtils.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractUtils.java
new file mode 100644
index 0000000..1926bd2
--- /dev/null
+++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/ITestOzoneContractUtils.java
@@ -0,0 +1,60 @@
+/*
+ * 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.hadoop.fs.ozone.contract;
+
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Utility class for Ozone-contract tests.
+ */
+public final class ITestOzoneContractUtils {
+
+ private ITestOzoneContractUtils(){}
+
+ private static List<Object> fsoCombinations = Arrays.asList(new Object[] {
+ // FSO configuration is a cluster level server side configuration.
+ // If the cluster is configured with V0 layout version,
+ // V0 bucket will created.
+ // If the cluster is configured with V1 layout version,
+ // V1 bucket will be created.
+ // Presently, OzoneClient checks bucketMetadata then invokes V1 or V0
+ // specific code and it makes no sense to add client side configs now.
+ // Once the specific client API to set FSO or non-FSO bucket is provided
+ // the contract test can be refactored to include another parameter
+ // (fsoClient) which sets/unsets the client side configs.
+ true, // Server is configured with new layout (V1)
+ // and new buckets will be operated on
+ false // Server is configured with old layout (V0)
+ // and old buckets will be operated on
+ });
+
+ static List<Object> getFsoCombinations(){
+ return fsoCombinations;
+ }
+
+ public static void restartCluster(boolean fsOptimizedServer)
+ throws IOException {
+ OzoneContract.destroyCluster();
+ OzoneContract.initOzoneConfiguration(
+ fsOptimizedServer);
+ OzoneContract.createCluster();
+ }
+}
diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/OzoneContract.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/OzoneContract.java
index 104b10c..f401c06 100644
--- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/OzoneContract.java
+++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/contract/OzoneContract.java
@@ -46,6 +46,8 @@ class OzoneContract extends AbstractFSContract {
private static MiniOzoneCluster cluster;
private static final String CONTRACT_XML = "contract/ozone.xml";
+ private static boolean fsOptimizedServer;
+
OzoneContract(Configuration conf) {
super(conf);
//insert the base features
@@ -63,6 +65,10 @@ class OzoneContract extends AbstractFSContract {
return path;
}
+ public static void initOzoneConfiguration(boolean fsoServer){
+ fsOptimizedServer = fsoServer;
+ }
+
public static void createCluster() throws IOException {
OzoneConfiguration conf = new OzoneConfiguration();
DatanodeRatisServerConfig ratisServerConfig =
@@ -79,6 +85,13 @@ class OzoneContract extends AbstractFSContract {
conf.addResource(CONTRACT_XML);
+ if (fsOptimizedServer){
+ conf.setBoolean(OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS,
+ true);
+ conf.set(OMConfigKeys.OZONE_OM_LAYOUT_VERSION,
+ OMConfigKeys.OZONE_OM_LAYOUT_VERSION_V1);
+ }
+
cluster = MiniOzoneCluster.newBuilder(conf).setNumDatanodes(5).build();
try {
cluster.waitForClusterToBeReady();
diff --git a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneFileSystem.java b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneFileSystem.java
index d2b9a6d..1214a5c 100644
--- a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneFileSystem.java
+++ b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneFileSystem.java
@@ -414,9 +414,11 @@ public class BasicOzoneFileSystem extends FileSystem {
try {
adapter.renameKey(srcPath, dstPath);
} catch (OMException ome) {
- LOG.error("rename key failed: {}. source:{}, destin:{}",
- ome.getMessage(), srcPath, dstPath);
- if (OMException.ResultCodes.KEY_ALREADY_EXISTS == ome.getResult()) {
+ LOG.error("rename key failed: {}. Error code: {} source:{}, destin:{}",
+ ome.getMessage(), ome.getResult(), srcPath, dstPath);
+ if (OMException.ResultCodes.KEY_ALREADY_EXISTS == ome.getResult() ||
+ OMException.ResultCodes.KEY_RENAME_ERROR == ome.getResult() ||
+ OMException.ResultCodes.KEY_NOT_FOUND == ome.getResult()) {
return false;
} else {
throw ome;
@@ -508,6 +510,9 @@ public class BasicOzoneFileSystem extends FileSystem {
if (adapter.isFSOptimizedBucket()) {
if (f.isRoot()) {
+ if (!recursive && listStatus(f).length!=0){
+ throw new PathIsNotEmptyDirectoryException(f.toString());
+ }
LOG.warn("Cannot delete root directory.");
return false;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@ozone.apache.org
For additional commands, e-mail: commits-help@ozone.apache.org