|
@@ -17,7 +17,6 @@
|
|
*/
|
|
*/
|
|
package org.apache.hadoop.crypto.key.kms.server;
|
|
package org.apache.hadoop.crypto.key.kms.server;
|
|
|
|
|
|
-import java.util.function.Supplier;
|
|
|
|
import org.apache.hadoop.thirdparty.com.google.common.cache.LoadingCache;
|
|
import org.apache.hadoop.thirdparty.com.google.common.cache.LoadingCache;
|
|
import org.apache.curator.test.TestingServer;
|
|
import org.apache.curator.test.TestingServer;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
@@ -92,7 +91,6 @@ import java.util.LinkedList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.Properties;
|
|
import java.util.Properties;
|
|
-import java.util.Set;
|
|
|
|
import java.util.UUID;
|
|
import java.util.UUID;
|
|
import java.util.concurrent.Callable;
|
|
import java.util.concurrent.Callable;
|
|
import java.util.concurrent.LinkedBlockingQueue;
|
|
import java.util.concurrent.LinkedBlockingQueue;
|
|
@@ -113,9 +111,6 @@ import static org.mockito.Mockito.when;
|
|
public class TestKMS {
|
|
public class TestKMS {
|
|
private static final Logger LOG = LoggerFactory.getLogger(TestKMS.class);
|
|
private static final Logger LOG = LoggerFactory.getLogger(TestKMS.class);
|
|
|
|
|
|
- private static final String SSL_RELOADER_THREAD_NAME =
|
|
|
|
- "Truststore reloader thread";
|
|
|
|
-
|
|
|
|
private SSLFactory sslFactory;
|
|
private SSLFactory sslFactory;
|
|
|
|
|
|
// Keep track of all key providers created during a test case, so they can be
|
|
// Keep track of all key providers created during a test case, so they can be
|
|
@@ -540,34 +535,6 @@ public class TestKMS {
|
|
url.getProtocol().equals("https"));
|
|
url.getProtocol().equals("https"));
|
|
final URI uri = createKMSUri(getKMSUrl());
|
|
final URI uri = createKMSUri(getKMSUrl());
|
|
|
|
|
|
- if (ssl) {
|
|
|
|
- KeyProvider testKp = createProvider(uri, conf);
|
|
|
|
- ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
|
|
|
|
- while (threadGroup.getParent() != null) {
|
|
|
|
- threadGroup = threadGroup.getParent();
|
|
|
|
- }
|
|
|
|
- Thread[] threads = new Thread[threadGroup.activeCount()];
|
|
|
|
- threadGroup.enumerate(threads);
|
|
|
|
- Thread reloaderThread = null;
|
|
|
|
- for (Thread thread : threads) {
|
|
|
|
- if ((thread.getName() != null)
|
|
|
|
- && (thread.getName().contains(SSL_RELOADER_THREAD_NAME))) {
|
|
|
|
- reloaderThread = thread;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- Assert.assertTrue("Reloader is not alive", reloaderThread.isAlive());
|
|
|
|
- // Explicitly close the provider so we can verify the internal thread
|
|
|
|
- // is shutdown
|
|
|
|
- testKp.close();
|
|
|
|
- boolean reloaderStillAlive = true;
|
|
|
|
- for (int i = 0; i < 10; i++) {
|
|
|
|
- reloaderStillAlive = reloaderThread.isAlive();
|
|
|
|
- if (!reloaderStillAlive) break;
|
|
|
|
- Thread.sleep(1000);
|
|
|
|
- }
|
|
|
|
- Assert.assertFalse("Reloader is still alive", reloaderStillAlive);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
if (kerberos) {
|
|
if (kerberos) {
|
|
for (String user : new String[]{"client", "client/host"}) {
|
|
for (String user : new String[]{"client", "client/host"}) {
|
|
doAs(user, new PrivilegedExceptionAction<Void>() {
|
|
doAs(user, new PrivilegedExceptionAction<Void>() {
|
|
@@ -2363,8 +2330,7 @@ public class TestKMS {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- // Close the client provider. We will verify all providers'
|
|
|
|
- // Truststore reloader threads are closed later.
|
|
|
|
|
|
+ // Close the client provider.
|
|
kp.close();
|
|
kp.close();
|
|
return null;
|
|
return null;
|
|
} finally {
|
|
} finally {
|
|
@@ -2375,22 +2341,6 @@ public class TestKMS {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
-
|
|
|
|
- // verify that providers created by KMSTokenRenewer are closed.
|
|
|
|
- if (ssl) {
|
|
|
|
- GenericTestUtils.waitFor(new Supplier<Boolean>() {
|
|
|
|
- @Override
|
|
|
|
- public Boolean get() {
|
|
|
|
- final Set<Thread> threadSet = Thread.getAllStackTraces().keySet();
|
|
|
|
- for (Thread t : threadSet) {
|
|
|
|
- if (t.getName().contains(SSL_RELOADER_THREAD_NAME)) {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- }, 1000, 10000);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|