Skip to content

Commit

Permalink
[BACKPORT pg15-cherrypicks][#23797] YSQL: Modify some tests to run in…
Browse files Browse the repository at this point in the history
… single connection mode with Connection Manager

Summary:
Merge resolution:
- TestYsqlUpgrade.java:
  - dmlsUpdatePgCache: YB pg15 bea1ffb
    removes test pinnedObjectsCacheIsUpdated that YB master
    dcf1821 touches.  Remove.
  - createPgTablegroupTableIfNotExists: YB pg15
    4638d7d modifies the function.  YB
    master dcf1821 moves it lower.
    Apply both.
  - class TableInfo: YB pg15 93f65c4
    adds arrayTypeOid handling.  YB master
    dcf1821 moves it higher.  Apply
    both.

Some tests test functionalities that would be requiring stickiness when run with Connection Manager. As these tests use a single connection, for the time being, allow the tests to strictly run in single connection mode until a feasible functionality change can be made. The tests include:

org.yb.pgsql.YsqlUpgrade.dmlsUpdatePgCache - This test modifies system tables, which can only be done by a superuser, requires stickiness
org.yb.pgsql.YsqlUpgrade.pinnedObjectsCacheIsUpdated - This test modifies system tables, which can only be done by a superuser, requires stickiness
org.yb.pgsql.TestPgRegressTypesUDT.testPgRegressTypesUDT - This test creates a base_type, which requires stickiness to be supported in Connection Manager
org.yb.pgsql.TestPgRegressPlanner.testPgRegressPlanner - This test modifies system tables, which can only be done by a superuser, requires stickiness
org.yb.pgsql.TestPgRegressThirdPartyExtensionsHypopg - hypopg indexes are contained in a single backend, stickiness would be needed

Jira: DB-12699

Test Plan: Jenkins: enable connection manager, test regex: .*YsqlUpgrade.dmlsUpdatePgCache|.*YsqlUpgrade.pinnedObjectsCacheIsUpdated|.*TestPgRegressTypesUDT.testPgRegressTypesUDT|.*TestPgRegressPlanner.testPgRegressPlanner|.*TestPgRegressThirdPartyExtensionsHypopg

Reviewers: tfoucher

Reviewed By: tfoucher

Subscribers: yql

Differential Revision: https://phorge.dev.yugabyte.com/D37990
  • Loading branch information
suranjan authored and jaki committed Sep 12, 2024
1 parent d1a90f7 commit edda58b
Show file tree
Hide file tree
Showing 8 changed files with 223 additions and 156 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ void setConnMgrWarmupModeAndRestartCluster(ConnectionManagerWarmupMode wm) throw

Map<String, String> tsFlagMap = getTServerFlags();
tsFlagMap.put("TEST_ysql_conn_mgr_dowarmup_all_pools_mode",
warmupMode.toString().toLowerCase());
wm.toString().toLowerCase());
warmupMode = wm;
Map<String, String> masterFlagMap = getMasterFlags();
restartClusterWithFlags(masterFlagMap, tsFlagMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import org.junit.Test;
import org.junit.runner.RunWith;
import org.yb.minicluster.MiniYBClusterBuilder;
import org.yb.util.YBTestRunnerNonTsanOnly;

/**
Expand All @@ -26,6 +27,12 @@ public int getTestMethodTimeoutSec() {
return 1800;
}

@Override
protected void customizeMiniClusterBuilder(MiniYBClusterBuilder builder) {
super.customizeMiniClusterBuilder(builder);
builder.addCommonTServerFlag("TEST_ysql_conn_mgr_dowarmup_all_pools_mode", "none");
}

@Test
public void testPgRegressPlanner() throws Exception {
runPgRegressTest("yb_planner_serial_schedule");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.yb.client.TestUtils;
import org.yb.minicluster.MiniYBClusterBuilder;
import org.yb.YBTestRunner;

import java.io.File;
Expand All @@ -26,6 +27,12 @@ public int getTestMethodTimeoutSec() {
return 1800;
}

@Override
protected void customizeMiniClusterBuilder(MiniYBClusterBuilder builder) {
super.customizeMiniClusterBuilder(builder);
builder.addCommonTServerFlag("TEST_ysql_conn_mgr_dowarmup_all_pools_mode", "none");
}

@Test
public void schedule() throws Exception {
runPgRegressTest(new File(TestUtils.getBuildRootDir(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import org.junit.Test;
import org.junit.runner.RunWith;
import org.yb.minicluster.MiniYBClusterBuilder;
import org.yb.YBTestRunner;

/**
Expand All @@ -26,6 +27,12 @@ public int getTestMethodTimeoutSec() {
return 1800;
}

@Override
protected void customizeMiniClusterBuilder(MiniYBClusterBuilder builder) {
super.customizeMiniClusterBuilder(builder);
builder.addCommonTServerFlag("TEST_ysql_conn_mgr_dowarmup_all_pools_mode", "none");
}

@Test
public void schedule() throws Exception {
runPgRegressTest("yb_types_udt_serial_schedule");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ private ScanInfo collectHashCodeScanInfo(Statement stmt, String selectList, int
selectList, kTableName, maxHashCode);
assertTrue(isIndexScan(stmt, query, kTableName + "_pkey"));
assertFalse(doesNeedPgFiltering(stmt, query));
if (isConnMgrWarmupRoundRobinMode()) {
for (int i = 0; i < CONN_MGR_WARMUP_BACKEND_COUNT; i++) {
stmt.execute(query);
}
}
return executeQueryAndCollectScanInfo(stmt, query);
}

Expand Down Expand Up @@ -195,6 +200,7 @@ private void testOneCase(

@Test
public void testScans() throws Exception {
setConnMgrWarmupModeAndRestartCluster(ConnectionManagerWarmupMode.ROUND_ROBIN);
try (Statement stmt = connection.createStatement()) {
// Note: In case of using yb_hash_code function all its argument columns are fetched.
// They are required for row recheck.
Expand Down
19 changes: 17 additions & 2 deletions java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgYbStat.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,15 @@ private void executeQueryAndExpectTempFileLimitExceeded(final String query,
private void executeQueryAndSendSignal(final String query,
final Connection inputConnection, final String signal) throws Exception {
try (Statement statement = inputConnection.createStatement()) {
final int pid = getPid(inputConnection);

int[] pids = new int[CONN_MGR_WARMUP_BACKEND_COUNT];
if (isConnMgrWarmupRoundRobinMode()) {
for (int i = 0; i < CONN_MGR_WARMUP_BACKEND_COUNT; i++){
pids[i] = getPid(inputConnection);
}
} else {
pids[0] = getPid(inputConnection);
}

final CountDownLatch startSignal = new CountDownLatch(1);
final List<ThrowingRunnable> cmds = new ArrayList<>();
Expand All @@ -83,7 +91,13 @@ private void executeQueryAndSendSignal(final String query,
startSignal.countDown();
startSignal.await();
Thread.sleep(100); // Allow the query execution a headstart before killing
ProcessUtil.signalProcess(pid, signal);
if (isConnMgrWarmupRoundRobinMode()) {
for (int i = 0; i < CONN_MGR_WARMUP_BACKEND_COUNT; i++) {
ProcessUtil.signalProcess(pids[i], signal);
}
} else {
ProcessUtil.signalProcess(pids[0], signal);
}
});
MiscUtil.runInParallel(cmds, startSignal, 60);
} catch (Throwable exception) {
Expand Down Expand Up @@ -146,6 +160,7 @@ private boolean waitUntilConditionSatisfiedOrTimeout(String query,

@Test
public void testYbTerminatedQueriesMultipleCauses() throws Exception {
setConnMgrWarmupModeAndRestartCluster(ConnectionManagerWarmupMode.ROUND_ROBIN);
// We need to restart the cluster to wipe the state currently contained in yb_terminated_queries
// that can potentially be leftover from another test in this class. This would let us start
// with a clean slate.
Expand Down
Loading

0 comments on commit edda58b

Please sign in to comment.