HDFS-13925. Unit Test for transitioning between different states. Contributed by Sherwood Zheng.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/b6f20c36 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/b6f20c36 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/b6f20c36 Branch: refs/heads/trunk Commit: b6f20c36c2f221f64ff4197903303236644c7be5 Parents: 1c4265d Author: Konstantin V Shvachko <[email protected]> Authored: Tue Oct 16 16:35:02 2018 -0700 Committer: Konstantin V Shvachko <[email protected]> Committed: Mon Dec 24 09:34:00 2018 -0800 ---------------------------------------------------------------------- .../server/namenode/ha/TestObserverNode.java | 23 ++++++++++++++++++++ 1 file changed, 23 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/b6f20c36/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestObserverNode.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestObserverNode.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestObserverNode.java index 28fd330..b18c5b8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestObserverNode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestObserverNode.java @@ -20,6 +20,7 @@ package org.apache.hadoop.hdfs.server.namenode.ha; import static org.apache.hadoop.hdfs.server.namenode.NameNodeAdapter.getServiceState; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyBoolean; import static org.mockito.Matchers.anyLong; @@ -30,11 +31,13 @@ import java.io.IOException; import java.net.URI; import java.util.ArrayList; import java.util.List; + import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileUtil; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.ha.HAServiceProtocol.HAServiceState; +import org.apache.hadoop.ha.ServiceFailedException; import org.apache.hadoop.hdfs.DistributedFileSystem; import org.apache.hadoop.hdfs.MiniDFSCluster; import org.apache.hadoop.hdfs.protocol.Block; @@ -100,6 +103,26 @@ public class TestObserverNode { } @Test + public void testNoActiveToObserver() throws Exception { + try { + dfsCluster.transitionToObserver(0); + } catch (ServiceFailedException e) { + return; + } + fail("active cannot be transitioned to observer"); + } + + @Test + public void testNoObserverToActive() throws Exception { + try { + dfsCluster.transitionToActive(2); + } catch (ServiceFailedException e) { + return; + } + fail("observer cannot be transitioned to active"); + } + + @Test public void testSimpleRead() throws Exception { Path testPath2 = new Path(testPath, "test2"); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
