Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix session acquire timeout test #2793

Merged
merged 4 commits into from
Feb 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1166,8 +1166,8 @@ public void blockAndTimeoutOnPoolExhaustion() throws Exception {
latch.await();
// Wait until the request has timed out.
int waitCount = 0;
while (pool.getNumWaiterTimeouts() == 0L && waitCount < 1000) {
Thread.sleep(5L);
while (pool.getNumWaiterTimeouts() == 0L && waitCount < 5000) {
Thread.sleep(1L);
waitCount++;
}
// Return the checked out session to the pool so the async request will get a session and
Expand Down Expand Up @@ -1214,8 +1214,8 @@ public void blockAndTimeoutOnPoolExhaustion_withAcquireSessionTimeout() throws E
latch.await();
// Wait until the request has timed out.
int waitCount = 0;
while (pool.getNumWaiterTimeouts() == 0L && waitCount < 1000) {
Thread.sleep(5L);
while (pool.getNumWaiterTimeouts() == 0L && waitCount < 5000) {
Thread.sleep(1L);
waitCount++;
}
// Return the checked out session to the pool so the async request will get a session and
Expand Down Expand Up @@ -1639,15 +1639,16 @@ public void testSessionNotFoundPartitionedUpdate() {
assertThat(impl.executePartitionedUpdate(statement)).isEqualTo(1L);
}

@SuppressWarnings("rawtypes")
@Test
public void testSessionMetrics() throws Exception {
// Create a session pool with max 2 session and a low timeout for waiting for a session.
options =
SessionPoolOptions.newBuilder()
.setMinSessions(1)
.setMaxSessions(2)
.setMaxIdleSessions(0)
.setInitialWaitForSessionTimeoutMillis(50L)
.setAcquireSessionTimeout(null)
harshachinta marked this conversation as resolved.
Show resolved Hide resolved
.build();
FakeClock clock = new FakeClock();
clock.currentTimeMillis.set(System.currentTimeMillis());
Expand Down Expand Up @@ -1746,10 +1747,12 @@ public void testSessionMetrics() throws Exception {
latch.await();
// Wait until the request has timed out.
int waitCount = 0;
while (pool.getNumWaiterTimeouts() == 0L && waitCount < 1000) {
Thread.sleep(5L);
while (pool.getNumWaiterTimeouts() == 0L && waitCount < 5000) {
harshachinta marked this conversation as resolved.
Show resolved Hide resolved
//noinspection BusyWait
Thread.sleep(1L);
waitCount++;
}
assertTrue(pool.getNumWaiterTimeouts() > 0L);
// Return the checked out session to the pool so the async request will get a session and
// finish.
session2.close();
Expand Down
Loading