HDFS-10879. TestEncryptionZonesWithKMS#testReadWrite fails intermittently. Contributed by Xiao Chen.
(cherry picked from commit d31bef575478fe78c0600fb602e117e4b81c9887)
(cherry picked from commit 11ed4f5d40
)
This commit is contained in:
parent
f27cf17f7e
commit
d053d1c3ff
|
@ -157,6 +157,9 @@ Release 2.7.4 - UNRELEASED
|
||||||
HDFS-10512. VolumeScanner may terminate due to NPE in
|
HDFS-10512. VolumeScanner may terminate due to NPE in
|
||||||
DataNode.reportBadBlocks. Contributed by Wei-Chiu Chuang and Yiqun Lin.
|
DataNode.reportBadBlocks. Contributed by Wei-Chiu Chuang and Yiqun Lin.
|
||||||
|
|
||||||
|
HDFS-10879. TestEncryptionZonesWithKMS#testReadWrite fails intermittently.
|
||||||
|
(xiaochen)
|
||||||
|
|
||||||
Release 2.7.3 - 2016-08-25
|
Release 2.7.3 - 2016-08-25
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -46,6 +46,7 @@ import org.apache.hadoop.crypto.key.JavaKeyStoreProvider;
|
||||||
import org.apache.hadoop.crypto.key.KeyProvider;
|
import org.apache.hadoop.crypto.key.KeyProvider;
|
||||||
import org.apache.hadoop.crypto.key.KeyProviderCryptoExtension;
|
import org.apache.hadoop.crypto.key.KeyProviderCryptoExtension;
|
||||||
import org.apache.hadoop.crypto.key.KeyProviderFactory;
|
import org.apache.hadoop.crypto.key.KeyProviderFactory;
|
||||||
|
import org.apache.hadoop.crypto.key.kms.server.EagerKeyGeneratorKeyProviderCryptoExtension;
|
||||||
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
|
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
|
||||||
import org.apache.hadoop.fs.CreateFlag;
|
import org.apache.hadoop.fs.CreateFlag;
|
||||||
import org.apache.hadoop.fs.FSDataOutputStream;
|
import org.apache.hadoop.fs.FSDataOutputStream;
|
||||||
|
@ -635,14 +636,33 @@ public class TestEncryptionZones {
|
||||||
// Roll the key of the encryption zone
|
// Roll the key of the encryption zone
|
||||||
assertNumZones(1);
|
assertNumZones(1);
|
||||||
String keyName = dfsAdmin.listEncryptionZones().next().getKeyName();
|
String keyName = dfsAdmin.listEncryptionZones().next().getKeyName();
|
||||||
|
FileEncryptionInfo feInfo1 = getFileEncryptionInfo(encFile1);
|
||||||
cluster.getNamesystem().getProvider().rollNewVersion(keyName);
|
cluster.getNamesystem().getProvider().rollNewVersion(keyName);
|
||||||
|
/**
|
||||||
|
* due to the cache on the server side, client may get old keys.
|
||||||
|
* @see EagerKeyGeneratorKeyProviderCryptoExtension#rollNewVersion(String)
|
||||||
|
*/
|
||||||
|
boolean rollSucceeded = false;
|
||||||
|
for (int i = 0; i <= EagerKeyGeneratorKeyProviderCryptoExtension
|
||||||
|
.KMS_KEY_CACHE_SIZE_DEFAULT + CommonConfigurationKeysPublic.
|
||||||
|
KMS_CLIENT_ENC_KEY_CACHE_SIZE_DEFAULT; ++i) {
|
||||||
|
KeyProviderCryptoExtension.EncryptedKeyVersion ekv2 =
|
||||||
|
cluster.getNamesystem().getProvider().generateEncryptedKey(TEST_KEY);
|
||||||
|
if (!(feInfo1.getEzKeyVersionName()
|
||||||
|
.equals(ekv2.getEncryptionKeyVersionName()))) {
|
||||||
|
rollSucceeded = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Assert.assertTrue("rollover did not generate a new key even after"
|
||||||
|
+ " queue is drained", rollSucceeded);
|
||||||
|
|
||||||
// Read them back in and compare byte-by-byte
|
// Read them back in and compare byte-by-byte
|
||||||
verifyFilesEqual(fs, baseFile, encFile1, len);
|
verifyFilesEqual(fs, baseFile, encFile1, len);
|
||||||
// Write a new enc file and validate
|
// Write a new enc file and validate
|
||||||
final Path encFile2 = new Path(zone, "myfile2");
|
final Path encFile2 = new Path(zone, "myfile2");
|
||||||
DFSTestUtil.createFile(fs, encFile2, len, (short) 1, 0xFEED);
|
DFSTestUtil.createFile(fs, encFile2, len, (short) 1, 0xFEED);
|
||||||
// FEInfos should be different
|
// FEInfos should be different
|
||||||
FileEncryptionInfo feInfo1 = getFileEncryptionInfo(encFile1);
|
|
||||||
FileEncryptionInfo feInfo2 = getFileEncryptionInfo(encFile2);
|
FileEncryptionInfo feInfo2 = getFileEncryptionInfo(encFile2);
|
||||||
assertFalse("EDEKs should be different", Arrays
|
assertFalse("EDEKs should be different", Arrays
|
||||||
.equals(feInfo1.getEncryptedDataEncryptionKey(),
|
.equals(feInfo1.getEncryptedDataEncryptionKey(),
|
||||||
|
|
Loading…
Reference in New Issue