HADOOP-14949. TestKMS#testACLs fails intermittently.
(cherry picked from commit 152317d40ece8abfa76fb5bd29f04878c1b0d3d8) Conflicts: hadoop-common-project/hadoop-kms/src/test/java/org/apache/hadoop/crypto/key/kms/server/TestKMS.java
This commit is contained in:
parent
53cd33cc4a
commit
0bddcf10ef
|
@ -326,4 +326,8 @@ public class KMSACLs implements Runnable, KeyACLs {
|
|||
|| whitelistKeyAcls.containsKey(opType));
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void forceNextReloadForTesting() {
|
||||
lastReload = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ package org.apache.hadoop.crypto.key.kms.server;
|
|||
import org.apache.hadoop.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
|
@ -31,6 +33,8 @@ import java.net.URL;
|
|||
@InterfaceAudience.Private
|
||||
public class KMSConfiguration {
|
||||
|
||||
static final Logger LOG = LoggerFactory.getLogger(KMSConfiguration.class);
|
||||
|
||||
public static final String KMS_CONFIG_DIR = "kms.config.dir";
|
||||
public static final String KMS_SITE_XML = "kms-site.xml";
|
||||
public static final String KMS_ACLS_XML = "kms-acls.xml";
|
||||
|
@ -120,6 +124,8 @@ public class KMSConfiguration {
|
|||
"' must be an absolute path: " + confDir);
|
||||
}
|
||||
File f = new File(confDir, KMS_ACLS_XML);
|
||||
LOG.trace("Checking file {}, modification time is {}, last reload time is"
|
||||
+ " {}", f.getPath(), f.lastModified(), time);
|
||||
// at least 100ms newer than time, we do this to ensure the file
|
||||
// has been properly closed/flushed
|
||||
newer = f.lastModified() - time > 100;
|
||||
|
|
|
@ -50,6 +50,7 @@ import org.junit.BeforeClass;
|
|||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.Timeout;
|
||||
import org.slf4j.event.Level;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.event.Level;
|
||||
|
@ -1444,12 +1445,11 @@ public class TestKMS {
|
|||
//stop the reloader, to avoid running while we are writing the new file
|
||||
KMSWebApp.getACLs().stopReloader();
|
||||
|
||||
GenericTestUtils.setLogLevel(KMSConfiguration.LOG, Level.TRACE);
|
||||
// test ACL reloading
|
||||
Thread.sleep(10); // to ensure the ACLs file modifiedTime is newer
|
||||
conf.set(KMSACLs.Type.CREATE.getAclConfigKey(), "foo");
|
||||
writeConf(testDir, conf);
|
||||
Thread.sleep(1000);
|
||||
|
||||
KMSWebApp.getACLs().forceNextReloadForTesting();
|
||||
KMSWebApp.getACLs().run(); // forcing a reload by hand.
|
||||
|
||||
// should not be able to create a key now
|
||||
|
|
Loading…
Reference in New Issue