Skip to content

HADOOP-17608. Fix TestKMS failure (#2880) #2929

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
package org.apache.hadoop.crypto.key.kms.server;

import java.util.function.Supplier;
import com.google.common.cache.LoadingCache;
import org.apache.curator.test.TestingServer;
import org.apache.hadoop.conf.Configuration;
Expand Down Expand Up @@ -91,7 +90,6 @@
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.LinkedBlockingQueue;
Expand All @@ -112,9 +110,6 @@
public class TestKMS {
private static final Logger LOG = LoggerFactory.getLogger(TestKMS.class);

private static final String SSL_RELOADER_THREAD_NAME =
"Truststore reloader thread";

private SSLFactory sslFactory;

// Keep track of all key providers created during a test case, so they can be
Expand Down Expand Up @@ -539,34 +534,6 @@ public Void call() throws Exception {
url.getProtocol().equals("https"));
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) {
for (String user : new String[]{"client", "client/host"}) {
doAs(user, new PrivilegedExceptionAction<Void>() {
Expand Down Expand Up @@ -2362,8 +2329,7 @@ public Void run() throws Exception {
return null;
}
});
// Close the client provider. We will verify all providers'
// Truststore reloader threads are closed later.
// Close the client provider.
kp.close();
return null;
} finally {
Expand All @@ -2374,22 +2340,6 @@ public Void run() throws Exception {
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
Expand Down