Skip to content

Commit

Permalink
#6565 additional checks to trace flaky test cause
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasz Mitusinski committed Jan 4, 2018
1 parent d03944b commit b3ed6f5
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;

import static com.twosigma.MessageAssertions.verifyExecuteReplyMessage;
import static com.twosigma.beakerx.MessageFactoryTest.getExecuteRequestMessage;
Expand Down Expand Up @@ -57,13 +58,32 @@ public void evaluate16Divide2() throws Exception {
Optional<Message> idleMessage = waitForIdleMessage(getKernelSocketsService().getKernelSockets());
assertThat(idleMessage).isPresent();
Optional<Message> result = waitForResult(getKernelSocketsService().getKernelSockets());
checkResultForErrors(result);
assertThat(result).isPresent();
verifyResult(result.get());
verifyPublishedMsgs(getKernelSocketsService());
waitForSentMessage(getKernelSocketsService().getKernelSockets());
verifySentMsgs(getKernelSocketsService());
}

private void checkResultForErrors(Optional<Message> result) throws InterruptedException {
if (!result.isPresent()){
Optional<Message> error = waitForErrorMessage(getKernelSocketsService().getKernelSockets());
String errorMsg;
if (error.isPresent()){
errorMsg = "Error message received instead of result:\n"
+ error.get().getContent().toString() + "\n";
} else {
errorMsg = "Result nor error messages found:\n" +
String.join(",",
getKernelSocketsService().getPublishedMessages().stream()
.map(m -> m.getHeader().getType())
.collect(Collectors.toList())) + "\n";
}
throw new AssertionError(errorMsg);
}
}

protected String codeFor16Divide2() {
return "16/2";
}
Expand Down

0 comments on commit b3ed6f5

Please sign in to comment.