You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by el...@apache.org on 2016/10/10 19:10:05 UTC
[3/4] phoenix git commit: PHOENIX-3287 Retry starting KDC on
BindException
PHOENIX-3287 Retry starting KDC on BindException
MiniKDC has a race-condition in its port-allocation.
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/f5089591
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/f5089591
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/f5089591
Branch: refs/heads/4.8-HBase-1.0
Commit: f508959167c76e43d64e3cbd96fbc0e507d9bb88
Parents: e847759
Author: Josh Elser <el...@apache.org>
Authored: Fri Sep 23 14:29:50 2016 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Mon Oct 10 14:42:26 2016 -0400
----------------------------------------------------------------------
.../phoenix/jdbc/SecureUserConnectionsTest.java | 27 +++++++++++++++-----
1 file changed, 21 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/f5089591/phoenix-core/src/test/java/org/apache/phoenix/jdbc/SecureUserConnectionsTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/jdbc/SecureUserConnectionsTest.java b/phoenix-core/src/test/java/org/apache/phoenix/jdbc/SecureUserConnectionsTest.java
index a14e47b..4996f94 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/jdbc/SecureUserConnectionsTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/jdbc/SecureUserConnectionsTest.java
@@ -31,13 +31,14 @@ import java.util.List;
import java.util.Properties;
import org.apache.commons.io.FileUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeys;
import org.apache.hadoop.hbase.security.User;
import org.apache.hadoop.minikdc.MiniKdc;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.authentication.util.KerberosName;
-import org.apache.hadoop.security.authentication.util.KerberosUtil;
import org.apache.phoenix.jdbc.PhoenixEmbeddedDriver.ConnectionInfo;
import org.apache.phoenix.query.ConfigurationFactory;
import org.apache.phoenix.util.InstanceResolver;
@@ -54,6 +55,9 @@ import org.junit.Test;
* collide and when they do not.
*/
public class SecureUserConnectionsTest {
+ private static final Log LOG = LogFactory.getLog(SecureUserConnectionsTest.class);
+ private static final int KDC_START_ATTEMPTS = 10;
+
private static final File TEMP_DIR = new File(getClassTempDir());
private static final File KEYTAB_DIR = new File(TEMP_DIR, "keytabs");
private static final File KDC_DIR = new File(TEMP_DIR, "kdc");
@@ -68,11 +72,22 @@ public class SecureUserConnectionsTest {
public static void setupKdc() throws Exception {
ensureIsEmptyDirectory(KDC_DIR);
ensureIsEmptyDirectory(KEYTAB_DIR);
- // Create and start the KDC
- Properties kdcConf = MiniKdc.createConf();
- kdcConf.put(MiniKdc.DEBUG, true);
- KDC = new MiniKdc(kdcConf, KDC_DIR);
- KDC.start();
+ // Create and start the KDC. MiniKDC appears to have a race condition in how it does
+ // port allocation (with apache-ds). See PHOENIX-3287.
+ boolean started = false;
+ for (int i = 0; !started && i < KDC_START_ATTEMPTS; i++) {
+ Properties kdcConf = MiniKdc.createConf();
+ kdcConf.put(MiniKdc.DEBUG, true);
+ KDC = new MiniKdc(kdcConf, KDC_DIR);
+ try {
+ KDC.start();
+ started = true;
+ } catch (Exception e) {
+ LOG.warn("PHOENIX-3287: Failed to start KDC, retrying..", e);
+ }
+ }
+ assertTrue("The embedded KDC failed to start successfully after " + KDC_START_ATTEMPTS
+ + " attempts.", started);
createUsers(NUM_USERS);