Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
Fix a race condition in a test
Browse files Browse the repository at this point in the history
It's hard to set this up properly, the cancel request needs to be sent before the GetQueryExecution response with the successful status is returned. Using the number of requests sent works better since it's coupled with the mechanism that blocks the request.
  • Loading branch information
iconara committed May 13, 2019
1 parent d024170 commit 5c9e29c
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/test/java/io/burt/athena/AthenaStatementTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -422,9 +422,6 @@ void throwsAnException() {
class WhenCalledAfterExecute {
@Test
void sendsACancelRequest() throws Exception {
queryExecutionHelper.queueStartQueryResponse("Q1234");
queryExecutionHelper.queueGetQueryExecutionResponse(QueryExecutionState.SUCCEEDED);
ResultSet rs = statement.executeQuery("SELECT 1");
queryExecutionHelper.blockGetQueryExecutionResponse();
queryExecutionHelper.queueStartQueryResponse("Q2345");
queryExecutionHelper.queueGetQueryExecutionResponse(QueryExecutionState.RUNNING);
Expand All @@ -437,7 +434,8 @@ void sendsACancelRequest() throws Exception {
}
});
runner.start();
while (!rs.isClosed()) {
while (queryExecutionHelper.getQueryExecutionRequests().size() == 0) {
Thread.sleep(1);
}
statement.cancel();
queryExecutionHelper.unblockGetQueryExecutionResponse();
Expand Down

0 comments on commit 5c9e29c

Please sign in to comment.