You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by rl...@apache.org on 2015/08/12 21:28:48 UTC

ambari git commit: AMBARI-12774. Kerberos: Test KDC Connection succeeds but prints ERROR to ambari server log (rlevas)

Repository: ambari
Updated Branches:
  refs/heads/trunk 9e962270b -> 9e2e2b0d7


AMBARI-12774. Kerberos: Test KDC Connection succeeds but prints ERROR to ambari server log (rlevas)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9e2e2b0d
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9e2e2b0d
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9e2e2b0d

Branch: refs/heads/trunk
Commit: 9e2e2b0d7429ad73c249813d84204c8c6845a87e
Parents: 9e96227
Author: Robert Levas <rl...@hortonworks.com>
Authored: Wed Aug 12 15:28:43 2015 -0400
Committer: Robert Levas <rl...@hortonworks.com>
Committed: Wed Aug 12 15:28:50 2015 -0400

----------------------------------------------------------------------
 .../server/KdcServerConnectionVerification.java | 147 +++++------
 .../KdcServerConnectionVerificationTest.java    | 243 ++++++++++++-------
 2 files changed, 241 insertions(+), 149 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/9e2e2b0d/ambari-server/src/main/java/org/apache/ambari/server/KdcServerConnectionVerification.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/KdcServerConnectionVerification.java b/ambari-server/src/main/java/org/apache/ambari/server/KdcServerConnectionVerification.java
index e464800..aa23e44 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/KdcServerConnectionVerification.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/KdcServerConnectionVerification.java
@@ -18,10 +18,6 @@
 
 package org.apache.ambari.server;
 
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-import java.net.UnknownHostException;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.FutureTask;
@@ -46,12 +42,12 @@ import com.google.inject.Singleton;
  * It has two potential clients.
  * <ul>
  * <li>Ambari Agent:
- * 		Uses it to make sure host can talk to specified KDC Server
+ * Uses it to make sure host can talk to specified KDC Server
  * </li>
- *
+ * <p/>
  * <li>Ambari Server:
- * 		Uses it for connection check, like agent, and also validates
- * 		the credentials provided on Server side.
+ * Uses it for connection check, like agent, and also validates
+ * the credentials provided on Server side.
  * </li>
  * </ul>
  * </p>
