This is an automated email from the ASF dual-hosted git repository.
sodonnell pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new 9aebf6e HDDS-5720. Reuse mini-clusters in TestOzoneFileInterfaces
(#2619)
9aebf6e is described below
commit 9aebf6e2583a17d3bbb62bbb429ae25930f505dc
Author: Stephen O'Donnell <[email protected]>
AuthorDate: Mon Sep 13 15:38:27 2021 +0100
HDDS-5720. Reuse mini-clusters in TestOzoneFileInterfaces (#2619)
---
.../hadoop/fs/ozone/TestOzoneFileInterfaces.java | 69 +++++++++++++++-------
.../fs/ozone/TestOzoneFileInterfacesWithFSO.java | 8 +--
.../request/key/TestOMKeyCreateRequestWithFSO.java | 2 -
3 files changed, 51 insertions(+), 28 deletions(-)
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileInterfaces.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileInterfaces.java
index 3d4fe2f..aace0fa 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileInterfaces.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileInterfaces.java
@@ -43,7 +43,6 @@ import org.apache.hadoop.ozone.MiniOzoneCluster;
import org.apache.hadoop.ozone.OzoneConfigKeys;
import org.apache.hadoop.ozone.OzoneConsts;
import org.apache.hadoop.ozone.TestDataUtil;
-import org.apache.hadoop.ozone.client.OzoneBucket;
import org.apache.hadoop.ozone.om.OMConfigKeys;
import org.apache.hadoop.ozone.om.OMMetadataManager;
import org.apache.hadoop.ozone.om.OMMetrics;
@@ -57,8 +56,8 @@ import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.RandomStringUtils;
import static org.apache.hadoop.fs.ozone.Constants.OZONE_DEFAULT_USER;
-import org.jetbrains.annotations.NotNull;
import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Assert;
import static org.junit.Assert.assertEquals;
@@ -103,11 +102,11 @@ public class TestOzoneFileInterfaces {
{true, false, false}});
}
- private boolean setDefaultFs;
+ private static boolean setDefaultFs;
- private boolean useAbsolutePath;
+ private static boolean useAbsolutePath;
- private MiniOzoneCluster cluster = null;
+ private static MiniOzoneCluster cluster = null;
private FileSystem fs;
@@ -121,32 +120,55 @@ public class TestOzoneFileInterfaces {
private OMMetrics omMetrics;
+ private static boolean enableFileSystemPaths;
+
@SuppressWarnings("checkstyle:VisibilityModifier")
- protected boolean enableFileSystemPaths;
+ protected boolean enableFileSystemPathsInstance;
public TestOzoneFileInterfaces(boolean setDefaultFs,
- boolean useAbsolutePath, boolean enabledFileSystemPaths) {
- this.setDefaultFs = setDefaultFs;
- this.useAbsolutePath = useAbsolutePath;
- this.enableFileSystemPaths = enabledFileSystemPaths;
+ boolean useAbsolutePath, boolean enabledFileSystemPaths)
+ throws Exception {
+ enableFileSystemPathsInstance = enabledFileSystemPaths;
+ if (this.setDefaultFs != setDefaultFs
+ || this.useAbsolutePath != useAbsolutePath
+ || this.enableFileSystemPaths != enabledFileSystemPaths) {
+ setParameters(setDefaultFs, useAbsolutePath, enabledFileSystemPaths);
+ teardown();
+ init();
+ }
GlobalStorageStatistics.INSTANCE.reset();
}
- @Before
- public void init() throws Exception {
- volumeName = RandomStringUtils.randomAlphabetic(10).toLowerCase();
- bucketName = RandomStringUtils.randomAlphabetic(10).toLowerCase();
+ private static void setParameters(boolean defaultFs,
+ boolean absolutePath,
+ boolean fileSystemPaths) {
+ setDefaultFs = defaultFs;
+ useAbsolutePath = absolutePath;
+ enableFileSystemPaths = fileSystemPaths;
+ }
- OzoneConfiguration conf = getOzoneConfiguration();
+ private static void setCluster(MiniOzoneCluster newCluster) {
+ cluster = newCluster;
+ }
- cluster = MiniOzoneCluster.newBuilder(conf)
+ public void init() throws Exception {
+ OzoneConfiguration conf = getOzoneConfiguration();
+ MiniOzoneCluster newCluster = MiniOzoneCluster.newBuilder(conf)
.setNumDatanodes(3)
.build();
- cluster.waitForClusterToBeReady();
+ newCluster.waitForClusterToBeReady();
+ setCluster(newCluster);
+ }
+
+ @Before
+ public void setupTest() throws Exception {
+ volumeName = RandomStringUtils.randomAlphabetic(10).toLowerCase();
+ bucketName = RandomStringUtils.randomAlphabetic(10).toLowerCase();
+
+ OzoneConfiguration conf = cluster.getConf();
// create a volume and a bucket to be used by OzoneFileSystem
- OzoneBucket bucket =
- TestDataUtil.createVolumeAndBucket(cluster, volumeName, bucketName);
+ TestDataUtil.createVolumeAndBucket(cluster, volumeName, bucketName);
rootPath = String
.format("%s://%s.%s/", OzoneConsts.OZONE_URI_SCHEME, bucketName,
@@ -163,7 +185,6 @@ public class TestOzoneFileInterfaces {
omMetrics = cluster.getOzoneManager().getMetrics();
}
- @NotNull
protected OzoneConfiguration getOzoneConfiguration() {
OzoneConfiguration conf = new OzoneConfiguration();
conf.setBoolean(OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS,
@@ -172,11 +193,15 @@ public class TestOzoneFileInterfaces {
}
@After
- public void teardown() throws IOException {
+ public void closeFs() throws IOException {
+ IOUtils.closeQuietly(fs);
+ }
+
+ @AfterClass
+ public static void teardown() throws IOException {
if (cluster != null) {
cluster.shutdown();
}
- IOUtils.closeQuietly(fs);
}
@Test
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileInterfacesWithFSO.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileInterfacesWithFSO.java
index 069154d..dcd4ffa 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileInterfacesWithFSO.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileInterfacesWithFSO.java
@@ -21,7 +21,6 @@ package org.apache.hadoop.fs.ozone;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.ozone.om.OMConfigKeys;
import org.apache.hadoop.ozone.om.request.TestOMRequestUtils;
-import org.jetbrains.annotations.NotNull;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -46,15 +45,16 @@ public class TestOzoneFileInterfacesWithFSO extends
TestOzoneFileInterfaces {
}
public TestOzoneFileInterfacesWithFSO(boolean setDefaultFs,
- boolean useAbsolutePath, boolean enabledFileSystemPaths) {
+ boolean useAbsolutePath, boolean enabledFileSystemPaths)
+ throws Exception {
super(setDefaultFs, useAbsolutePath, enabledFileSystemPaths);
}
- @NotNull
@Override
protected OzoneConfiguration getOzoneConfiguration() {
OzoneConfiguration conf = new OzoneConfiguration();
- TestOMRequestUtils.configureFSOptimizedPaths(conf, enableFileSystemPaths,
+ TestOMRequestUtils.configureFSOptimizedPaths(conf,
+ enableFileSystemPathsInstance,
OMConfigKeys.OZONE_OM_METADATA_LAYOUT_PREFIX);
return conf;
}
diff --git
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/key/TestOMKeyCreateRequestWithFSO.java
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/key/TestOMKeyCreateRequestWithFSO.java
index fd6c5d2..978525b 100644
---
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/key/TestOMKeyCreateRequestWithFSO.java
+++
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/key/TestOMKeyCreateRequestWithFSO.java
@@ -29,7 +29,6 @@ import
org.apache.hadoop.ozone.om.ratis.utils.OzoneManagerRatisUtils;
import org.apache.hadoop.ozone.om.request.TestOMRequestUtils;
import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest;
import org.apache.hadoop.util.Time;
-import org.jetbrains.annotations.NotNull;
import org.junit.Assert;
import java.io.IOException;
@@ -42,7 +41,6 @@ import java.util.Iterator;
*/
public class TestOMKeyCreateRequestWithFSO extends TestOMKeyCreateRequest {
- @NotNull
@Override
protected OzoneConfiguration getOzoneConfiguration() {
OzoneConfiguration config = super.getOzoneConfiguration();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]