Skip to content

Commit

Permalink
[SPARK-23834][TEST] Wait for connection before disconnect in Launcher…
Browse files Browse the repository at this point in the history
…Server test.

It was possible that the disconnect() was called on the handle before the
server had received the handshake messages, so no connection was yet
attached to the handle. The fix waits until we're sure the handle has been
mapped to a client connection.

Author: Marcelo Vanzin <[email protected]>

Closes #20950 from vanzin/SPARK-23834.
  • Loading branch information
Marcelo Vanzin committed Apr 2, 2018
1 parent a7c19d9 commit 28ea4e3
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ public void testAppHandleDisconnect() throws Exception {
Socket s = new Socket(InetAddress.getLoopbackAddress(), server.getPort());
client = new TestClient(s);
client.send(new Hello(secret, "1.4.0"));
client.send(new SetAppId("someId"));

// Wait until we know the server has received the messages and matched the handle to the
// connection before disconnecting.
eventually(Duration.ofSeconds(1), Duration.ofMillis(10), () -> {
assertEquals("someId", handle.getAppId());
});

handle.disconnect();
waitForError(client, secret);
} finally {
Expand Down

0 comments on commit 28ea4e3

Please sign in to comment.