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 ar...@apache.org on 2016/05/20 22:20:10 UTC
hadoop git commit: HDFS-10420. Fix Ozone unit tests to use
MiniOzoneCluster. Contributed by Arpit Agarwal.
Repository: hadoop
Updated Branches:
refs/heads/HDFS-7240 76279f587 -> 54f7975df
HDFS-10420. Fix Ozone unit tests to use MiniOzoneCluster. Contributed by Arpit Agarwal.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/54f7975d
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/54f7975d
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/54f7975d
Branch: refs/heads/HDFS-7240
Commit: 54f7975dfce8e27e8444fad879af51ab7b1704f4
Parents: 76279f5
Author: Arpit Agarwal <ar...@apache.org>
Authored: Fri May 20 15:19:09 2016 -0700
Committer: Arpit Agarwal <ar...@apache.org>
Committed: Fri May 20 15:19:09 2016 -0700
----------------------------------------------------------------------
.../apache/hadoop/ozone/OzoneClientUtils.java | 4 +-
.../impl/ContainerLocationManagerImpl.java | 7 +-
.../common/impl/ContainerManagerImpl.java | 7 +-
.../common/interfaces/ContainerManager.java | 4 +-
.../container/ozoneimpl/OzoneContainer.java | 12 +-
.../ozone/storage/StorageContainerManager.java | 4 +-
.../apache/hadoop/ozone/MiniOzoneCluster.java | 60 +++++---
.../ozone/TestStorageContainerManager.java | 141 +++++++++++++++++++
.../common/impl/TestContainerPersistence.java | 39 ++---
.../container/ozoneimpl/TestOzoneContainer.java | 32 ++---
.../storage/TestStorageContainerManager.java | 135 ------------------
.../ozone/web/TestOzoneRestWithMiniCluster.java | 14 +-
.../hadoop/ozone/web/TestOzoneVolumes.java | 23 +--
.../hadoop/ozone/web/TestOzoneWebAccess.java | 48 +++----
.../hadoop/ozone/web/client/TestBuckets.java | 21 +--
.../hadoop/ozone/web/client/TestKeys.java | 30 ++--
.../hadoop/ozone/web/client/TestVolume.java | 18 +--
17 files changed, 320 insertions(+), 279 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/54f7975d/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/OzoneClientUtils.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/OzoneClientUtils.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/OzoneClientUtils.java
index 413bdbe..80a2d33 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/OzoneClientUtils.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/OzoneClientUtils.java
@@ -110,8 +110,10 @@ public final class OzoneClientUtils {
final Optional<Integer> port = getPortNumberFromConfigKeys(conf,
OZONE_SCM_DATANODE_ADDRESS_KEY);
- return NetUtils.createSocketAddr(host.get() + ":" +
+ InetSocketAddress addr = NetUtils.createSocketAddr(host.get() + ":" +
port.or(OZONE_SCM_DATANODE_PORT_DEFAULT));
+
+ return addr;
}
/**
http://git-wip-us.apache.org/repos/asf/hadoop/blob/54f7975d/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerLocationManagerImpl.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerLocationManagerImpl.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerLocationManagerImpl.java
index f367630..deb35f2 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerLocationManagerImpl.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerLocationManagerImpl.java
@@ -49,7 +49,7 @@ public class ContainerLocationManagerImpl implements ContainerLocationManager {
private final Configuration conf;
- private final FsDatasetSpi dataset;
+ private final FsDatasetSpi<? extends FsVolumeSpi> dataset;
private final Path[] volumePaths;
private int currentIndex;
private final List<Path> locations;
@@ -59,8 +59,9 @@ public class ContainerLocationManagerImpl implements ContainerLocationManager {
* Constructs a Location Manager.
* @param conf - Configuration.
*/
- public ContainerLocationManagerImpl(Configuration conf, List<Path> locations,
- FsDatasetSpi dataset) throws IOException {
+ public ContainerLocationManagerImpl(
+ Configuration conf, List<Path> locations,
+ FsDatasetSpi<? extends FsVolumeSpi> dataset) throws IOException {
this.conf = conf;
this.dataset = dataset;
List<Path> pathList = new LinkedList<>();
http://git-wip-us.apache.org/repos/asf/hadoop/blob/54f7975d/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerManagerImpl.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerManagerImpl.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerManagerImpl.java
index b920d8e..0a9e22a 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerManagerImpl.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerManagerImpl.java
@@ -25,6 +25,7 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileAlreadyExistsException;
import org.apache.hadoop.hdfs.ozone.protocol.proto.ContainerProtos;
import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi;
+import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsVolumeSpi;
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.ozone.OzoneConsts;
import org.apache.hadoop.ozone.container.common.helpers.ContainerData;
@@ -83,9 +84,9 @@ public class ContainerManagerImpl implements ContainerManager {
* @throws IOException
*/
@Override
- public void init(Configuration config, List<Path> containerDirs,
- FsDatasetSpi dataset)
- throws IOException {
+ public void init(
+ Configuration config, List<Path> containerDirs,
+ FsDatasetSpi<? extends FsVolumeSpi> dataset) throws IOException {
Preconditions.checkNotNull(config);
Preconditions.checkNotNull(containerDirs);
http://git-wip-us.apache.org/repos/asf/hadoop/blob/54f7975d/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/interfaces/ContainerManager.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/interfaces/ContainerManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/interfaces/ContainerManager.java
index fb2fec5..5602920 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/interfaces/ContainerManager.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/common/interfaces/ContainerManager.java
@@ -22,6 +22,7 @@ import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi;
+import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsVolumeSpi;
import org.apache.hadoop.hdfs.util.RwLock;
import org.apache.hadoop.ozone.container.common.helpers.ContainerData;
import org.apache.hadoop.ozone.container.common.helpers.Pipeline;
@@ -42,11 +43,10 @@ public interface ContainerManager extends RwLock {
*
* @param config - Configuration.
* @param containerDirs - List of Metadata Container locations.
- * @param dataset - FSDataset.
* @throws IOException
*/
void init(Configuration config, List<Path> containerDirs,
- FsDatasetSpi dataset)
+ FsDatasetSpi<? extends FsVolumeSpi> dataset)
throws IOException;
/**
http://git-wip-us.apache.org/repos/asf/hadoop/blob/54f7975d/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/ozoneimpl/OzoneContainer.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/ozoneimpl/OzoneContainer.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/ozoneimpl/OzoneContainer.java
index d62d0f1..fc3e0cf 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/ozoneimpl/OzoneContainer.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/container/ozoneimpl/OzoneContainer.java
@@ -48,7 +48,7 @@ public class OzoneContainer {
LoggerFactory.getLogger(OzoneContainer.class);
private final Configuration ozoneConfig;
- private final FsDatasetSpi dataSet;
+ private final FsDatasetSpi<? extends FsVolumeSpi> dataSet;
private final ContainerDispatcher dispatcher;
private final ContainerManager manager;
private final XceiverServer server;
@@ -62,8 +62,9 @@ public class OzoneContainer {
* @param dataSet - FsDataset.
* @throws IOException
*/
- public OzoneContainer(Configuration ozoneConfig, FsDatasetSpi dataSet) throws
- Exception {
+ public OzoneContainer(
+ Configuration ozoneConfig,
+ FsDatasetSpi<? extends FsVolumeSpi> dataSet) throws Exception {
List<Path> locations = new LinkedList<>();
String[] paths = ozoneConfig.getStrings(OzoneConfigKeys
.OZONE_METADATA_DIRS);
@@ -150,8 +151,9 @@ public class OzoneContainer {
* @param pathList - List of paths.
* @throws IOException
*/
- private void getDataDir(FsDatasetSpi dataset, List<Path> pathList) throws
- IOException {
+ private void getDataDir(
+ FsDatasetSpi<? extends FsVolumeSpi> dataset,
+ List<Path> pathList) throws IOException {
FsDatasetSpi.FsVolumeReferences references;
try {
synchronized (dataset) {
http://git-wip-us.apache.org/repos/asf/hadoop/blob/54f7975d/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/storage/StorageContainerManager.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/storage/StorageContainerManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/storage/StorageContainerManager.java
index 2fdb783..1d18b5b 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/storage/StorageContainerManager.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/storage/StorageContainerManager.java
@@ -155,7 +155,7 @@ public class StorageContainerManager
DatanodeProtocolPB.class, dnProtoPbService, handlerCount);
datanodeRpcAddress = updateListenAddress(conf,
OZONE_SCM_DATANODE_ADDRESS_KEY, datanodeRpcAddr, datanodeRpcServer);
- LOG.info(buildRpcServerStartMessage("Service RPC server",
+ LOG.info(buildRpcServerStartMessage("RPC server for DataNodes",
datanodeRpcAddress));
BlockingService storageProtoPbService =
@@ -522,7 +522,7 @@ public class StorageContainerManager
InetSocketAddress updatedAddr = new InetSocketAddress(
addr.getHostString(), listenAddr.getPort());
conf.set(rpcAddressKey,
- addr.getHostString() + ":" + listenAddr.getPort());
+ addr.getHostString() + ":" + updatedAddr.getPort());
return updatedAddr;
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/54f7975d/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/MiniOzoneCluster.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/MiniOzoneCluster.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/MiniOzoneCluster.java
index 2bcc38b..1107a76 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/MiniOzoneCluster.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/MiniOzoneCluster.java
@@ -22,9 +22,14 @@ import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.URISyntaxException;
import java.util.Random;
+import java.util.concurrent.TimeoutException;
+import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
+import com.google.common.base.Supplier;
+import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
+import org.apache.hadoop.test.GenericTestUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -41,7 +46,6 @@ import org.apache.hadoop.ozone.storage.StorageContainerManager;
import org.apache.hadoop.ozone.web.client.OzoneClient;
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
import org.apache.hadoop.security.UserGroupInformation;
-import org.apache.hadoop.util.Time;
/**
* MiniOzoneCluster creates a complete in-process Ozone cluster suitable for
@@ -82,6 +86,7 @@ public class MiniOzoneCluster extends MiniDFSCluster implements Closeable {
extends org.apache.hadoop.hdfs.MiniDFSCluster.Builder {
private final OzoneConfiguration conf;
+ private Optional<String> ozoneHandlerType = Optional.absent();
/**
* Creates a new Builder.
@@ -100,13 +105,35 @@ public class MiniOzoneCluster extends MiniDFSCluster implements Closeable {
return this;
}
+ public Builder setHandlerType(String handler) {
+ ozoneHandlerType = Optional.of(handler);
+ return this;
+ }
+
@Override
public MiniOzoneCluster build() throws IOException {
+ if (!ozoneHandlerType.isPresent()) {
+ throw new IllegalArgumentException(
+ "The Ozone handler type must be specified.");
+ }
+
+ conf.setBoolean(OzoneConfigKeys.OZONE_ENABLED, true);
+ conf.setBoolean(OzoneConfigKeys.OZONE_TRACE_ENABLED_KEY, true);
+ conf.set(OzoneConfigKeys.OZONE_HANDLER_TYPE_KEY, ozoneHandlerType.get());
conf.set(OzoneConfigKeys.OZONE_SCM_CLIENT_ADDRESS_KEY, "127.0.0.1:0");
conf.set(OzoneConfigKeys.OZONE_SCM_DATANODE_ADDRESS_KEY, "127.0.0.1:0");
StorageContainerManager scm = new StorageContainerManager(conf);
scm.start();
- return new MiniOzoneCluster(this, scm);
+ MiniOzoneCluster cluster = new MiniOzoneCluster(this, scm);
+ try {
+ cluster.waitOzoneReady();
+ } catch(Exception e) {
+ // A workaround to propagate MiniOzoneCluster failures without
+ // changing the method signature (which would require cascading
+ // changes to hundreds of unrelated HDFS tests).
+ throw new IOException("Failed to start MiniOzoneCluster", e);
+ }
+ return cluster;
}
}
@@ -176,22 +203,19 @@ public class MiniOzoneCluster extends MiniDFSCluster implements Closeable {
/**
* Waits for the Ozone cluster to be ready for processing requests.
*/
- public void waitOzoneReady() {
- long begin = Time.monotonicNow();
- while (scm.getDatanodeReport(DatanodeReportType.LIVE).length <
- numDataNodes) {
- if (Time.monotonicNow() - begin > 20000) {
- throw new IllegalStateException(
- "Timed out waiting for Ozone cluster to become ready.");
+ public void waitOzoneReady() throws TimeoutException, InterruptedException {
+ GenericTestUtils.waitFor(new Supplier<Boolean>() {
+ @Override
+ public Boolean get() {
+ final DatanodeInfo[] reports =
+ scm.getDatanodeReport(DatanodeReportType.LIVE);
+ if (reports.length >= numDataNodes) {
+ return true;
+ }
+ LOG.info("Waiting for cluster to be ready. Got {} of {} DN reports.",
+ reports.length, numDataNodes);
+ return false;
}
- LOG.info("Waiting for Ozone cluster to become ready");
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- throw new IllegalStateException(
- "Interrupted while waiting for Ozone cluster to become ready.");
- }
- }
+ }, 100, 45000);
}
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/54f7975d/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/TestStorageContainerManager.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/TestStorageContainerManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/TestStorageContainerManager.java
new file mode 100644
index 0000000..7498656
--- /dev/null
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/TestStorageContainerManager.java
@@ -0,0 +1,141 @@
+/**
+ * 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.ozone;
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import org.junit.After;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import org.apache.hadoop.io.IOUtils;
+import org.apache.hadoop.ozone.protocol.LocatedContainer;
+import org.apache.hadoop.ozone.protocolPB.StorageContainerLocationProtocolClientSideTranslatorPB;
+import org.junit.rules.Timeout;
+
+/**
+ * Test class that exercises the StorageContainerManager.
+ */
+public class TestStorageContainerManager {
+ /**
+ * Set the timeout for every test.
+ */
+ @Rule
+ public Timeout testTimeout = new Timeout(300000);
+
+ private static MiniOzoneCluster cluster;
+ private static OzoneConfiguration conf;
+ private static StorageContainerLocationProtocolClientSideTranslatorPB
+ storageContainerLocationClient;
+
+ @Rule
+ public ExpectedException exception = ExpectedException.none();
+
+ @BeforeClass
+ public static void init() throws IOException {
+ conf = new OzoneConfiguration();
+ }
+
+ @After
+ public void shutdown() throws InterruptedException {
+ IOUtils.cleanup(null, storageContainerLocationClient, cluster);
+ }
+
+ @Test
+ public void testLocationsForSingleKey() throws Exception {
+ cluster = new MiniOzoneCluster.Builder(conf).numDataNodes(1)
+ .setHandlerType("distributed").build();
+ storageContainerLocationClient =
+ cluster.createStorageContainerLocationClient();
+ Set<LocatedContainer> containers =
+ storageContainerLocationClient.getStorageContainerLocations(
+ new LinkedHashSet<>(Arrays.asList("/key1")));
+ assertNotNull(containers);
+ assertEquals(1, containers.size());
+ assertLocatedContainer(containers, "/key1", 1);
+ }
+
+ @Test
+ public void testLocationsForMultipleKeys() throws Exception {
+ cluster = new MiniOzoneCluster.Builder(conf).numDataNodes(1)
+ .setHandlerType("distributed").build();
+ storageContainerLocationClient =
+ cluster.createStorageContainerLocationClient();
+ Set<LocatedContainer> containers =
+ storageContainerLocationClient.getStorageContainerLocations(
+ new LinkedHashSet<>(Arrays.asList("/key1", "/key2", "/key3")));
+ assertNotNull(containers);
+ assertEquals(3, containers.size());
+ assertLocatedContainer(containers, "/key1", 1);
+ assertLocatedContainer(containers, "/key2", 1);
+ assertLocatedContainer(containers, "/key3", 1);
+ }
+
+ @Test
+ public void testNoDataNodes() throws Exception {
+ cluster = new MiniOzoneCluster.Builder(conf).numDataNodes(0)
+ .setHandlerType("distributed").build();
+ storageContainerLocationClient =
+ cluster.createStorageContainerLocationClient();
+ exception.expect(IOException.class);
+ exception.expectMessage("locations not found");
+ storageContainerLocationClient.getStorageContainerLocations(
+ new LinkedHashSet<>(Arrays.asList("/key1")));
+ }
+
+ @Test
+ public void testMultipleDataNodes() throws Exception {
+ cluster = new MiniOzoneCluster.Builder(conf).numDataNodes(3)
+ .setHandlerType("distributed").build();
+ storageContainerLocationClient =
+ cluster.createStorageContainerLocationClient();
+ Set<LocatedContainer> containers =
+ storageContainerLocationClient.getStorageContainerLocations(
+ new LinkedHashSet<>(Arrays.asList("/key1")));
+ assertNotNull(containers);
+ assertEquals(1, containers.size());
+ assertLocatedContainer(containers, "/key1", 3);
+ }
+
+ private static void assertLocatedContainer(Set<LocatedContainer> containers,
+ String key, int expectedNumLocations) {
+ LocatedContainer container = null;
+ for (LocatedContainer curContainer: containers) {
+ if (key.equals(curContainer.getKey())) {
+ container = curContainer;
+ break;
+ }
+ }
+ assertNotNull("Container for key " + key + " not found.", container);
+ assertEquals(key, container.getKey());
+ assertNotNull(container.getMatchedKeyPrefix());
+ assertFalse(container.getMatchedKeyPrefix().isEmpty());
+ assertNotNull(container.getContainerName());
+ assertFalse(container.getContainerName().isEmpty());
+ assertNotNull(container.getLocations());
+ assertEquals(expectedNumLocations, container.getLocations().size());
+ assertNotNull(container.getLeader());
+ }
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/54f7975d/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/container/common/impl/TestContainerPersistence.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/container/common/impl/TestContainerPersistence.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/container/common/impl/TestContainerPersistence.java
index 349889d..3cb91d7 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/container/common/impl/TestContainerPersistence.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/container/common/impl/TestContainerPersistence.java
@@ -20,9 +20,10 @@ package org.apache.hadoop.ozone.container.common.impl;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.io.FileUtils;
-import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.hadoop.hdfs.ozone.protocol.proto.ContainerProtos;
import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi;
+import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsVolumeSpi;
+import org.apache.hadoop.ozone.MiniOzoneCluster;
import org.apache.hadoop.ozone.OzoneConfigKeys;
import org.apache.hadoop.ozone.OzoneConfiguration;
import org.apache.hadoop.ozone.OzoneConsts;
@@ -41,6 +42,7 @@ import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.junit.rules.Timeout;
import java.io.File;
import java.io.IOException;
@@ -69,21 +71,26 @@ import static org.junit.Assert.fail;
* Simple tests to verify that container persistence works as expected.
*/
public class TestContainerPersistence {
-
- static String path;
- static ContainerManagerImpl containerManager;
- static ChunkManagerImpl chunkManager;
- static KeyManagerImpl keyManager;
- static OzoneConfiguration conf;
- static FsDatasetSpi fsDataSet;
- static MiniDFSCluster cluster;
- static List<Path> pathLists = new LinkedList<>();
-
@Rule
public ExpectedException exception = ExpectedException.none();
+ /**
+ * Set the timeout for every test.
+ */
+ @Rule
+ public Timeout testTimeout = new Timeout(300000);
+
+ private static String path;
+ private static ContainerManagerImpl containerManager;
+ private static ChunkManagerImpl chunkManager;
+ private static KeyManagerImpl keyManager;
+ private static OzoneConfiguration conf;
+ private static FsDatasetSpi<? extends FsVolumeSpi> fsDataSet;
+ private static MiniOzoneCluster cluster;
+ private static List<Path> pathLists = new LinkedList<>();
+
@BeforeClass
- public static void init() throws IOException {
+ public static void init() throws Throwable {
conf = new OzoneConfiguration();
URL p = conf.getClass().getResource("");
path = p.getPath().concat(
@@ -91,8 +98,6 @@ public class TestContainerPersistence {
path += conf.getTrimmed(OzoneConfigKeys.OZONE_LOCALSTORAGE_ROOT,
OzoneConfigKeys.OZONE_LOCALSTORAGE_ROOT_DEFAULT);
conf.set(OzoneConfigKeys.OZONE_LOCALSTORAGE_ROOT, path);
- conf.setBoolean(OzoneConfigKeys.OZONE_ENABLED, true);
- conf.set(OzoneConfigKeys.OZONE_HANDLER_TYPE_KEY, "local");
File containerDir = new File(path);
if (containerDir.exists()) {
@@ -101,8 +106,8 @@ public class TestContainerPersistence {
Assert.assertTrue(containerDir.mkdirs());
- cluster = new MiniDFSCluster.Builder(conf).build();
- cluster.waitActive();
+ cluster = new MiniOzoneCluster.Builder(conf)
+ .setHandlerType("local").build();
fsDataSet = cluster.getDataNodes().get(0).getFSDataset();
containerManager = new ContainerManagerImpl();
chunkManager = new ChunkManagerImpl(containerManager);
@@ -601,4 +606,4 @@ public class TestContainerPersistence {
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/54f7975d/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/container/ozoneimpl/TestOzoneContainer.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/container/ozoneimpl/TestOzoneContainer.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/container/ozoneimpl/TestOzoneContainer.java
index 3a06669..306a2f3 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/container/ozoneimpl/TestOzoneContainer.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/container/ozoneimpl/TestOzoneContainer.java
@@ -17,10 +17,8 @@
*/
package org.apache.hadoop.ozone.container.ozoneimpl;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.hadoop.hdfs.ozone.protocol.proto.ContainerProtos;
+import org.apache.hadoop.ozone.MiniOzoneCluster;
import org.apache.hadoop.ozone.OzoneConfigKeys;
import org.apache.hadoop.ozone.OzoneConfiguration;
import org.apache.hadoop.ozone.container.ContainerTestHelper;
@@ -28,15 +26,23 @@ import org.apache.hadoop.ozone.container.common.helpers.Pipeline;
import org.apache.hadoop.ozone.container.common.transport.client.XceiverClient;
import org.apache.hadoop.ozone.web.utils.OzoneUtils;
import org.junit.Assert;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.Timeout;
import java.net.URL;
public class TestOzoneContainer {
+ /**
+ * Set the timeout for every test.
+ */
+ @Rule
+ public Timeout testTimeout = new Timeout(300000);
+
@Test
public void testCreateOzoneContainer() throws Exception {
String containerName = OzoneUtils.getRequestID();
- Configuration conf = new OzoneConfiguration();
+ OzoneConfiguration conf = new OzoneConfiguration();
URL p = conf.getClass().getResource("");
String path = p.getPath().concat(
TestOzoneContainer.class.getSimpleName());
@@ -44,15 +50,11 @@ public class TestOzoneContainer {
OzoneConfigKeys.OZONE_LOCALSTORAGE_ROOT_DEFAULT);
conf.set(OzoneConfigKeys.OZONE_LOCALSTORAGE_ROOT, path);
+ MiniOzoneCluster cluster = new MiniOzoneCluster.Builder(conf)
+ .setHandlerType("local").build();
+
// We don't start Ozone Container via data node, we will do it
// independently in our test path.
- conf.setBoolean(OzoneConfigKeys.OZONE_ENABLED, false);
- conf.set(OzoneConfigKeys.OZONE_HANDLER_TYPE_KEY, "local");
-
- MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).build();
- cluster.waitActive();
-
-
Pipeline pipeline = ContainerTestHelper.createSingleNodePipeline
(containerName);
conf.setInt(OzoneConfigKeys.DFS_CONTAINER_IPC_PORT,
@@ -78,7 +80,7 @@ public class TestOzoneContainer {
public void testOzoneContainerViaDataNode() throws Exception {
String keyName = OzoneUtils.getRequestID();
String containerName = OzoneUtils.getRequestID();
- Configuration conf = new OzoneConfiguration();
+ OzoneConfiguration conf = new OzoneConfiguration();
URL p = conf.getClass().getResource("");
String path = p.getPath().concat(
TestOzoneContainer.class.getSimpleName());
@@ -87,16 +89,14 @@ public class TestOzoneContainer {
conf.set(OzoneConfigKeys.OZONE_LOCALSTORAGE_ROOT, path);
// Start ozone container Via Datanode create.
- conf.setBoolean(OzoneConfigKeys.OZONE_ENABLED, true);
- conf.set(OzoneConfigKeys.OZONE_HANDLER_TYPE_KEY, "local");
Pipeline pipeline =
ContainerTestHelper.createSingleNodePipeline(containerName);
conf.setInt(OzoneConfigKeys.DFS_CONTAINER_IPC_PORT,
pipeline.getLeader().getContainerPort());
- MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).build();
- cluster.waitActive();
+ MiniOzoneCluster cluster = new MiniOzoneCluster.Builder(conf)
+ .setHandlerType("local").build();
// This client talks to ozone container via datanode.
XceiverClient client = new XceiverClient(pipeline, conf);
http://git-wip-us.apache.org/repos/asf/hadoop/blob/54f7975d/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/storage/TestStorageContainerManager.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/storage/TestStorageContainerManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/storage/TestStorageContainerManager.java
deleted file mode 100644
index 5867092..0000000
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/storage/TestStorageContainerManager.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/**
- * 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.ozone;
-
-import static org.junit.Assert.*;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-import org.junit.After;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
-import org.apache.hadoop.io.IOUtils;
-import org.apache.hadoop.ozone.protocol.LocatedContainer;
-import org.apache.hadoop.ozone.protocolPB.StorageContainerLocationProtocolClientSideTranslatorPB;
-
-public class TestStorageContainerManager {
-
- private static MiniOzoneCluster cluster;
- private static OzoneConfiguration conf;
- private static StorageContainerLocationProtocolClientSideTranslatorPB
- storageContainerLocationClient;
-
- @Rule
- public ExpectedException exception = ExpectedException.none();
-
- @BeforeClass
- public static void init() throws IOException {
- conf = new OzoneConfiguration();
- conf.setBoolean(OzoneConfigKeys.OZONE_ENABLED, true);
- conf.set(OzoneConfigKeys.OZONE_HANDLER_TYPE_KEY, "distributed");
- conf.setBoolean(OzoneConfigKeys.OZONE_TRACE_ENABLED_KEY, true);
- }
-
- @After
- public void shutdown() throws InterruptedException {
- IOUtils.cleanup(null, storageContainerLocationClient, cluster);
- }
-
- @Test
- public void testLocationsForSingleKey() throws IOException {
- cluster = new MiniOzoneCluster.Builder(conf).numDataNodes(1).build();
- cluster.waitOzoneReady();
- storageContainerLocationClient =
- cluster.createStorageContainerLocationClient();
- Set<LocatedContainer> containers =
- storageContainerLocationClient.getStorageContainerLocations(
- new LinkedHashSet<>(Arrays.asList("/key1")));
- assertNotNull(containers);
- assertEquals(1, containers.size());
- assertLocatedContainer(containers, "/key1", 1);
- }
-
- @Test
- public void testLocationsForMultipleKeys() throws IOException {
- cluster = new MiniOzoneCluster.Builder(conf).numDataNodes(1).build();
- cluster.waitOzoneReady();
- storageContainerLocationClient =
- cluster.createStorageContainerLocationClient();
- Set<LocatedContainer> containers =
- storageContainerLocationClient.getStorageContainerLocations(
- new LinkedHashSet<>(Arrays.asList("/key1", "/key2", "/key3")));
- assertNotNull(containers);
- assertEquals(3, containers.size());
- assertLocatedContainer(containers, "/key1", 1);
- assertLocatedContainer(containers, "/key2", 1);
- assertLocatedContainer(containers, "/key3", 1);
- }
-
- @Test
- public void testNoDataNodes() throws IOException {
- cluster = new MiniOzoneCluster.Builder(conf).numDataNodes(0).build();
- cluster.waitOzoneReady();
- storageContainerLocationClient =
- cluster.createStorageContainerLocationClient();
- exception.expect(IOException.class);
- exception.expectMessage("locations not found");
- storageContainerLocationClient.getStorageContainerLocations(
- new LinkedHashSet<>(Arrays.asList("/key1")));
- }
-
- @Test
- public void testMultipleDataNodes() throws IOException {
- cluster = new MiniOzoneCluster.Builder(conf).numDataNodes(3).build();
- cluster.waitOzoneReady();
- storageContainerLocationClient =
- cluster.createStorageContainerLocationClient();
- Set<LocatedContainer> containers =
- storageContainerLocationClient.getStorageContainerLocations(
- new LinkedHashSet<>(Arrays.asList("/key1")));
- assertNotNull(containers);
- assertEquals(1, containers.size());
- assertLocatedContainer(containers, "/key1", 3);
- }
-
- private static void assertLocatedContainer(Set<LocatedContainer> containers,
- String key, int expectedNumLocations) {
- LocatedContainer container = null;
- for (LocatedContainer curContainer: containers) {
- if (key.equals(curContainer.getKey())) {
- container = curContainer;
- break;
- }
- }
- assertNotNull("Container for key " + key + " not found.", container);
- assertEquals(key, container.getKey());
- assertNotNull(container.getMatchedKeyPrefix());
- assertFalse(container.getMatchedKeyPrefix().isEmpty());
- assertNotNull(container.getContainerName());
- assertFalse(container.getContainerName().isEmpty());
- assertNotNull(container.getLocations());
- assertEquals(expectedNumLocations, container.getLocations().size());
- assertNotNull(container.getLeader());
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/54f7975d/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/web/TestOzoneRestWithMiniCluster.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/web/TestOzoneRestWithMiniCluster.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/web/TestOzoneRestWithMiniCluster.java
index 827daef..7d96bff 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/web/TestOzoneRestWithMiniCluster.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/web/TestOzoneRestWithMiniCluster.java
@@ -31,17 +31,22 @@ import org.junit.rules.ExpectedException;
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.ozone.MiniOzoneCluster;
-import org.apache.hadoop.ozone.OzoneConfigKeys;
import org.apache.hadoop.ozone.OzoneConfiguration;
import org.apache.hadoop.ozone.web.client.OzoneBucket;
import org.apache.hadoop.ozone.web.client.OzoneClient;
import org.apache.hadoop.ozone.web.client.OzoneVolume;
import org.apache.hadoop.ozone.web.request.OzoneQuota;
+import org.junit.rules.Timeout;
/**
* End-to-end testing of Ozone REST operations.
*/
public class TestOzoneRestWithMiniCluster {
+ /**
+ * Set the timeout for every test.
+ */
+ @Rule
+ public Timeout testTimeout = new Timeout(300000);
private static MiniOzoneCluster cluster;
private static OzoneConfiguration conf;
@@ -54,11 +59,8 @@ public class TestOzoneRestWithMiniCluster {
@BeforeClass
public static void init() throws Exception {
conf = new OzoneConfiguration();
- conf.setBoolean(OzoneConfigKeys.OZONE_ENABLED, true);
- conf.set(OzoneConfigKeys.OZONE_HANDLER_TYPE_KEY, "distributed");
- conf.setBoolean(OzoneConfigKeys.OZONE_TRACE_ENABLED_KEY, true);
- cluster = new MiniOzoneCluster.Builder(conf).numDataNodes(3).build();
- cluster.waitOzoneReady();
+ cluster = new MiniOzoneCluster.Builder(conf).numDataNodes(3)
+ .setHandlerType("distributed").build();
ozoneClient = cluster.createOzoneClient();
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/54f7975d/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/web/TestOzoneVolumes.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/web/TestOzoneVolumes.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/web/TestOzoneVolumes.java
index 73991ad..afe22df 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/web/TestOzoneVolumes.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/web/TestOzoneVolumes.java
@@ -17,8 +17,8 @@
*/
package org.apache.hadoop.ozone.web;
-import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.hadoop.hdfs.server.datanode.DataNode;
+import org.apache.hadoop.ozone.MiniOzoneCluster;
import org.apache.hadoop.ozone.OzoneConfigKeys;
import org.apache.hadoop.ozone.OzoneConfiguration;
import org.apache.hadoop.ozone.web.exceptions.ErrorTable;
@@ -35,7 +35,9 @@ import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.Timeout;
import javax.ws.rs.core.HttpHeaders;
import java.io.IOException;
@@ -49,8 +51,14 @@ import static java.net.HttpURLConnection.HTTP_OK;
import static org.junit.Assert.assertEquals;
public class TestOzoneVolumes {
- static MiniDFSCluster cluster = null;
- static int port = 0;
+ /**
+ * Set the timeout for every test.
+ */
+ @Rule
+ public Timeout testTimeout = new Timeout(300000);
+
+ private static MiniOzoneCluster cluster = null;
+ private static int port = 0;
/**
* Create a MiniDFSCluster for testing.
@@ -62,7 +70,7 @@ public class TestOzoneVolumes {
* @throws IOException
*/
@BeforeClass
- public static void init() throws IOException {
+ public static void init() throws Exception {
OzoneConfiguration conf = new OzoneConfiguration();
URL p = conf.getClass().getResource("");
@@ -71,13 +79,10 @@ public class TestOzoneVolumes {
OzoneConfigKeys.OZONE_LOCALSTORAGE_ROOT_DEFAULT);
conf.set(OzoneConfigKeys.OZONE_LOCALSTORAGE_ROOT, path);
- conf.setBoolean(OzoneConfigKeys.OZONE_ENABLED, true);
- conf.set(OzoneConfigKeys.OZONE_HANDLER_TYPE_KEY, "local");
- conf.setBoolean(OzoneConfigKeys.OZONE_TRACE_ENABLED_KEY, true);
Logger.getLogger("log4j.logger.org.apache.http").setLevel(Level.DEBUG);
- cluster = new MiniDFSCluster.Builder(conf).build();
- cluster.waitActive();
+ cluster = new MiniOzoneCluster.Builder(conf)
+ .setHandlerType("local").build();
DataNode dataNode = cluster.getDataNodes().get(0);
port = dataNode.getInfoPort();
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/54f7975d/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/web/TestOzoneWebAccess.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/web/TestOzoneWebAccess.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/web/TestOzoneWebAccess.java
index 368ab3d..ac5b3e4 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/web/TestOzoneWebAccess.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/web/TestOzoneWebAccess.java
@@ -18,43 +18,43 @@
package org.apache.hadoop.ozone.web;
-import static java.net.HttpURLConnection.HTTP_CREATED;
-import static org.apache.hadoop.ozone.web.utils.OzoneUtils.*;
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-import java.net.URL;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-import javax.ws.rs.core.HttpHeaders;
-
-import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.hadoop.hdfs.server.datanode.DataNode;
+import org.apache.hadoop.ozone.MiniOzoneCluster;
import org.apache.hadoop.ozone.OzoneConfigKeys;
import org.apache.hadoop.ozone.OzoneConfiguration;
-import org.apache.hadoop.ozone.web.headers.Header;
import org.apache.hadoop.ozone.OzoneConsts;
+import org.apache.hadoop.ozone.web.headers.Header;
import org.apache.hadoop.util.Time;
-
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
-
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.Timeout;
-public class TestOzoneWebAccess {
+import javax.ws.rs.core.HttpHeaders;
+import java.io.IOException;
+import java.net.URL;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
- private static MiniDFSCluster cluster;
- private static int port;
+import static java.net.HttpURLConnection.HTTP_CREATED;
+import static org.apache.hadoop.ozone.web.utils.OzoneUtils.getRequestID;
+import static org.junit.Assert.assertEquals;
+public class TestOzoneWebAccess {
+ /**
+ * Set the timeout for every test
+ */
@Rule
- public Timeout timeout = new Timeout(30000);
+ public Timeout testTimeout = new Timeout(300000);
+
+ private static MiniOzoneCluster cluster;
+ private static int port;
/**
* Create a MiniDFSCluster for testing.
@@ -66,23 +66,21 @@ public class TestOzoneWebAccess {
* @throws IOException
*/
@BeforeClass
- public static void init() throws IOException {
+ public static void init() throws Exception {
OzoneConfiguration conf = new OzoneConfiguration();
URL p = conf.getClass().getResource("");
String path = p.getPath().concat(TestOzoneWebAccess.class.getSimpleName());
conf.set(OzoneConfigKeys.OZONE_LOCALSTORAGE_ROOT, path);
- conf.setBoolean(OzoneConfigKeys.OZONE_ENABLED, true);
- conf.set(OzoneConfigKeys.OZONE_HANDLER_TYPE_KEY, "local");
- cluster = new MiniDFSCluster.Builder(conf).build();
- cluster.waitActive();
+ cluster = new MiniOzoneCluster.Builder(conf)
+ .setHandlerType("local").build();
DataNode dataNode = cluster.getDataNodes().get(0);
port = dataNode.getInfoPort();
}
/**
- * shutdown MiniDFSCluster
+ * shutdown MiniOzoneCluster.
*/
@AfterClass
public static void shutdown() {
http://git-wip-us.apache.org/repos/asf/hadoop/blob/54f7975d/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/web/client/TestBuckets.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/web/client/TestBuckets.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/web/client/TestBuckets.java
index b7c3513..21d28cd 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/web/client/TestBuckets.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/web/client/TestBuckets.java
@@ -18,8 +18,8 @@
package org.apache.hadoop.ozone.web.client;
import org.apache.hadoop.fs.StorageType;
-import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.hadoop.hdfs.server.datanode.DataNode;
+import org.apache.hadoop.ozone.MiniOzoneCluster;
import org.apache.hadoop.ozone.OzoneConfigKeys;
import org.apache.hadoop.ozone.OzoneConfiguration;
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
@@ -27,7 +27,9 @@ import org.apache.hadoop.ozone.web.request.OzoneQuota;
import org.apache.hadoop.ozone.web.utils.OzoneUtils;
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.Timeout;
import java.io.IOException;
import java.net.URISyntaxException;
@@ -39,9 +41,13 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
public class TestBuckets {
+ /**
+ * Set the timeout for every test.
+ */
+ @Rule
+ public Timeout testTimeout = new Timeout(300000);
- static MiniDFSCluster cluster = null;
- static int port = 0;
+ private static MiniOzoneCluster cluster = null;
private static OzoneClient client = null;
/**
@@ -64,13 +70,10 @@ public class TestBuckets {
OzoneConfigKeys.OZONE_LOCALSTORAGE_ROOT_DEFAULT);
conf.set(OzoneConfigKeys.OZONE_LOCALSTORAGE_ROOT, path);
- conf.setBoolean(OzoneConfigKeys.OZONE_ENABLED, true);
- conf.set(OzoneConfigKeys.OZONE_HANDLER_TYPE_KEY, "local");
-
- cluster = new MiniDFSCluster.Builder(conf).build();
- cluster.waitActive();
+ cluster = new MiniOzoneCluster.Builder(conf)
+ .setHandlerType("local").build();
DataNode dataNode = cluster.getDataNodes().get(0);
- port = dataNode.getInfoPort();
+ final int port = dataNode.getInfoPort();
client = new OzoneClient(String.format("http://localhost:%d", port));
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/54f7975d/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/web/client/TestKeys.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/web/client/TestKeys.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/web/client/TestKeys.java
index d2b2b8d..c753a29 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/web/client/TestKeys.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/web/client/TestKeys.java
@@ -19,8 +19,8 @@ package org.apache.hadoop.ozone.web.client;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.hadoop.fs.StorageType;
-import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.hadoop.hdfs.server.datanode.DataNode;
+import org.apache.hadoop.ozone.MiniOzoneCluster;
import org.apache.hadoop.ozone.OzoneConfigKeys;
import org.apache.hadoop.ozone.OzoneConfiguration;
import org.apache.hadoop.ozone.web.exceptions.ErrorTable;
@@ -31,13 +31,14 @@ import org.apache.log4j.Logger;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.Timeout;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -49,12 +50,16 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
public class TestKeys {
- static MiniDFSCluster cluster = null;
- static int port = 0;
+ /**
+ * Set the timeout for every test.
+ */
+ @Rule
+ public Timeout testTimeout = new Timeout(300000);
+
+ private static MiniOzoneCluster cluster = null;
static private String path;
private static OzoneClient client = null;
-
/**
* Create a MiniDFSCluster for testing.
*
@@ -65,27 +70,20 @@ public class TestKeys {
* @throws IOException
*/
@BeforeClass
- public static void init()
- throws IOException, OzoneException, URISyntaxException {
+ public static void init() throws Exception {
OzoneConfiguration conf = new OzoneConfiguration();
URL p = conf.getClass().getResource("");
path = p.getPath().concat(TestKeys.class.getSimpleName());
path += conf.getTrimmed(OzoneConfigKeys.OZONE_LOCALSTORAGE_ROOT,
OzoneConfigKeys.OZONE_LOCALSTORAGE_ROOT_DEFAULT);
-
conf.set(OzoneConfigKeys.OZONE_LOCALSTORAGE_ROOT, path);
- conf.setBoolean(OzoneConfigKeys.OZONE_ENABLED, true);
- conf.set(OzoneConfigKeys.OZONE_HANDLER_TYPE_KEY, "local");
-
- conf.setBoolean(OzoneConfigKeys.OZONE_TRACE_ENABLED_KEY, true);
Logger.getLogger("log4j.logger.org.apache.http").setLevel(Level.DEBUG);
-
- cluster = new MiniDFSCluster.Builder(conf).build();
- cluster.waitActive();
+ cluster = new MiniOzoneCluster.Builder(conf)
+ .setHandlerType("local").build();
DataNode dataNode = cluster.getDataNodes().get(0);
- port = dataNode.getInfoPort();
+ final int port = dataNode.getInfoPort();
client = new OzoneClient(String.format("http://localhost:%d", port));
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/54f7975d/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/web/client/TestVolume.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/web/client/TestVolume.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/web/client/TestVolume.java
index 1499114..eb7db6f 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/web/client/TestVolume.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/web/client/TestVolume.java
@@ -19,8 +19,8 @@
package org.apache.hadoop.ozone.web.client;
import org.apache.commons.io.FileUtils;
-import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.hadoop.hdfs.server.datanode.DataNode;
+import org.apache.hadoop.ozone.MiniOzoneCluster;
import org.apache.hadoop.ozone.OzoneConfigKeys;
import org.apache.hadoop.ozone.OzoneConfiguration;
import org.apache.hadoop.ozone.web.exceptions.OzoneException;
@@ -36,7 +36,6 @@ import org.junit.Test;
import java.io.File;
import java.io.IOException;
-import java.net.URISyntaxException;
import java.net.URL;
import java.util.List;
@@ -46,8 +45,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
public class TestVolume {
- private static MiniDFSCluster cluster = null;
- private static int port = 0;
+ private static MiniOzoneCluster cluster = null;
private static OzoneClient client = null;
/**
@@ -60,8 +58,7 @@ public class TestVolume {
* @throws IOException
*/
@BeforeClass
- public static void init() throws IOException, OzoneException,
- URISyntaxException {
+ public static void init() throws Exception {
OzoneConfiguration conf = new OzoneConfiguration();
URL p = conf.getClass().getResource("");
@@ -71,15 +68,12 @@ public class TestVolume {
FileUtils.deleteDirectory(new File(path));
conf.set(OzoneConfigKeys.OZONE_LOCALSTORAGE_ROOT, path);
- conf.setBoolean(OzoneConfigKeys.OZONE_ENABLED, true);
- conf.set(OzoneConfigKeys.OZONE_HANDLER_TYPE_KEY, "local");
- conf.setBoolean(OzoneConfigKeys.OZONE_TRACE_ENABLED_KEY, true);
Logger.getLogger("log4j.logger.org.apache.http").setLevel(Level.DEBUG);
- cluster = new MiniDFSCluster.Builder(conf).build();
- cluster.waitActive();
+ cluster = new MiniOzoneCluster.Builder(conf)
+ .setHandlerType("local").build();
DataNode dataNode = cluster.getDataNodes().get(0);
- port = dataNode.getInfoPort();
+ final int port = dataNode.getInfoPort();
client = new OzoneClient(String.format("http://localhost:%d", port));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org