Skip to content

Commit b7393c6

Browse files
author
Manav Kumar
committed
[#30411] YSQL: Fix TestReserveYsqlInternalConns test on running with conn mgr
Summary: This diff fixes `org.yb.ysqlconnmgr.TestReserveYsqlInternalConns` when ran with `--enable-ysql-conn-mgr-test` flag. Before running the test, internal set-up creates physical connection to default user/db (yugabyte/yugabyte). Therefore on running the test for different pool, it reduces number of available backends from total `ysql_max_connections`. This diff overrides `verifyClusterAcceptsPGConnections` function to create internal set-up connections to PG so they get successfully closed. Test Plan: Jenkins: enable connection manager, test regex: .*ReserveYsqlInternalConns.* Make sure test passes with conn mgr flag: `./yb_build.sh --enable-ysql-conn-mgr-test --java-test org.yb.ysqlconnmgr.TestReserveYsqlInternalConns` Reviewers: skumar, arpit.saxena Reviewed By: arpit.saxena Subscribers: yql Differential Revision: https://phorge.dev.yugabyte.com/D50687
1 parent 9593905 commit b7393c6

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

java/yb-ysql-conn-mgr/src/test/java/org/yb/ysqlconnmgr/TestReserveYsqlInternalConns.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import org.junit.Test;
2626
import org.junit.runner.RunWith;
27+
import org.yb.client.TestUtils;
2728
import org.yb.minicluster.MiniYBClusterBuilder;
2829
import org.yb.pgsql.ConnectionEndpoint;
2930

@@ -59,6 +60,25 @@ protected void customizeMiniClusterBuilder(MiniYBClusterBuilder builder) {
5960
"superuser_reserved_connections=" + RESERVED_CONNS_FOR_NON_REPLICATION_SUPERUSER);
6061
}
6162

63+
// Before starting the test, avoid making connection to conn mgr end point
64+
// even when test is ran with --enable-ysql-conn-mgr flag.
65+
// Otherwise it creates extra backend to default user / db which limits number
66+
// of connection to other user/db & can cause test to fail.
67+
@Override
68+
public void verifyClusterAcceptsPGConnections() throws Exception {
69+
LOG.info("Waiting for the cluster to accept pg connections");
70+
TestUtils.waitFor(() -> {
71+
try {
72+
connectionBuilderForVerification(getConnectionBuilder())
73+
.withConnectionEndpoint(ConnectionEndpoint.POSTGRES)
74+
.connect().close();
75+
return true;
76+
} catch (Exception e) {
77+
return false;
78+
}
79+
}, 10000);
80+
}
81+
6282
private void createUser(String userName) throws Exception {
6383
try (Connection conn = getConnectionBuilder()
6484
.withConnectionEndpoint(ConnectionEndpoint.POSTGRES)

0 commit comments

Comments
 (0)