From 9e911a24392cfec9dc7ad5886ca57f2365fddc12 Mon Sep 17 00:00:00 2001 From: Haohui Mai Date: Wed, 28 Oct 2015 15:54:37 -0700 Subject: [PATCH] HDFS-9168. Move client side unit test to hadoop-hdfs-client. Contributed by Haohui Mai. --- .../hadoop-hdfs-client/pom.xml | 21 +++++ .../ReplaceDatanodeOnFailure.java | 78 +++++++++---------- .../fs/TestUrlStreamHandlerFactory.java | 0 .../java/org/apache/hadoop/fs/TestXAttr.java | 0 .../org/apache/hadoop/hdfs/TestDFSPacket.java | 0 .../hadoop/hdfs/TestDefaultNameNodePort.java | 12 ++- .../org/apache/hadoop/hdfs/TestPeerCache.java | 25 +++--- .../hdfs/client/impl/TestLeaseRenewer.java | 12 ++- .../hdfs/protocol/TestExtendedBlock.java | 0 .../shortcircuit/TestShortCircuitShm.java | 18 ++--- .../hdfs/util/TestByteArrayManager.java | 37 +++++---- .../hdfs/util/TestExactSizeInputStream.java | 0 .../hdfs/web/TestByteRangeInputStream.java | 0 .../hdfs/web/TestOffsetUrlInputStream.java | 0 .../hadoop/hdfs/web/TestTokenAspect.java | 0 .../hdfs/web/TestURLConnectionFactory.java | 0 .../hadoop/hdfs/web/TestWebHDFSOAuth2.java | 7 +- .../hdfs/web/TestWebHdfsContentLength.java | 0 .../hdfs/web/oauth2/TestAccessTokenTimer.java | 0 ...ientCredentialTimeBasedTokenRefresher.java | 0 ...stRefreshTokenTimeBasedTokenRefresher.java | 0 hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 2 + hadoop-hdfs-project/hadoop-hdfs/pom.xml | 6 -- .../hdfs/server/namenode/TestAuditLogger.java | 4 +- hadoop-project/pom.xml | 5 ++ 25 files changed, 121 insertions(+), 106 deletions(-) rename hadoop-hdfs-project/{hadoop-hdfs => hadoop-hdfs-client}/src/test/java/org/apache/hadoop/fs/TestUrlStreamHandlerFactory.java (100%) rename hadoop-hdfs-project/{hadoop-hdfs => hadoop-hdfs-client}/src/test/java/org/apache/hadoop/fs/TestXAttr.java (100%) rename hadoop-hdfs-project/{hadoop-hdfs => hadoop-hdfs-client}/src/test/java/org/apache/hadoop/hdfs/TestDFSPacket.java (100%) rename hadoop-hdfs-project/{hadoop-hdfs => hadoop-hdfs-client}/src/test/java/org/apache/hadoop/hdfs/TestDefaultNameNodePort.java (97%) rename hadoop-hdfs-project/{hadoop-hdfs => hadoop-hdfs-client}/src/test/java/org/apache/hadoop/hdfs/TestPeerCache.java (98%) rename hadoop-hdfs-project/{hadoop-hdfs => hadoop-hdfs-client}/src/test/java/org/apache/hadoop/hdfs/client/impl/TestLeaseRenewer.java (99%) rename hadoop-hdfs-project/{hadoop-hdfs => hadoop-hdfs-client}/src/test/java/org/apache/hadoop/hdfs/protocol/TestExtendedBlock.java (100%) rename hadoop-hdfs-project/{hadoop-hdfs => hadoop-hdfs-client}/src/test/java/org/apache/hadoop/hdfs/shortcircuit/TestShortCircuitShm.java (94%) rename hadoop-hdfs-project/{hadoop-hdfs => hadoop-hdfs-client}/src/test/java/org/apache/hadoop/hdfs/util/TestByteArrayManager.java (98%) rename hadoop-hdfs-project/{hadoop-hdfs => hadoop-hdfs-client}/src/test/java/org/apache/hadoop/hdfs/util/TestExactSizeInputStream.java (100%) rename hadoop-hdfs-project/{hadoop-hdfs => hadoop-hdfs-client}/src/test/java/org/apache/hadoop/hdfs/web/TestByteRangeInputStream.java (100%) rename hadoop-hdfs-project/{hadoop-hdfs => hadoop-hdfs-client}/src/test/java/org/apache/hadoop/hdfs/web/TestOffsetUrlInputStream.java (100%) rename hadoop-hdfs-project/{hadoop-hdfs => hadoop-hdfs-client}/src/test/java/org/apache/hadoop/hdfs/web/TestTokenAspect.java (100%) rename hadoop-hdfs-project/{hadoop-hdfs => hadoop-hdfs-client}/src/test/java/org/apache/hadoop/hdfs/web/TestURLConnectionFactory.java (100%) rename hadoop-hdfs-project/{hadoop-hdfs => hadoop-hdfs-client}/src/test/java/org/apache/hadoop/hdfs/web/TestWebHDFSOAuth2.java (98%) rename hadoop-hdfs-project/{hadoop-hdfs => hadoop-hdfs-client}/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsContentLength.java (100%) rename hadoop-hdfs-project/{hadoop-hdfs => hadoop-hdfs-client}/src/test/java/org/apache/hadoop/hdfs/web/oauth2/TestAccessTokenTimer.java (100%) rename hadoop-hdfs-project/{hadoop-hdfs => hadoop-hdfs-client}/src/test/java/org/apache/hadoop/hdfs/web/oauth2/TestClientCredentialTimeBasedTokenRefresher.java (100%) rename hadoop-hdfs-project/{hadoop-hdfs => hadoop-hdfs-client}/src/test/java/org/apache/hadoop/hdfs/web/oauth2/TestRefreshTokenTimeBasedTokenRefresher.java (100%) diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/pom.xml b/hadoop-hdfs-project/hadoop-hdfs-client/pom.xml index f2becf162f3..a6491198bd2 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/pom.xml +++ b/hadoop-hdfs-project/hadoop-hdfs-client/pom.xml @@ -51,6 +51,27 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + junit + junit + test + + + org.mockito + mockito-all + test + + + org.mock-server + mockserver-netty + test + + + org.apache.hadoop + hadoop-common + test + test-jar + diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/datatransfer/ReplaceDatanodeOnFailure.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/datatransfer/ReplaceDatanodeOnFailure.java index c21a6a5c144..7099c28db18 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/datatransfer/ReplaceDatanodeOnFailure.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/datatransfer/ReplaceDatanodeOnFailure.java @@ -30,16 +30,49 @@ import org.apache.hadoop.hdfs.protocol.DatanodeInfo; @InterfaceAudience.Private @InterfaceStability.Evolving public class ReplaceDatanodeOnFailure { + /** + * DEFAULT condition: + * Let r be the replication number. + * Let n be the number of existing datanodes. + * Add a new datanode only if r >= 3 and either + * (1) floor(r/2) >= n or (2) the block is hflushed/appended. + */ + private static final Condition CONDITION_DEFAULT = new Condition() { + @Override + public boolean satisfy(final short replication, + final DatanodeInfo[] existings, final int n, final boolean isAppend, + final boolean isHflushed) { + return replication >= 3 && + (n <= (replication / 2) || isAppend || isHflushed); + } + }; + /** Return false unconditionally. */ + private static final Condition CONDITION_FALSE = new Condition() { + @Override + public boolean satisfy(short replication, DatanodeInfo[] existings, + int nExistings, boolean isAppend, boolean isHflushed) { + return false; + } + }; + /** Return true unconditionally. */ + private static final Condition CONDITION_TRUE = new Condition() { + @Override + public boolean satisfy(short replication, DatanodeInfo[] existings, + int nExistings, boolean isAppend, boolean isHflushed) { + return true; + } + }; + /** The replacement policies */ public enum Policy { /** The feature is disabled in the entire site. */ - DISABLE(Condition.FALSE), + DISABLE(CONDITION_FALSE), /** Never add a new datanode. */ - NEVER(Condition.FALSE), - /** @see ReplaceDatanodeOnFailure.Condition#DEFAULT */ - DEFAULT(Condition.DEFAULT), + NEVER(CONDITION_FALSE), + /** @see ReplaceDatanodeOnFailure#CONDITION_DEFAULT */ + DEFAULT(CONDITION_DEFAULT), /** Always add a new datanode when an existing datanode is removed. */ - ALWAYS(Condition.TRUE); + ALWAYS(CONDITION_TRUE); private final Condition condition; @@ -54,41 +87,6 @@ public class ReplaceDatanodeOnFailure { /** Datanode replacement condition */ private interface Condition { - /** Return true unconditionally. */ - Condition TRUE = new Condition() { - @Override - public boolean satisfy(short replication, DatanodeInfo[] existings, - int nExistings, boolean isAppend, boolean isHflushed) { - return true; - } - }; - - /** Return false unconditionally. */ - Condition FALSE = new Condition() { - @Override - public boolean satisfy(short replication, DatanodeInfo[] existings, - int nExistings, boolean isAppend, boolean isHflushed) { - return false; - } - }; - - /** - * DEFAULT condition: - * Let r be the replication number. - * Let n be the number of existing datanodes. - * Add a new datanode only if r >= 3 and either - * (1) floor(r/2) >= n; or - * (2) r > n and the block is hflushed/appended. - */ - Condition DEFAULT = new Condition() { - @Override - public boolean satisfy(final short replication, - final DatanodeInfo[] existings, final int n, final boolean isAppend, - final boolean isHflushed) { - return replication >= 3 && - (n <= (replication / 2) || isAppend || isHflushed); - } - }; /** Is the condition satisfied? */ boolean satisfy(short replication, DatanodeInfo[] existings, int nExistings, diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestUrlStreamHandlerFactory.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/fs/TestUrlStreamHandlerFactory.java similarity index 100% rename from hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestUrlStreamHandlerFactory.java rename to hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/fs/TestUrlStreamHandlerFactory.java diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestXAttr.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/fs/TestXAttr.java similarity index 100% rename from hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestXAttr.java rename to hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/fs/TestXAttr.java diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSPacket.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/TestDFSPacket.java similarity index 100% rename from hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSPacket.java rename to hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/TestDFSPacket.java diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDefaultNameNodePort.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/TestDefaultNameNodePort.java similarity index 97% rename from hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDefaultNameNodePort.java rename to hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/TestDefaultNameNodePort.java index 1d8d289aed4..fc76a071b78 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDefaultNameNodePort.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/TestDefaultNameNodePort.java @@ -17,17 +17,15 @@ */ package org.apache.hadoop.hdfs; -import static org.junit.Assert.assertEquals; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.hdfs.client.HdfsClientConfigKeys; +import org.junit.Test; import java.net.InetSocketAddress; import java.net.URI; -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.fs.FileSystem; -import org.apache.hadoop.hdfs.client.HdfsClientConfigKeys; -import org.apache.hadoop.hdfs.server.namenode.NameNode; - -import org.junit.Test; +import static org.junit.Assert.assertEquals; /** Test NameNode port defaulting code. */ public class TestDefaultNameNodePort { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestPeerCache.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/TestPeerCache.java similarity index 98% rename from hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestPeerCache.java rename to hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/TestPeerCache.java index 243d09b78c1..b24df2bfce9 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestPeerCache.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/TestPeerCache.java @@ -17,17 +17,7 @@ */ package org.apache.hadoop.hdfs; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.nio.channels.ReadableByteChannel; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import com.google.common.collect.HashMultiset; import org.apache.hadoop.hdfs.net.Peer; import org.apache.hadoop.hdfs.protocol.DatanodeID; import org.apache.hadoop.net.unix.DomainSocket; @@ -35,11 +25,20 @@ import org.junit.Test; import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -import com.google.common.collect.HashMultiset; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.channels.ReadableByteChannel; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; public class TestPeerCache { - static final Log LOG = LogFactory.getLog(TestPeerCache.class); + static final Logger LOG = LoggerFactory.getLogger(TestPeerCache.class); private static class FakePeer implements Peer { private boolean closed = false; diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/client/impl/TestLeaseRenewer.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/client/impl/TestLeaseRenewer.java similarity index 99% rename from hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/client/impl/TestLeaseRenewer.java rename to hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/client/impl/TestLeaseRenewer.java index a4e00d94121..eb10e965424 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/client/impl/TestLeaseRenewer.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/client/impl/TestLeaseRenewer.java @@ -17,14 +17,9 @@ */ package org.apache.hadoop.hdfs.client.impl; -import static org.junit.Assert.assertSame; - -import java.io.IOException; -import java.util.concurrent.atomic.AtomicInteger; - +import com.google.common.base.Supplier; import org.apache.hadoop.hdfs.DFSClient; import org.apache.hadoop.hdfs.DFSOutputStream; -import org.apache.hadoop.hdfs.client.impl.DfsClientConf; import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.util.Time; @@ -35,7 +30,10 @@ import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -import com.google.common.base.Supplier; +import java.io.IOException; +import java.util.concurrent.atomic.AtomicInteger; + +import static org.junit.Assert.assertSame; public class TestLeaseRenewer { private final String FAKE_AUTHORITY="hdfs://nn1/"; diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocol/TestExtendedBlock.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/protocol/TestExtendedBlock.java similarity index 100% rename from hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/protocol/TestExtendedBlock.java rename to hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/protocol/TestExtendedBlock.java diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/shortcircuit/TestShortCircuitShm.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/shortcircuit/TestShortCircuitShm.java similarity index 94% rename from hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/shortcircuit/TestShortCircuitShm.java rename to hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/shortcircuit/TestShortCircuitShm.java index 7d28736ae41..9d484447984 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/shortcircuit/TestShortCircuitShm.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/shortcircuit/TestShortCircuitShm.java @@ -17,16 +17,8 @@ */ package org.apache.hadoop.hdfs.shortcircuit; -import java.io.File; -import java.io.FileInputStream; -import java.util.ArrayList; -import java.util.Iterator; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.hadoop.fs.FileUtil; import org.apache.hadoop.hdfs.ExtendedBlockId; -import org.apache.hadoop.hdfs.shortcircuit.ShortCircuitShm; import org.apache.hadoop.hdfs.shortcircuit.ShortCircuitShm.ShmId; import org.apache.hadoop.hdfs.shortcircuit.ShortCircuitShm.Slot; import org.apache.hadoop.io.nativeio.SharedFileDescriptorFactory; @@ -34,9 +26,17 @@ import org.junit.Assert; import org.junit.Assume; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.io.FileInputStream; +import java.util.ArrayList; +import java.util.Iterator; public class TestShortCircuitShm { - public static final Log LOG = LogFactory.getLog(TestShortCircuitShm.class); + public static final Logger LOG = LoggerFactory.getLogger( + TestShortCircuitShm.class); private static final File TEST_BASE = new File(System.getProperty("test.build.data", "/tmp")); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/util/TestByteArrayManager.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/util/TestByteArrayManager.java similarity index 98% rename from hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/util/TestByteArrayManager.java rename to hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/util/TestByteArrayManager.java index 35a6d9af1af..f5dd88360b0 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/util/TestByteArrayManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/util/TestByteArrayManager.java @@ -17,6 +17,19 @@ */ package org.apache.hadoop.hdfs.util; +import org.apache.hadoop.hdfs.client.HdfsClientConfigKeys; +import org.apache.hadoop.hdfs.util.ByteArrayManager.Counter; +import org.apache.hadoop.hdfs.util.ByteArrayManager.CounterMap; +import org.apache.hadoop.hdfs.util.ByteArrayManager.FixedLengthManager; +import org.apache.hadoop.hdfs.util.ByteArrayManager.ManagerMap; +import org.apache.hadoop.test.GenericTestUtils; +import org.apache.hadoop.util.Time; +import org.apache.log4j.Level; +import org.junit.Assert; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -31,29 +44,16 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicInteger; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.hadoop.hdfs.client.HdfsClientConfigKeys; -import org.apache.hadoop.hdfs.util.ByteArrayManager.Counter; -import org.apache.hadoop.hdfs.util.ByteArrayManager.CounterMap; -import org.apache.hadoop.hdfs.util.ByteArrayManager.FixedLengthManager; -import org.apache.hadoop.hdfs.util.ByteArrayManager.ManagerMap; -import org.apache.hadoop.test.GenericTestUtils; -import org.apache.hadoop.util.Time; -import org.apache.log4j.Level; -import org.junit.Assert; -import org.junit.Test; - /** * Test {@link ByteArrayManager}. */ public class TestByteArrayManager { static { - GenericTestUtils.setLogLevel(LogFactory.getLog(ByteArrayManager.class), - Level.ALL); + GenericTestUtils.setLogLevel( + LoggerFactory.getLogger(ByteArrayManager.class), Level.ALL); } - static final Log LOG = LogFactory.getLog(TestByteArrayManager.class); + static final Logger LOG = LoggerFactory.getLogger(TestByteArrayManager.class); private static final Comparator> CMP = new Comparator>() { @Override @@ -559,9 +559,8 @@ public class TestByteArrayManager { } public static void main(String[] args) throws Exception { - GenericTestUtils.setLogLevel(LogFactory.getLog(ByteArrayManager.class), - Level.OFF); - + GenericTestUtils.setLogLevel(LoggerFactory.getLogger(ByteArrayManager.class), + Level.OFF); final int arrayLength = 64 * 1024; //64k final int nThreads = 512; final int nAllocations = 1 << 15; diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/util/TestExactSizeInputStream.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/util/TestExactSizeInputStream.java similarity index 100% rename from hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/util/TestExactSizeInputStream.java rename to hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/util/TestExactSizeInputStream.java diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestByteRangeInputStream.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/TestByteRangeInputStream.java similarity index 100% rename from hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestByteRangeInputStream.java rename to hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/TestByteRangeInputStream.java diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestOffsetUrlInputStream.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/TestOffsetUrlInputStream.java similarity index 100% rename from hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestOffsetUrlInputStream.java rename to hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/TestOffsetUrlInputStream.java diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestTokenAspect.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/TestTokenAspect.java similarity index 100% rename from hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestTokenAspect.java rename to hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/TestTokenAspect.java diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestURLConnectionFactory.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/TestURLConnectionFactory.java similarity index 100% rename from hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestURLConnectionFactory.java rename to hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/TestURLConnectionFactory.java diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHDFSOAuth2.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/TestWebHDFSOAuth2.java similarity index 98% rename from hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHDFSOAuth2.java rename to hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/TestWebHDFSOAuth2.java index e2f6230ef25..032fff05762 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHDFSOAuth2.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/TestWebHDFSOAuth2.java @@ -18,8 +18,6 @@ */ package org.apache.hadoop.hdfs.web; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; @@ -38,6 +36,8 @@ import org.mockserver.integration.ClientAndServer; import org.mockserver.model.Header; import org.mockserver.model.HttpRequest; import org.mockserver.model.HttpResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; import java.net.URI; @@ -58,7 +58,8 @@ import static org.mockserver.model.HttpRequest.request; import static org.mockserver.model.HttpResponse.response; public class TestWebHDFSOAuth2 { - public static final Log LOG = LogFactory.getLog(TestWebHDFSOAuth2.class); + public static final Logger LOG = LoggerFactory.getLogger( + TestWebHDFSOAuth2.class); private ClientAndServer mockWebHDFS; private ClientAndServer mockOAuthServer; diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsContentLength.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsContentLength.java similarity index 100% rename from hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsContentLength.java rename to hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsContentLength.java diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/oauth2/TestAccessTokenTimer.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/oauth2/TestAccessTokenTimer.java similarity index 100% rename from hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/oauth2/TestAccessTokenTimer.java rename to hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/oauth2/TestAccessTokenTimer.java diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/oauth2/TestClientCredentialTimeBasedTokenRefresher.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/oauth2/TestClientCredentialTimeBasedTokenRefresher.java similarity index 100% rename from hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/oauth2/TestClientCredentialTimeBasedTokenRefresher.java rename to hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/oauth2/TestClientCredentialTimeBasedTokenRefresher.java diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/oauth2/TestRefreshTokenTimeBasedTokenRefresher.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/oauth2/TestRefreshTokenTimeBasedTokenRefresher.java similarity index 100% rename from hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/oauth2/TestRefreshTokenTimeBasedTokenRefresher.java rename to hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/oauth2/TestRefreshTokenTimeBasedTokenRefresher.java diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index a128ebcd0ef..93af5b39bbc 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -805,6 +805,8 @@ Release 2.8.0 - UNRELEASED HDFS-9297. Update TestBlockMissingException to use corruptBlockOnDataNodesByDeletingBlockFile(). (Tony Wu via lei) + HDFS-9168. Move client side unit test to hadoop-hdfs-client. (wheat9) + BUG FIXES HDFS-8091: ACLStatus and XAttributes should be presented to diff --git a/hadoop-hdfs-project/hadoop-hdfs/pom.xml b/hadoop-hdfs-project/hadoop-hdfs/pom.xml index fc47f628d22..d132da5a662 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/pom.xml +++ b/hadoop-hdfs-project/hadoop-hdfs/pom.xml @@ -210,12 +210,6 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd"> leveldbjni-all 1.8 - - org.mock-server - mockserver-netty - 3.9.2 - test - org.bouncycastle diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestAuditLogger.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestAuditLogger.java index 62b5f8f4466..168b9d62d05 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestAuditLogger.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestAuditLogger.java @@ -19,7 +19,7 @@ package org.apache.hadoop.hdfs.server.namenode; import com.google.common.collect.Lists; -import org.apache.commons.lang3.RandomStringUtils; +import org.apache.commons.lang.StringUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; @@ -259,7 +259,7 @@ public class TestAuditLogger { auditlog.clearOutput(); // long context is truncated - final String longContext = RandomStringUtils.randomAscii(200); + final String longContext = StringUtils.repeat("foo", 100); context = new CallerContext.Builder(longContext) .setSignature("L".getBytes(CallerContext.SIGNATURE_ENCODING)) .build(); diff --git a/hadoop-project/pom.xml b/hadoop-project/pom.xml index 2f430d5be85..cf58a1ddea4 100644 --- a/hadoop-project/pom.xml +++ b/hadoop-project/pom.xml @@ -774,6 +774,11 @@ mockito-all 1.8.5 + + org.mock-server + mockserver-netty + 3.9.2 + org.apache.avro avro