Skip to content

Commit

Permalink
[java client] Fix TestMiniKuduCluster flakiness
Browse files Browse the repository at this point in the history
Servers are now taking longer to start, and this test wasn't waiting
long enough most of the time.

Also fixed some javadoc, whoever wrote it (likely me) was not in a
right state of mind.

Change-Id: I0b524f9e70022d44b0095795cc364d7b8cb80b8b
Reviewed-on: http://gerrit.cloudera.org:8080/6058
Tested-by: Kudu Jenkins
Reviewed-by: Adar Dembo <[email protected]>
  • Loading branch information
jdcryans authored and adembo committed Feb 17, 2017
1 parent 6abafd7 commit 5080130
Showing 1 changed file with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class TestMiniKuduCluster {

private static final int NUM_TABLET_SERVERS = 3;
private static final int DEFAULT_NUM_MASTERS = 1;
private static final long SLEEP_TIME_MS = 10000;

@Test(timeout = 50000)
public void test() throws Exception {
Expand All @@ -38,30 +39,30 @@ public void test() throws Exception {
{
// Kill the master.
int masterPort = cluster.getMasterProcesses().keySet().iterator().next();
testPort(masterPort, true, 1000);
testPort(masterPort, true);
cluster.killMasterOnPort(masterPort);

testPort(masterPort, false, 2000);
testPort(masterPort, false);

// Restart the master.
cluster.restartDeadMasterOnPort(masterPort);

// Test we can reach it.
testPort(masterPort, true, 3000);
testPort(masterPort, true);
}

{
// Kill the first TS.
int tsPort = cluster.getTabletServerProcesses().keySet().iterator().next();
testPort(tsPort, true, 1000);
testPort(tsPort, true);
cluster.killTabletServerOnPort(tsPort);

testPort(tsPort, false, 2000);
testPort(tsPort, false);

// Restart it.
cluster.restartDeadTabletServerOnPort(tsPort);

testPort(tsPort, true, 3000);
testPort(tsPort, true);
}

assertEquals(DEFAULT_NUM_MASTERS, cluster.getMasterProcesses().size());
Expand All @@ -81,17 +82,14 @@ public void testKerberos() throws Exception {
}

/**
* Test without the specified is open or closed, waiting up to a certain time.
* The longer you expect it might for the socket to become open or closed.
* Test whether the specified port is open or closed, waiting up to a certain time.
* @param port the port to test
* @param testIsOpen true if we should want it to be open, false if we want it closed
* @param timeout how long we're willing to wait before it happens
*/
private static void testPort(int port,
boolean testIsOpen,
long timeout) throws InterruptedException {
boolean testIsOpen) throws InterruptedException {
DeadlineTracker tracker = new DeadlineTracker();
while (tracker.getElapsedMillis() < timeout) {
while (tracker.getElapsedMillis() < SLEEP_TIME_MS) {
try {
Socket socket = new Socket(TestUtils.getUniqueLocalhost(), port);
socket.close();
Expand Down

0 comments on commit 5080130

Please sign in to comment.