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

This commit is contained in:
Xiao Chen 2016-11-09 17:15:19 -08:00
parent de3a5f8d08
commit 71adf44c3f

View File

@ -94,7 +94,9 @@
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 @@ protected String getKeyProviderURI() {
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 void setup() throws Exception {
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 void assertZonePresent(String keyName, String path) throws IOException {
* 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 Object run() throws Exception {
* 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 void testProvisionTrash() throws Exception {
assertTrue(trashFileStatus.getPermission().getStickyBit());
}
@Test(timeout = 60000)
// CHECKSTYLE:OFF:MethodLengthCheck
@Test
public void testBasicOperations() throws Exception {
int numZones = 0;
@ -485,8 +492,9 @@ public Object run() throws Exception {
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 void testBasicOperationsRootDir() throws Exception {
/**
* 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 Object run() throws Exception {
/**
* Test getEncryptionZoneForPath as a non super user.
*/
@Test(timeout = 60000)
@Test
public void testGetEZAsNonSuperUser() throws Exception {
final UserGroupInformation user = UserGroupInformation.
@ -688,12 +696,12 @@ private void doRenameEncryptionZone(FSTestWrapper wrapper) throws Exception {
}
}
@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 @@ private FileEncryptionInfo getFileEncryptionInfo(Path path) throws Exception {
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 void testReadWrite() throws Exception {
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 @@ private void appendOneByte(FileSystem fs, Path p) throws IOException {
out.close();
}
@Test(timeout = 60000)
@Test
public void testVersionAndSuiteNegotiation() throws Exception {
final HdfsAdmin dfsAdmin =
new HdfsAdmin(FileSystem.getDefaultUri(conf), conf);
@ -935,14 +943,13 @@ private static void testCipherSuiteNegotiation(DistributedFileSystem fs,
}
}
@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 void testCreateEZWithNoProvider() throws Exception {
assertNumZones(0);
}
@Test(timeout = 120000)
@Test
public void testIsEncryptedMethod() throws Exception {
doTestIsEncryptedMethod(new Path("/"));
doTestIsEncryptedMethod(new Path("/.reserved/raw"));
@ -1137,7 +1144,7 @@ public void doCleanup() throws Exception {}
* 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 void doCleanup() throws Exception {
/**
* 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 void testDelegationToken() throws Exception {
/**
* 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 void testFsckOnEncryptionZones() throws Exception {
* 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 void testSnapshotsOnEncryptionZones() throws Exception {
* 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 void testEncryptionZonesWithSymlinks() throws Exception {
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 void testConcatFailsInEncryptionZones() throws Exception {
/**
* 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 void testOfflineImageViewerOnEncryptionZones() throws Exception {
/**
* 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 void testEncryptionZonesOnRootPath() throws Exception {
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 void testEncryptionZonesOnRelativePath() throws Exception {
.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 void testGetEncryptionZoneOnANonExistentPaths() throws Exception {
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 void testEncryptionZoneWithTrash() throws Exception {
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 void testRootDirEZTrash() throws Exception {
}
@Test(timeout = 120000)
@Test
public void testGetTrashRoots() throws Exception {
final HdfsAdmin dfsAdmin =
new HdfsAdmin(FileSystem.getDefaultUri(conf), conf);