Skip to content

Commit

Permalink
Refactor session polling (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyprime committed Feb 11, 2022
1 parent b3d9b51 commit 231704b
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4148,24 +4148,24 @@ class EndToEndTests(readOpts: Map[String, String], writeOpts: Map[String, String

// Poll sessions until they have cleaned up (or until we give up)
var success: Boolean = false
var i: Int = 0
while (!success || i < 10) {
var i: Int = 1
while (!success && i <= 10) {
Thread.sleep(1000)
val stmt = conn.createStatement()
val query = "SELECT COUNT(*) FROM v_monitor.sessions;"
try {
val rs = stmt.executeQuery(query)
rs.next
// Expect a single session for the session count query itself
// Note that this can fail if you are connected to vsql or performing other operations on the DB at the same time as these tests
success = (rs.getInt(1) == 1)
success = (rs.getInt(1) <= 1)
} catch {
case err : Exception => fail(err)
} finally {
stmt.close()
}
println("Unexpected session count, trying again - iteration " + i)
i += 1
Thread.sleep(1000)
}
assert(success)

Expand Down

0 comments on commit 231704b

Please sign in to comment.