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