Skip to content

Commit

Permalink
[JENKINS-36871] Fix flaky test
Browse files Browse the repository at this point in the history
 - On machines with fewer cores than my machine, the selector thread may not have processed the interest removal and hence the test can fail randomly for lower spec machines
  • Loading branch information
stephenc committed Aug 11, 2016
1 parent 926307a commit 247f15b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/test/java/org/jenkinsci/remoting/protocol/IOHubTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,18 @@ public void onClosedChannel(ClosedChannelException e) {

// Wait for registration, in other case we get unpredictable timing related results due to late registration
while (key.get() == null) {
Thread.sleep(100);
Thread.sleep(10);
}

Socket client = new Socket();
client.setSoTimeout(100);
client.connect(srv.getLocalAddress(), 100);
assertThat(IOUtils.toString(client.getInputStream()), is("Go away #1"));
hub.hub().removeInterestAccept(key.get());
// wait for the interest accept to be removed
while ((key.get().interestOps() & SelectionKey.OP_ACCEPT) != 0) {
Thread.sleep(10);
}
client = new Socket();
client.setSoTimeout(100);
client.connect(srv.getLocalAddress(), 100);
Expand Down

0 comments on commit 247f15b

Please sign in to comment.