Conversation
…ting Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
rrobetti
left a comment
There was a problem hiding this comment.
@copilot don't use scripts, I want a much simpler approach, just add a flag in the connection csv files and depending on that flag get a xa or standard jdbc(current) connection. then have each line in the csv files duplicate one for running with XA connection, one without.
I don't want to have to run a script to run tests.
No need for special report as well.
INTEGRATION_TESTING.md
Outdated
| ### Server-Side Handling | ||
|
|
||
| The OJP server handles both XA and non-XA connections simultaneously: | ||
| - XA connections use Atomikos transaction manager |
…signatures Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
Implemented as requested (commit 6a7acbd):
Tests will run twice per configuration - once in each mode. Completing connection creation logic updates for all test files. |
Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
| } | ||
|
|
||
| Connection conn = DriverManager.getConnection(url, user, pwd); | ||
| Connection conn; |
There was a problem hiding this comment.
@copilot put the logic of creating a connection in a helper class and reuse it everywhere
There was a problem hiding this comment.
Implemented (commits b2cf1e7 and 242dca5):
Added TestDBUtils.createConnection(url, user, password, isXA) helper method that returns a ConnectionResult containing both the Connection and optional XAConnection.
Refactored 11 test files to use the helper, eliminating duplicate connection creation logic. The pattern is now:
ConnectionResult connResult = TestDBUtils.createConnection(url, user, pwd, isXA);
Connection conn = connResult.getConnection();
// ... test code ...
connResult.close(); // Handles both connectionsThis centralizes the XA/JDBC branching logic and makes tests cleaner and more maintainable.
…amIntegrationTest Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
|
@copilot excude xa tests on maria db and MySQL. they are failing and their support to xa is known to be limited |
Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
Done (commit 2587c56). Removed XA test entries (
MySQL and MariaDB now only run in standard JDBC mode to avoid issues with their limited XA support. |
|
@copilot also remove all xa tests from H2 |
@copilot csv files not postgres related still have the XA flag |
The changes were completed in commit de6d2be. Here's what was done: CSV Files Updated:
Documentation:
Result: Only PostgreSQL tests now run in both XA and JDBC modes. All other databases run in JDBC mode only. |
|
|
||
| @SneakyThrows | ||
| public void setUp(String driverClass, String url, String user, String password) throws SQLException { | ||
| public void setUp(String driverClass, String url, String user, String password, boolean isXA) throws SQLException { |
There was a problem hiding this comment.
@copilot isXA still preset here, remove and remove from the CSV file.
|
|
||
| @SneakyThrows | ||
| public void setUp(String driverClass, String url, String user, String pwd) throws SQLException { | ||
| public void setUp(String driverClass, String url, String user, String pwd, boolean isXA) throws SQLException { |
There was a problem hiding this comment.
@copilot remove isXA from all non postgres tests.
| assumeFalse(isTestDisabled, "Skipping DB2 tests"); | ||
|
|
||
| Connection conn = DriverManager.getConnection(url, user, pwd); | ||
| ConnectionResult connResult = TestDBUtils.createConnection(url, user, pwd, isXA); |
There was a problem hiding this comment.
@copilot revert all changes done to non postgres files
| 101,org.openjproxy.jdbc.Driver,jdbc:ojp[localhost:1059]_db2://localhost:50000/testdb,db2inst1,testpass | ||
| 1000,org.openjproxy.jdbc.Driver,jdbc:ojp[localhost:1059]_db2://localhost:50000/testdb,db2inst1,testpass | ||
| 10000,org.openjproxy.jdbc.Driver,jdbc:ojp[localhost:1059]_db2://localhost:50000/testdb,db2inst1,testpass No newline at end of file | ||
| 1,org.openjproxy.jdbc.Driver,jdbc:ojp[localhost:1059]_db2://localhost:50000/testdb,db2inst1,testpass,false |
| @@ -1 +1 @@ | |||
| org.openjproxy.jdbc.Driver,jdbc:ojp[localhost:1059]_db2://localhost:50000/testdb,db2inst1,testpass No newline at end of file | |||
| org.openjproxy.jdbc.Driver,jdbc:ojp[localhost:1059]_db2://localhost:50000/testdb,db2inst1,testpass,false No newline at end of file | |||
| @@ -1 +1 @@ | |||
| org.openjproxy.jdbc.Driver,jdbc:ojp[localhost:1059]_postgresql://localhost:26257/defaultdb?sslmode=disable,root, | |||
| org.openjproxy.jdbc.Driver,jdbc:ojp[localhost:1059]_postgresql://localhost:26257/defaultdb?sslmode=disable,root,,false | |||
| 101,org.openjproxy.jdbc.Driver,jdbc:ojp[localhost:1059]_oracle:thin:@localhost:1521/XEPDB1,testuser,testpassword | ||
| 1000,org.openjproxy.jdbc.Driver,jdbc:ojp[localhost:1059]_oracle:thin:@localhost:1521/XEPDB1,testuser,testpassword | ||
| 10000,org.openjproxy.jdbc.Driver,jdbc:ojp[localhost:1059]_oracle:thin:@localhost:1521/XEPDB1,testuser,testpassword No newline at end of file | ||
| 1,org.openjproxy.jdbc.Driver,jdbc:ojp[localhost:1059]_oracle:thin:@localhost:1521/XEPDB1,testuser,testpassword,false |
There was a problem hiding this comment.
@copilot revert all changes done in non postgres related CSV source files, revert also the tests changed previously if they are non postgres.
Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
| import org.openjproxy.jdbc.xa.OjpXADataSource; | ||
| import javax.sql.XAConnection; | ||
| import openjproxy.jdbc.testutil.TestDBUtils; | ||
| import openjproxy.jdbc.testutil.TestDBUtils.ConnectionResult; |
| } | ||
|
|
||
| public void setUp(String driverClass, String url, String user, String pwd) throws SQLException, ClassNotFoundException { | ||
| public void setUp(String driverClass, String url, String user, String pwd, boolean isXA) throws SQLException, ClassNotFoundException { |
| @ParameterizedTest | ||
| @CsvFileSource(resources = "/cockroachdb_connection.csv") | ||
| public void testCockroachDBBasicConnection(String driverClass, String url, String user, String pwd) throws SQLException { | ||
| public void testCockroachDBBasicConnection(String driverClass, String url, String user, String pwd, boolean isXA) throws SQLException { |
| } | ||
|
|
||
| public void setUp(String driverClass, String url, String user, String password) throws Exception { | ||
| public void setUp(String driverClass, String url, String user, String password, boolean isXA) throws Exception { |
| @ParameterizedTest | ||
| @CsvFileSource(resources = "/cockroachdb_connection.csv") | ||
| public void typesCoverageTestSuccessful(String driverClass, String url, String user, String pwd) throws SQLException, ClassNotFoundException, ParseException { | ||
| public void typesCoverageTestSuccessful(String driverClass, String url, String user, String pwd, boolean isXA) throws SQLException, ClassNotFoundException, ParseException { |
| @@ -1 +1 @@ | |||
| org.openjproxy.jdbc.Driver,jdbc:ojp[localhost:1059]_h2:~/test,sa, No newline at end of file | |||
| org.openjproxy.jdbc.Driver,jdbc:ojp[localhost:1059]_h2:~/test,sa,,false No newline at end of file | |||
| org.openjproxy.jdbc.Driver,jdbc:ojp[localhost:1059]_h2:~/test,sa, | ||
| org.openjproxy.jdbc.Driver,jdbc:ojp[localhost:1059]_mysql://localhost:3306/defaultdb,testuser,testpassword | ||
| org.openjproxy.jdbc.Driver,jdbc:ojp[localhost:1059]_mariadb://localhost:3307/defaultdb,testuser,testpassword No newline at end of file | ||
| org.openjproxy.jdbc.Driver,jdbc:ojp[localhost:1059]_h2:~/test,sa,,false |
| org.openjproxy.jdbc.Driver,jdbc:ojp[localhost:1059]_mysql://localhost:3306/defaultdb,testuser,testpassword | ||
| org.openjproxy.jdbc.Driver,jdbc:ojp[localhost:1059]_mariadb://localhost:3307/defaultdb,testuser,testpassword | ||
| org.openjproxy.jdbc.Driver,jdbc:ojp[localhost:1059]_oracle:thin:@localhost:1521/XEPDB1,testuser,testpassword No newline at end of file | ||
| org.openjproxy.jdbc.Driver,jdbc:ojp[localhost:1059]_h2:~/test,sa,,false |
| @@ -1,2 +1,3 @@ | |||
| org.openjproxy.jdbc.Driver,jdbc:ojp[localhost:1059]_h2:~/test,sa, | |||
| org.openjproxy.jdbc.Driver,jdbc:ojp[localhost:1059]_oracle:thin:@localhost:1521/XEPDB1,testuser,testpassword No newline at end of file | |||
| org.openjproxy.jdbc.Driver,jdbc:ojp[localhost:1059]_h2:~/test,sa,,false | |||
| @@ -1 +1,2 @@ | |||
| org.openjproxy.jdbc.Driver,jdbc:ojp[localhost:1059]_postgresql://localhost:5432/defaultdb,testuser,testpassword | |||
| org.openjproxy.jdbc.Driver,jdbc:ojp[localhost:1059]_postgresql://localhost:5432/defaultdb,testuser,testpassword,false | |||
There was a problem hiding this comment.
@copilot there is no need for this file just use the postgres_connection.csv instead. Delete this file
…_xa_connection.csv Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
|
@copilot fix the error that follows by using the postgres connection file PostgresXAIntegrationTest.testXATransactionWithCRUD(String, String, String, String, boolean) » PreconditionViolation Classpath resource [/postgres_xa_connection.csv] does not exist |
PostgreSQL-Only XA Testing Implementation
This PR implements CSV-based test parameterization to run ojp-jdbc integration tests in both XA and standard JDBC modes, exclusively for PostgreSQL.
Final Changes
1. PostgreSQL-Only XA Testing ✅
postgres_connection.csvwith bothisXA=falseandisXA=trueentries2. Complete Reversion of Non-PostgreSQL Changes ✅
All non-PostgreSQL files reverted to their original state:
3. Documentation ✅
4. Test Infrastructure ✅
TestDBUtils.createConnection()helper functional for PostgreSQL XA/JDBC modesXADataSourceFactorywith PostgreSQL implementation5. How PostgreSQL XA Works
isXA=false: UsesDriverManager.getConnection()for standard JDBCisXA=true: UsesOjpXADataSource→ PostgreSQL XADataSource → proper XA transaction managementTestDBUtils.createConnection()properly handle both modesXAResource.commit()via ConnectionResult helperUsage
PostgreSQL tests run twice per configuration (XA and JDBC modes). All other databases run in their original configuration without any changes.
Adding XA Support for New Databases
See
ADDING_DATABASE_XA_SUPPORT.mdfor complete guide with PostgreSQL as reference implementation.Key Files
ADDING_DATABASE_XA_SUPPORT.md- Extension guideojp-jdbc-driver/src/test/resources/postgres_connection.csv- PostgreSQL with both XA and JDBC modesojp-jdbc-driver/src/test/java/openjproxy/jdbc/testutil/TestDBUtils.java- Connection helperojp-server/src/main/java/org/openjproxy/grpc/server/xa/XADataSourceFactory.java- XA factoryOriginal prompt
You are an automated coding/CI agent working on the Open-J-Proxy/ojp repository. Your task: run all current ojp-jdbc integration tests twice — once in XA mode and once in the current pure JDBC mode — and produce machine-readable test reports and a clear summary of results.
Requirements and steps:
Detect the repository build tool:
If pom.xml is present at the repo root (Maven), use Maven.
If build.gradle or build.gradle.kts is present (Gradle), use Gradle.
If neither is present, search for Java build hints and stop with an error describing what you found.
Locate the ojp-jdbc module/tests:
Prefer a module/directory named "ojp-jdbc" or artifactId "ojp-jdbc".
If no explicit module, find tests under src/test/java that reference packages/names that include "ojp" and "jdbc" or test class names that include "Jdbc", "JDBC", "IntegrationTest", or "IT".
If multiple candidate modules match, run tests for each candidate and include module name in the output.
Run the tests twice with identical test selection:
XA mode (explicitly enable XA).
Pure JDBC mode (explicitly disable XA or leave default).
For Maven (preferred commands):
Use the failsafe lifecycle (verify) if the project uses it for integration tests; otherwise run test.
Example (replace module selection if necessary):
XA: mvn -pl ojp-jdbc -am -Dojp.jdbc.xa=true -DskipTests=false -DfailIfNoTests=false -T1C verify
JDBC: mvn -pl ojp-jdbc -am -Dojp.jdbc.xa=false -DskipTests=false -DfailIfNoTests=false -T1C verify
Ensure the property name you set is the canonical one used by the project; if you find a different property or env var used to toggle XA in the code/config, use that instead.
Save reports to separate directories:
XA: target/surefire-reports-xa or target/failsafe-reports-xa
JDBC: target/surefire-reports-jdbc or target/failsafe-reports-jdbc
If the project already uses surefire/failsafe, copy or move the generated reports into the above-named directories after each run so they don’t get overwritten.
For Gradle (if build uses Gradle):
XA: ./gradlew :ojp-jdbc:test -Dojp.jdbc.xa=true --no-daemon --console=plain
JDBC: ./gradlew :ojp-jdbc:test -Dojp.jdbc.xa=false --no-daemon --console=plain
Use systemProp. prefix for properties if needed (e.g., -DsystemProp.ojp.jdbc.xa=true) based on gradle config.
Save/rename test-result directories after each run (build/test-results/test-xa, build/test-results/test-jdbc).
Test selection:
Run every test the module considers an integration test and all tests under ojp-jdbc module’s test sources.
If the repo separates unit vs integration tests (IT suffix, failsafe), run the integration tests specifically (use -DskipITs=false or failsafe's verify phase).
Capture and report:
After both runs, generate:
A pass/fail summary for each mode.
A combined list of failing tests (class, method, stack trace snippet) for each mode.
Paths to the JUnit XML / surefire/failsafe reports for each run.
Exit non-zero if any run had failing tests.
Robustness and logging:
Run each execution in a clean state (git clean -fdx or delete target/build outputs for the module) to avoid caching issues.
Use a maximum parallelism safe for CI (-T1C for maven or no parallel gradle test workers) unless the repo documents safe concurrency.
If a required property name to toggle XA is not obvious, search the codebase for "xa", "XADataSource", "XA", "ojp.jdbc.xa", "OJP_XA", or similar and use the matching configuration key. If multiple keys found, try the most likely one and log what you tried.
Optional (preferred): create a script at the repository root called run-ojp-jdbc-integration-tests.sh that:
Detects build tool and module as above.
Runs both modes, stores reports under ./test-reports/ojp-jdbc/xa and ./test-reports/ojp-jdbc/jdbc.
Produces a concise summary on stdout and writes a combined JSON summary at ./test-reports/ojp-jdbc/summary.json containing mode, status, failures[], report_paths[].
Make the script executable and include usage help.
Deliverables (what I want you to return):
The exact shell commands you ran (or that the generated script will run) for both modes.
The location of the saved test reports (JUnit XML / surefire/failsafe or Gradle test-results).
A concise summary showing pass/fail for XA mode and pure JDBC mode and failing test details (class, test name, failure message).
If you created a script or CI job, include the file path and its contents.
If you cannot run tests (e.g., missing external DB or credentials), detect that and:
Report the missing dependency and how to provide it (env vars, local DB image, or testcontainers).
If the repo includes docker-compose or testcontainers setup, prefer to use it; otherwise fail with an actionable message describing how to reproduce locally.
Notes:
Use the repository name Open-J-Proxy/ojp and run tests only for the ojp-jdbc code/tests.
Keep the agent’s actions auditable: list every command executed and any files you created/modified.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.