HDFS-11120. TestEncryptionZones should waitActive. Contributed by John Zhuge.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/71adf44c
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/71adf44c
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/71adf44c

Branch: refs/heads/YARN-4752
Commit: 71adf44c3fc5655700cdc904e61366d438c938eb
Parents: de3a5f8
Author: Xiao Chen <x...@apache.org>
Authored: Wed Nov 9 17:15:19 2016 -0800
Committer: Xiao Chen <x...@apache.org>
Committed: Wed Nov 9 17:16:07 2016 -0800

----------------------------------------------------------------------
 .../apache/hadoop/hdfs/TestEncryptionZones.java | 61 +++++++++++---------
 1 file changed, 34 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/71adf44c/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java
----------------------------------------------------------------------
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java
 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java
index 3a0586e..8605b9e 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java
@@ -94,7 +94,9 @@ import org.apache.log4j.Logger;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.Timeout;
 import org.mockito.Mockito;
 
 import static org.junit.Assert.assertNotNull;
@@ -146,6 +148,9 @@ public class TestEncryptionZones {
       new Path(testRootDir.toString(), "test.jks").toUri();
   }
 
+  @Rule
+  public Timeout globalTimeout = new Timeout(120 * 1000);
+
   @Before
   public void setup() throws Exception {
     conf = new HdfsConfiguration();
@@ -160,6 +165,7 @@ public class TestEncryptionZones {
     conf.setInt(DFSConfigKeys.DFS_NAMENODE_LIST_ENCRYPTION_ZONES_NUM_RESPONSES,
         2);
     cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1).build();
+    cluster.waitActive();
     Logger.getLogger(EncryptionZoneManager.class).setLevel(Level.TRACE);
     fs = cluster.getFileSystem();
     fsWrapper = new FileSystemTestWrapper(fs);
@@ -231,7 +237,7 @@ public class TestEncryptionZones {
    * with sticky bits.
    * @throws Exception
    */
-  @Test(timeout = 60000)
+  @Test
   public void testTrashStickyBit() throws Exception {
     // create an EZ /zones/zone1, make it world writable.
     final Path zoneParent = new Path("/zones");
@@ -294,7 +300,7 @@ public class TestEncryptionZones {
    * with sticky bits.
    * @throws Exception
    */
-  @Test(timeout = 60000)
+  @Test
   public void testProvisionTrash() throws Exception {
     // create an EZ /zones/zone1
     final Path zoneParent = new Path("/zones");
@@ -326,7 +332,8 @@ public class TestEncryptionZones {
     assertTrue(trashFileStatus.getPermission().getStickyBit());
   }
 
-  @Test(timeout = 60000)
+  // CHECKSTYLE:OFF:MethodLengthCheck
+  @Test
   public void testBasicOperations() throws Exception {
 
     int numZones = 0;
@@ -485,8 +492,9 @@ public class TestEncryptionZones {
     assertNumZones(numZones);
     assertZonePresent(null, nonpersistZone.toString());
   }
+  // CHECKSTYLE:ON:MethodLengthCheck
 
-  @Test(timeout = 60000)
+  @Test
   public void testBasicOperationsRootDir() throws Exception {
     int numZones = 0;
     final Path rootDir = new Path("/");
@@ -510,7 +518,7 @@ public class TestEncryptionZones {
   /**
    * Test listing encryption zones as a non super user.
    */
-  @Test(timeout = 60000)
+  @Test
   public void testListEncryptionZonesAsNonSuperUser() throws Exception {
 
     final UserGroupInformation user = UserGroupInformation.
@@ -544,7 +552,7 @@ public class TestEncryptionZones {
   /**
    * Test getEncryptionZoneForPath as a non super user.
    */
-  @Test(timeout = 60000)
+  @Test
   public void testGetEZAsNonSuperUser() throws Exception {
 
     final UserGroupInformation user = UserGroupInformation.
@@ -688,12 +696,12 @@ public class TestEncryptionZones {
     }
   }
 
-  @Test(timeout = 60000)
+  @Test
   public void testRenameFileSystem() throws Exception {
     doRenameEncryptionZone(fsWrapper);
   }
 
-  @Test(timeout = 60000)
+  @Test
   public void testRenameFileContext() throws Exception {
     doRenameEncryptionZone(fcWrapper);
   }
@@ -703,7 +711,7 @@ public class TestEncryptionZones {
     return blocks.getFileEncryptionInfo();
   }
 
-  @Test(timeout = 120000)
+  @Test
   public void testReadWrite() throws Exception {
     final HdfsAdmin dfsAdmin =
         new HdfsAdmin(FileSystem.getDefaultUri(conf), conf);
@@ -759,7 +767,7 @@ public class TestEncryptionZones {
     verifyFilesEqual(fs, encFile1, encFile2, len);
   }
 
-  @Test(timeout = 120000)
+  @Test
   public void testReadWriteUsingWebHdfs() throws Exception {
     final HdfsAdmin dfsAdmin =
         new HdfsAdmin(FileSystem.getDefaultUri(conf), conf);
@@ -808,7 +816,7 @@ public class TestEncryptionZones {
     out.close();
   }
 
-  @Test(timeout = 60000)
+  @Test
   public void testVersionAndSuiteNegotiation() throws Exception {
     final HdfsAdmin dfsAdmin =
         new HdfsAdmin(FileSystem.getDefaultUri(conf), conf);
@@ -935,14 +943,13 @@ public class TestEncryptionZones {
     }
   }
 
-  @Test(timeout = 120000)
+  @Test
   public void testCreateEZWithNoProvider() throws Exception {
     // Unset the key provider and make sure EZ ops don't work
     final Configuration clusterConf = cluster.getConfiguration(0);
     clusterConf
         
.unset(CommonConfigurationKeysPublic.HADOOP_SECURITY_KEY_PROVIDER_PATH);
     cluster.restartNameNode(true);
-    cluster.waitActive();
     final Path zone1 = new Path("/zone1");
     fsWrapper.mkdir(zone1, FsPermission.getDirDefault(), true);
     try {
@@ -960,7 +967,7 @@ public class TestEncryptionZones {
     assertNumZones(0);
   }
 
-  @Test(timeout = 120000)
+  @Test
   public void testIsEncryptedMethod() throws Exception {
     doTestIsEncryptedMethod(new Path("/"));
     doTestIsEncryptedMethod(new Path("/.reserved/raw"));
@@ -1137,7 +1144,7 @@ public class TestEncryptionZones {
    * Tests the retry logic in startFile. We release the lock while generating
    * an EDEK, so tricky things can happen in the intervening time.
    */
-  @Test(timeout = 120000)
+  @Test
   public void testStartFileRetry() throws Exception {
     final Path zone1 = new Path("/zone1");
     final Path file = new Path(zone1, "file1");
@@ -1232,7 +1239,7 @@ public class TestEncryptionZones {
   /**
    * Tests obtaining delegation token from stored key
    */
-  @Test(timeout = 120000)
+  @Test
   public void testDelegationToken() throws Exception {
     UserGroupInformation.createRemoteUser("JobTracker");
     DistributedFileSystem dfs = cluster.getFileSystem();
@@ -1263,7 +1270,7 @@ public class TestEncryptionZones {
   /**
    * Test running fsck on a system with encryption zones.
    */
-  @Test(timeout = 60000)
+  @Test
   public void testFsckOnEncryptionZones() throws Exception {
     final int len = 8196;
     final Path zoneParent = new Path("/zones");
@@ -1294,7 +1301,7 @@ public class TestEncryptionZones {
    * Test correctness of successive snapshot creation and deletion
    * on a system with encryption zones.
    */
-  @Test(timeout = 60000)
+  @Test
   public void testSnapshotsOnEncryptionZones() throws Exception {
     final String TEST_KEY2 = "testkey2";
     DFSTestUtil.createKey(TEST_KEY2, cluster, conf);
@@ -1376,7 +1383,7 @@ public class TestEncryptionZones {
    * they function properly when the target is in the same
    * or different ez.
    */
-  @Test(timeout = 60000)
+  @Test
   public void testEncryptionZonesWithSymlinks() throws Exception {
     // Verify we can create an encryption zone over both link and target
     final int len = 8192;
@@ -1411,7 +1418,7 @@ public class TestEncryptionZones {
     fs.delete(target, true);
   }
 
-  @Test(timeout = 60000)
+  @Test
   public void testConcatFailsInEncryptionZones() throws Exception {
     final int len = 8192;
     final Path ez = new Path("/ez");
@@ -1436,7 +1443,7 @@ public class TestEncryptionZones {
   /**
    * Test running the OfflineImageViewer on a system with encryption zones.
    */
-  @Test(timeout = 60000)
+  @Test
   public void testOfflineImageViewerOnEncryptionZones() throws Exception {
     final int len = 8196;
     final Path zoneParent = new Path("/zones");
@@ -1467,7 +1474,7 @@ public class TestEncryptionZones {
   /**
    * Test creating encryption zone on the root path
    */
-  @Test(timeout = 60000)
+  @Test
   public void testEncryptionZonesOnRootPath() throws Exception {
     final int len = 8196;
     final Path rootDir = new Path("/");
@@ -1486,7 +1493,7 @@ public class TestEncryptionZones {
     DFSTestUtil.verifyFilesNotEqual(fs, zoneFile, rawFile, len);
   }
 
-  @Test(timeout = 60000)
+  @Test
   public void testEncryptionZonesOnRelativePath() throws Exception {
     final int len = 8196;
     final Path baseDir = new Path("/somewhere/base");
@@ -1504,7 +1511,7 @@ public class TestEncryptionZones {
         .getEncryptionZoneForPath(zoneDir).getPath().toString());
   }
 
-  @Test(timeout = 60000)
+  @Test
   public void testGetEncryptionZoneOnANonExistentPaths() throws Exception {
     final Path ezPath = new Path("/ez");
     fs.mkdirs(ezPath);
@@ -1519,7 +1526,7 @@ public class TestEncryptionZones {
     assertNull("Expected null for non-existent path not in EZ", ez);
   }
 
-  @Test(timeout = 120000)
+  @Test
   public void testEncryptionZoneWithTrash() throws Exception {
     // Create the encryption zone1
     final HdfsAdmin dfsAdmin =
@@ -1582,7 +1589,7 @@ public class TestEncryptionZones {
     verifyShellDeleteWithTrash(shell, topEZ);
   }
 
-  @Test(timeout = 120000)
+  @Test
   public void testRootDirEZTrash() throws Exception {
     final HdfsAdmin dfsAdmin =
         new HdfsAdmin(FileSystem.getDefaultUri(conf), conf);
@@ -1619,7 +1626,7 @@ public class TestEncryptionZones {
 
   }
 
-  @Test(timeout = 120000)
+  @Test
   public void testGetTrashRoots() throws Exception {
     final HdfsAdmin dfsAdmin =
         new HdfsAdmin(FileSystem.getDefaultUri(conf), conf);


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-commits-h...@hadoop.apache.org

Reply via email to