@@ -64,9 +60,9 @@ public class KdcServerConnectionVerification {
   private Configuration config;
 
   /**
-   * UDP connection timeout in seconds.
+   * The connection timeout in seconds.
    */
-  private int udpTimeout = 10;
+  private int connectionTimeout = 10;
 
   @Inject
   public KdcServerConnectionVerification(Configuration config) {
@@ -88,7 +84,7 @@ public class KdcServerConnectionVerification {
         throw new IllegalArgumentException("Invalid hostname for KDC server");
       }
       String[] kdcDetails = kdcHost.split(":");
-      if (kdcDetails.length == 1)  {
+      if (kdcDetails.length == 1) {
         return isKdcReachable(kdcDetails[0], parsePort(config.getDefaultKdcPort()));
       } else {
         return isKdcReachable(kdcDetails[0], parsePort(kdcDetails[1]));
@@ -107,70 +103,47 @@ public class KdcServerConnectionVerification {
    * process for the give host and port.
    *
    * @param server KDC server IP or hostname
-   * @param port	 KDC port
-   * @return	true, if server is accepting connection given port; false otherwise.
+   * @param port   KDC port
+   * @return true, if server is accepting connection given port; false otherwise.
    */
   public boolean isKdcReachable(String server, int port) {
-    return isKdcReachableViaTCP(server, port) || isKdcReachableViaUDP(server, port);
-  }
+    boolean success = isKdcReachable(server, port, ConnectionProtocol.TCP) || isKdcReachable(server, port, ConnectionProtocol.UDP);
 
-  /**
-   * Attempt to connect to KDC server over TCP.
-   *
-   * @param server KDC server IP or hostname
-   * @param port	 KDC server port
-   * @return	true, if server is accepting connection given port; false otherwise.
-   */
-  public boolean isKdcReachableViaTCP(String server, int port) {
-    Socket socket = null;
-    try {
-      socket = new Socket();
-      socket.connect(new InetSocketAddress(server, port), config.getKdcConnectionCheckTimeout());
-    } catch (UnknownHostException e) {
-      LOG.error("Unable to resolve Kerberos Server hostname");
-      return false;
-    } catch (IOException e) {
-      LOG.error("Unable to connect to Kerberos Server");
-      return false;
-    } finally {
-      if (socket != null) {
-        try {
-          socket.close();
-        } catch (IOException e) {
-          LOG.debug("Error while closing socket connection to Kerberos Server. Can be ignored.");
-        }
-      }
+    if (!success) {
+      LOG.error("Failed to connect to the KDC at {}:{} using either TCP or UDP", server, port);
     }
 
-    return true;
+    return success;
   }
 
   /**
-   * Attempt to communicate with KDC server over UDP.
-   * @param server KDC hostname or IP address
-   * @param port   KDC server port
-   * @return  true if communication is successful; false otherwise
+   * Attempt to communicate with KDC server over a specified communication protocol (TCP or UDP).
+   *
+   * @param server         KDC hostname or IP address
+   * @param port           KDC server port
+   * @param connectionProtocol the type of connection to use
+   * @return true if communication is successful; false otherwise
    */
-  public boolean isKdcReachableViaUDP(final String server, final int port) {
-    int timeoutMillis = udpTimeout * 1000;
+  public boolean isKdcReachable(final String server, final int port, final ConnectionProtocol connectionProtocol) {
+    int timeoutMillis = connectionTimeout * 1000;
     final KdcConfig config = KdcConfig.getDefaultConfig();
     config.setHostName(server);
     config.setKdcPort(port);
-    config.setUseUdp(true);
+    config.setUseUdp(ConnectionProtocol.UDP == connectionProtocol);
     config.setTimeout(timeoutMillis);
 
-    final KdcConnection connection = getKdcUdpConnection(config);
     FutureTask<Boolean> future = new FutureTask<Boolean>(new Callable<Boolean>() {
       @Override
       public Boolean call() {
         try {
+          KdcConnection connection = getKdcConnection(config);
           // we are only testing whether we can communicate with server and not
           // validating credentials
           connection.getTgt("noUser@noRealm", "noPassword");
         } catch (KerberosException e) {
           // unfortunately, need to look at msg as error 60 is a generic error code
-          return ! (e.getErrorCode() == ErrorType.KRB_ERR_GENERIC.getValue() &&
-                    e.getMessage().contains("TimeOut"));
+          return !(e.getErrorCode() == ErrorType.KRB_ERR_GENERIC.getValue() &&
+              e.getMessage().contains("TimeOut"));
           //todo: evaluate other error codes to provide better information
           //todo: as there may be other error codes where we should return false
         } catch (Exception e) {
@@ -186,15 +159,44 @@ public class KdcServerConnectionVerification {
     try {
       // timeout after specified timeout
       result = future.get(timeoutMillis, TimeUnit.MILLISECONDS);
+
+      if (result) {
+        LOG.info(String.format("Successfully connected to the KDC server at %s:%d over %s",
+            server, port, connectionProtocol.name()));
+      } else {
+        LOG.warn(String.format("Failed to connect to the KDC server at %s:%d over %s",
+            server, port, connectionProtocol.name()));
+      }
     } catch (InterruptedException e) {
-      LOG.error("Interrupted while trying to communicate with KDC server over UDP");
+      String message = String.format("Interrupted while trying to communicate with KDC server at %s:%d over %s",
+          server, port, connectionProtocol.name());
+      if (LOG.isDebugEnabled()) {
+        LOG.warn(message, e);
+      } else {
+        LOG.warn(message);
+      }
+
       result = false;
       future.cancel(true);
     } catch (ExecutionException e) {
-      LOG.error("An unexpected exception occurred while attempting to communicate with the KDC server over UDP", e);
+      String message = String.format("An unexpected exception occurred while attempting to communicate with the KDC server at %s:%d over %s",
+          server, port, connectionProtocol.name());
+      if (LOG.isDebugEnabled()) {
+        LOG.warn(message, e);
+      } else {
+        LOG.warn(message);
+      }
+
       result = false;
     } catch (TimeoutException e) {
-      LOG.error("Timeout occurred while attempting to to communicate with KDC server over UDP");
+      String message = String.format("Timeout occurred while attempting to to communicate with KDC server at %s:%d over %s",
+          server, port, connectionProtocol.name());
+      if (LOG.isDebugEnabled()) {
+        LOG.warn(message, e);
+      } else {
+        LOG.warn(message);
+      }
+
       result = false;
       future.cancel(true);
     }
@@ -210,40 +212,49 @@ public class KdcServerConnectionVerification {
    * @param config KDC connection configuration
    * @return new KDC connection
    */
-  protected KdcConnection getKdcUdpConnection(KdcConfig config) {
+  protected KdcConnection getKdcConnection(KdcConfig config) {
     return new KdcConnection(config);
   }
 
   /**
-   * Set the UDP connection timeout.
-   * This is the amount of time that we will attempt to read data from UDP connection.
+   * Set the connection timeout.
+   * This is the amount of time that we will attempt to read data from connection.
    *
-   * @param timeoutSeconds  timeout in seconds
+   * @param timeoutSeconds timeout in seconds
    */
-  public void setUdpTimeout(int timeoutSeconds) {
-    udpTimeout = (timeoutSeconds < 1) ? 1 : timeoutSeconds;
+  public void setConnectionTimeout(int timeoutSeconds) {
+    connectionTimeout = (timeoutSeconds < 1) ? 1 : timeoutSeconds;
   }
 
   /**
-   * Get the UDP timeout value.
+   * Get the timeout value.
    *
-   * @return the UDP connection timeout value in seconds
+   * @return the connection timeout value in seconds
    */
-  public int getUdpTimeout() {
-    return udpTimeout;
+  public int getConnectionTimeout() {
+    return connectionTimeout;
   }
 
   /**
    * Parses port number from given string.
+   *
    * @param port port number string
-   * @throws NumberFormatException if given string cannot be parsed
-   * @throws IllegalArgumentException if given string is null or empty
    * @return parsed port number
+   * @throws NumberFormatException    if given string cannot be parsed
+   * @throws IllegalArgumentException if given string is null or empty
    */
-  private int parsePort(String port) {
+  protected int parsePort(String port) {
     if (StringUtils.isEmpty(port)) {
       throw new IllegalArgumentException("Port number must be non-empty, non-null positive integer");
     }
     return Integer.parseInt(port);
   }
+
+  /**
+   * A connection protocol to use to for connecting to the KDC
+   */
+  public enum ConnectionProtocol {
+    TCP,
+    UDP
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/9e2e2b0d/ambari-server/src/test/java/org/apache/ambari/server/api/rest/KdcServerConnectionVerificationTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/rest/KdcServerConnectionVerificationTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/rest/KdcServerConnectionVerificationTest.java
index da47eb2..948b6db 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/rest/KdcServerConnectionVerificationTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/rest/KdcServerConnectionVerificationTest.java
@@ -17,6 +17,8 @@
  */
 package org.apache.ambari.server.api.rest;
 
+import static org.apache.ambari.server.KdcServerConnectionVerification.ConnectionProtocol.TCP;
+import static org.apache.ambari.server.KdcServerConnectionVerification.ConnectionProtocol.UDP;
 import static org.easymock.EasyMock.createStrictMock;
 import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.replay;
@@ -25,25 +27,18 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
-import java.io.IOException;
-import java.net.ServerSocket;
-import java.net.SocketException;
 import java.util.Properties;
 
 import org.apache.ambari.server.KdcServerConnectionVerification;
 import org.apache.ambari.server.configuration.Configuration;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.directory.kerberos.client.KdcConfig;
 import org.apache.directory.kerberos.client.KdcConnection;
 import org.apache.directory.kerberos.client.TgTicket;
 import org.apache.directory.shared.kerberos.exceptions.ErrorType;
 import org.apache.directory.shared.kerberos.exceptions.KerberosException;
-import org.junit.AfterClass;
 import org.junit.Before;
-import org.junit.BeforeClass;
+import org.junit.Ignore;
 import org.junit.Test;
-import org.springframework.test.annotation.ExpectedException;
 
 
 /**
@@ -51,64 +46,175 @@ import org.springframework.test.annotation.ExpectedException;
  */
 public class KdcServerConnectionVerificationTest  {
 
-  private static Log LOG = LogFactory.getLog(KdcServerConnectionVerificationTest.class);
-
-  private KdcServerConnectionVerification kdcConnectionVerifier;
-  private Properties configProps;
   private Configuration configuration;
 
-  private static ServerSocket serverSocket = null;
-  private static boolean serverStop = false;
-
   private static final int KDC_TEST_PORT = 8090;
-  // Some dummy port to test a non-listening KDC server
-  private static final int DUMMY_KDC_PORT = 11234;
 
-  @BeforeClass
-  public static void beforeClass() throws Exception {
-    createSocketServer(KDC_TEST_PORT);
-  }
-
-  @AfterClass
-  public static void afterClass() throws Exception {
-    closeServerSocket();
-  }
-  
   @Before
   public void before() throws Exception {
-    configProps = new Properties();
+    Properties configProps = new Properties();
     configProps.setProperty(Configuration.KDC_PORT_KEY, Integer.toString(KDC_TEST_PORT));
     configuration = new Configuration(configProps);
-    kdcConnectionVerifier = new KdcServerConnectionVerification(configuration);     
   }
 
   @Test
-  public void testWithPortSuccess() throws Exception {
-    assertTrue(kdcConnectionVerifier.isKdcReachable(String.format("localhost:%d", KDC_TEST_PORT)));
+  public void testValidate__Fail_InvalidPort() throws Exception {
+    assertFalse(new KdcServerConnectionVerification(configuration).isKdcReachable("test-host:abcd"));
   }
 
   @Test
-  public void testWithoutPortSuccess() throws Exception {
-    assertTrue(kdcConnectionVerifier.isKdcReachable("localhost"));
+  public void testValidate__Success() throws Exception {
+    KdcConnection connection = createStrictMock(KdcConnection.class);
+
+    expect(connection.getTgt("noUser@noRealm", "noPassword")).andReturn(null).once();
+    replay(connection);
+
+    TestKdcServerConnectionVerification kdcConnVerifier =
+        new TestKdcServerConnectionVerification(configuration, connection);
+
+    boolean result = kdcConnVerifier.isKdcReachable("test-host:11111");
+    assertTrue(result);
+
+    KdcConfig kdcConfig = kdcConnVerifier.getConfigUsedInConnectionCreation();
+    assertEquals("test-host", kdcConfig.getHostName());
+    assertEquals(11111, kdcConfig.getKdcPort());
+    assertEquals(10 * 1000, kdcConfig.getTimeout());
+
+    verify(connection);
   }
 
   @Test
-  public void testWithoutPortFailure() throws Exception {
-    // Assumption: test machine has no KDC so nothing listening on port DUMMY_KDC_PORT
-    configProps.setProperty(Configuration.KDC_PORT_KEY, Integer.toString(DUMMY_KDC_PORT));
-    assertFalse(kdcConnectionVerifier.isKdcReachable("localhost"));
+  public void testValidateTCP__Successful() throws Exception {
+    KdcConnection connection = createStrictMock(KdcConnection.class);
+
+    expect(connection.getTgt("noUser@noRealm", "noPassword")).andReturn(null).once();
+    replay(connection);
+
+    TestKdcServerConnectionVerification kdcConnVerifier =
+        new TestKdcServerConnectionVerification(configuration, connection);
+
+    boolean result = kdcConnVerifier.isKdcReachable("test-host", 11111, TCP);
+    assertTrue(result);
+
+    KdcConfig kdcConfig = kdcConnVerifier.getConfigUsedInConnectionCreation();
+    assertFalse(kdcConfig.isUseUdp());
+    assertEquals("test-host", kdcConfig.getHostName());
+    assertEquals(11111, kdcConfig.getKdcPort());
+    assertEquals(10 * 1000, kdcConfig.getTimeout());
+
+    verify(connection);
   }
 
   @Test
-  public void testWithPortFailure() throws Exception {
-    assertFalse(kdcConnectionVerifier.isKdcReachable("localhost:8091"));
+  public void testValidateTCP__Successful2() throws Exception {
+    KdcConnection connection = createStrictMock(KdcConnection.class);
+
+    expect(connection.getTgt("noUser@noRealm", "noPassword")).andThrow(
+        new KerberosException(ErrorType.KDC_ERR_C_PRINCIPAL_UNKNOWN));
+    replay(connection);
+
+    TestKdcServerConnectionVerification kdcConnVerifier =
+        new TestKdcServerConnectionVerification(configuration, connection);
+
+    boolean result = kdcConnVerifier.isKdcReachable("test-host", 11111, TCP);
+    assertTrue(result);
+
+    KdcConfig kdcConfig = kdcConnVerifier.getConfigUsedInConnectionCreation();
+    assertFalse(kdcConfig.isUseUdp());
+    assertEquals("test-host", kdcConfig.getHostName());
+    assertEquals(11111, kdcConfig.getKdcPort());
+    assertEquals(10 * 1000, kdcConfig.getTimeout());
+
+    verify(connection);
   }
 
+  @Test
+  public void testValidateTCP__Fail_UnknownException() throws Exception {
+    KdcConnection connection = createStrictMock(KdcConnection.class);
+
+    expect(connection.getTgt("noUser@noRealm", "noPassword")).andThrow(
+        new RuntimeException("This is a really bad exception"));
+    replay(connection);
+
+    TestKdcServerConnectionVerification kdcConnVerifier =
+        new TestKdcServerConnectionVerification(configuration, connection);
+
+    boolean result = kdcConnVerifier.isKdcReachable("test-host", 11111, TCP);
+    assertFalse(result);
+
+    KdcConfig kdcConfig = kdcConnVerifier.getConfigUsedInConnectionCreation();
+    assertFalse(kdcConfig.isUseUdp());
+    assertEquals("test-host", kdcConfig.getHostName());
+    assertEquals(11111, kdcConfig.getKdcPort());
+    assertEquals(10 * 1000, kdcConfig.getTimeout());
+
+    verify(connection);
+  }
+
+  @Test
+  public void testValidateTCP__Fail_Timeout() throws Exception {
+    int timeout = 1;
+    KdcConnection connection = new BlockingKdcConnection(null);
+
+    TestKdcServerConnectionVerification kdcConnVerifier =
+        new TestKdcServerConnectionVerification(configuration, connection);
+
+    kdcConnVerifier.setConnectionTimeout(timeout);
+
+    boolean result = kdcConnVerifier.isKdcReachable("test-host", 11111, TCP);
+    assertFalse(result);
+
+    KdcConfig kdcConfig = kdcConnVerifier.getConfigUsedInConnectionCreation();
+    assertFalse(kdcConfig.isUseUdp());
+    assertEquals("test-host", kdcConfig.getHostName());
+    assertEquals(11111, kdcConfig.getKdcPort());
+    assertEquals(timeout * 1000, kdcConfig.getTimeout());
+  }
+
+  @Test
+  public void testValidateTCP__Fail_TimeoutErrorCode() throws Exception {
+    KdcConnection connection = createStrictMock(KdcConnection.class);
+
+    expect(connection.getTgt("noUser@noRealm", "noPassword")).andThrow(
+        new KerberosException(ErrorType.KRB_ERR_GENERIC, "TimeOut occurred"));
+    replay(connection);
+
+    TestKdcServerConnectionVerification kdcConnVerifier =
+        new TestKdcServerConnectionVerification(configuration, connection);
+
+    boolean result = kdcConnVerifier.isKdcReachable("test-host", 11111, TCP);
+    assertFalse(result);
+
+    KdcConfig kdcConfig = kdcConnVerifier.getConfigUsedInConnectionCreation();
+    assertFalse(kdcConfig.isUseUdp());
+    assertEquals("test-host", kdcConfig.getHostName());
+    assertEquals(11111, kdcConfig.getKdcPort());
+    assertEquals(10 * 1000, kdcConfig.getTimeout());
+
+    verify(connection);
+  }
 
   @Test
-  @ExpectedException(NumberFormatException.class)
-  public void testPortParsingFailure() throws Exception {
-    assertFalse(kdcConnectionVerifier.isKdcReachable("localhost:abc"));
+  public void testValidateTCP__Fail_GeneralErrorCode_NotTimeout() throws Exception {
+    KdcConnection connection = createStrictMock(KdcConnection.class);
+
+    expect(connection.getTgt("noUser@noRealm", "noPassword")).andThrow(
+        new KerberosException(ErrorType.KRB_ERR_GENERIC, "foo"));
+    replay(connection);
+
+    TestKdcServerConnectionVerification kdcConnVerifier =
+        new TestKdcServerConnectionVerification(configuration, connection);
+
+    boolean result = kdcConnVerifier.isKdcReachable("test-host", 11111, TCP);
+    assertTrue(result);
+
+    KdcConfig kdcConfig = kdcConnVerifier.getConfigUsedInConnectionCreation();
+    assertFalse(kdcConfig.isUseUdp());
+    assertEquals("test-host", kdcConfig.getHostName());
+    assertEquals(11111, kdcConfig.getKdcPort());
+    assertEquals(10 * 1000, kdcConfig.getTimeout());
+
+    verify(connection);
   }
 
   @Test
@@ -121,7 +227,7 @@ public class KdcServerConnectionVerificationTest  {
     TestKdcServerConnectionVerification kdcConnVerifier =
         new TestKdcServerConnectionVerification(configuration, connection);
 
-    boolean result = kdcConnVerifier.isKdcReachableViaUDP("test-host", 11111);
+    boolean result = kdcConnVerifier.isKdcReachable("test-host", 11111, UDP);
     assertTrue(result);
 
     KdcConfig kdcConfig = kdcConnVerifier.getConfigUsedInConnectionCreation();
@@ -144,7 +250,7 @@ public class KdcServerConnectionVerificationTest  {
     TestKdcServerConnectionVerification kdcConnVerifier =
         new TestKdcServerConnectionVerification(configuration, connection);
 
-    boolean result = kdcConnVerifier.isKdcReachableViaUDP("test-host", 11111);
+    boolean result = kdcConnVerifier.isKdcReachable("test-host", 11111, UDP);
     assertTrue(result);
 
     KdcConfig kdcConfig = kdcConnVerifier.getConfigUsedInConnectionCreation();
@@ -167,7 +273,7 @@ public class KdcServerConnectionVerificationTest  {
     TestKdcServerConnectionVerification kdcConnVerifier =
         new TestKdcServerConnectionVerification(configuration, connection);
 
-    boolean result = kdcConnVerifier.isKdcReachableViaUDP("test-host", 11111);
+    boolean result = kdcConnVerifier.isKdcReachable("test-host", 11111, UDP);
     assertFalse(result);
 
     KdcConfig kdcConfig = kdcConnVerifier.getConfigUsedInConnectionCreation();
@@ -187,9 +293,9 @@ public class KdcServerConnectionVerificationTest  {
     TestKdcServerConnectionVerification kdcConnVerifier =
         new TestKdcServerConnectionVerification(configuration, connection);
 
-    kdcConnVerifier.setUdpTimeout(timeout);
+    kdcConnVerifier.setConnectionTimeout(timeout);
 
-    boolean result = kdcConnVerifier.isKdcReachableViaUDP("test-host", 11111);
+    boolean result = kdcConnVerifier.isKdcReachable("test-host", 11111, UDP);
     assertFalse(result);
 
     KdcConfig kdcConfig = kdcConnVerifier.getConfigUsedInConnectionCreation();
@@ -210,7 +316,7 @@ public class KdcServerConnectionVerificationTest  {
     TestKdcServerConnectionVerification kdcConnVerifier =
         new TestKdcServerConnectionVerification(configuration, connection);
 
-    boolean result = kdcConnVerifier.isKdcReachableViaUDP("test-host", 11111);
+    boolean result = kdcConnVerifier.isKdcReachable("test-host", 11111, UDP);
     assertFalse(result);
 
     KdcConfig kdcConfig = kdcConnVerifier.getConfigUsedInConnectionCreation();
@@ -233,7 +339,7 @@ public class KdcServerConnectionVerificationTest  {
     TestKdcServerConnectionVerification kdcConnVerifier =
         new TestKdcServerConnectionVerification(configuration, connection);
 
-    boolean result = kdcConnVerifier.isKdcReachableViaUDP("test-host", 11111);
+    boolean result = kdcConnVerifier.isKdcReachable("test-host", 11111, UDP);
     assertTrue(result);
 
     KdcConfig kdcConfig = kdcConnVerifier.getConfigUsedInConnectionCreation();
@@ -245,39 +351,14 @@ public class KdcServerConnectionVerificationTest  {
     verify(connection);
   }
 
-
-  /**
-   * Socket server for test
-   * We need a separate thread as accept() is a blocking call
-   */
-  private static class SocketThread extends Thread {
-    public void run() {
-      while (serverSocket != null && !serverStop) {
-        try {
-          serverSocket.accept();
-        } catch (SocketException se) {
-          LOG.debug("SocketException during tearDown. Can be safely ignored");
-        } catch (IOException e) {
-          LOG.error("Unexpected exception while accepting connection request");
-        }
-      }
-
-    }
-  }
-
-  private static void createSocketServer(int port) throws Exception {
-    serverSocket = new ServerSocket(port);
-    new SocketThread().start();
+  @Test
+  @Ignore
+  public void testValidate__Live() throws Exception {
+    KdcServerConnectionVerification kdcConnVerifier = new KdcServerConnectionVerification(configuration);
+    boolean result = kdcConnVerifier.isKdcReachable("c6501:88");
+    assertTrue(result);
   }
 
-  private static void closeServerSocket() throws Exception {
-    serverStop = true;
-    try{
-      serverSocket.close();
-    } catch (IOException ioe) {
-      LOG.debug("IOException during tearDown. Can be safely ignored");
-    }
-  }
 
   // Test implementation which allows a mock KDC connection to be used.
   private static class TestKdcServerConnectionVerification extends KdcServerConnectionVerification {
@@ -290,7 +371,7 @@ public class KdcServerConnectionVerificationTest  {
     }
 
     @Override
-    protected KdcConnection getKdcUdpConnection(KdcConfig config) {
+    protected KdcConnection getKdcConnection(KdcConfig config) {
       kdcConfig = config;
       return connection;
     }