Alexey Serbin has submitted this change and it was merged.

Change subject: KUDU-1976. java: use ephemeral ports for MiniKDC
......................................................................


KUDU-1976. java: use ephemeral ports for MiniKDC

This fixes an issue where Java tests would occasionally fail due to failure to
kinit as a principal just after adding it. We initially interpreted this as
a race, but it turns out to be an issue with concurrent test execution on
the same slave:

- We were using Testutils.findFreePort() to look for an open port. This was
  in turn calling TestUtils.getUniqueLocalHost() when it was testing binding
  to ports. Because it used the "unique localhost", it would always successfully
  bind on the first port it tried, since another concurrently-running test
  would not have used that port.

- Meanwhile, when we actually started the KDC, we bound it to 0.0.0.0:<port>
  rather than the unique loopback. This is because the KDC does not actually
  support specifying a bind-address.

- Even worse, the KDC would successfully start up in this case and only log
  a warning that it had failed to bind to the requested port. So, we'd merrily
  continue on our way with a lame-duck KDC.

The tests would often pass despite this, since we'd create our KDC, add a user
to it, and then connect to the _other_ test's KDC. That KDC would likely also
have the appropriate user "testuser". However there was a small window where
the other KDC would have started already but not yet created the "testuser"
user, in which case the test would fail.

This patch fixes the issue by following the same approach as the C++ tests:
we start the KDC on an ephemeral port and then use lsof to figure out which
port it picked.

Change-Id: I1e75d89616e6dbca6e8687eeb23f807c3c7eb952
Reviewed-on: http://gerrit.cloudera.org:8080/7850
Reviewed-by: Dan Burkert <danburk...@apache.org>
Tested-by: Alexey Serbin <aser...@cloudera.com>
---
M java/kudu-client/src/test/java/org/apache/kudu/client/MiniKdc.java
M java/kudu-client/src/test/java/org/apache/kudu/client/TestUtils.java
2 files changed, 87 insertions(+), 52 deletions(-)

Approvals:
  Dan Burkert: Looks good to me, approved
  Alexey Serbin: Verified



-- 
To view, visit http://gerrit.cloudera.org:8080/7850
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I1e75d89616e6dbca6e8687eeb23f807c3c7eb952
Gerrit-PatchSet: 4
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Todd Lipcon <t...@apache.org>
Gerrit-Reviewer: Alexey Serbin <aser...@cloudera.com>
Gerrit-Reviewer: Dan Burkert <danburk...@apache.org>
Gerrit-Reviewer: Todd Lipcon <t...@apache.org>

Reply via email to