You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "zooo-code (via GitHub)" <gi...@apache.org> on 2026/02/01 14:59:46 UTC
[PR] [Feat][Connector-v2][JDBC][Oracle] Add Testcontainers-based unit tests [seatunnel]
zooo-code opened a new pull request, #10435:
URL: https://github.com/apache/seatunnel/pull/10435
### Purpose of this pull request
Add comprehensive Testcontainers-based unit tests for the Oracle JDBC connector to improve test coverage and enable CI execution.
This PR addresses issue #10212 by introducing Docker-based unit tests that can run in CI environments without requiring a local Oracle installation.
---
### Does this PR introduce _any_ user-facing change?
No.
This PR only adds unit tests for the Oracle connector. No functional changes to the connector itself.
---
### How was this patch tested?
#### New Tests Added
- `AbstractOracleContainerTest`: Base class providing Oracle container setup with ARM64 support
- `OracleCatalogContainerTest`: 9 tests for catalog operations (database/table management, complex types, primary keys)
- `OracleDialectContainerTest`: 15 tests for Oracle-specific SQL features (DUAL, ORA_HASH, identifier quoting, data sampling)
#### Test Environment
- Uses `gvenzl/oracle-free:23-slim` Docker image for ARM64 / Apple Silicon compatibility
- Configured with:
- 1GB shared memory
- 5-minute startup timeout
- Disabled on Windows for CI compatibility
#### Test Results
- Tests run: 570
- Failures: 0
- Errors: 0
- Skipped: 0
All 570 tests in the `connector-jdbc` module pass successfully, including 24 new Oracle tests.
#### Local Testing
```bash
cd seatunnel-connectors-v2/connector-jdbc
mvn test -Dtest=OracleCatalogContainerTest
mvn test -Dtest=OracleDialectContainerTest
```
### Check list
* [ ] If any new Jar binary package adding in your PR, please add License Notice according [New License Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/contribution/new-license.md)
* **N/A**: Only test dependencies added (Testcontainers), no new binary packages.
* [ ] If necessary, please update the documentation to describe the new feature. https://github.com/apache/seatunnel/tree/dev/docs
* **N/A**: Test-only changes, no user-facing features.
* [ ] If necessary, please update `incompatible-changes.md` to describe the incompatibility caused by this PR.
* **N/A**: No incompatible changes.
* [ ] If you are contributing the connector code, please check that the following files are updated:
* **N/A**: Not adding a new connector, only adding tests for existing Oracle connector.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feat][Connector-v2][JDBC][Oracle] Add Testcontainers-based unit tests [seatunnel]
Posted by "chl-wxp (via GitHub)" <gi...@apache.org>.
chl-wxp commented on code in PR #10435:
URL: https://github.com/apache/seatunnel/pull/10435#discussion_r2788107424
##########
seatunnel-connectors-v2/connector-jdbc/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/oracle/container/OracleDialectTest.java:
##########
@@ -0,0 +1,218 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.oracle.container;
+
+import org.apache.seatunnel.api.table.catalog.TablePath;
+import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.DatabaseIdentifier;
+import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.oracle.OracleDialect;
+import org.apache.seatunnel.connectors.seatunnel.jdbc.source.JdbcSourceTable;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.DisabledOnOs;
+import org.junit.jupiter.api.condition.OS;
+
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+/**
+ * Unit tests for OracleDialect using Testcontainers. Tests dialect-specific functionality like
+ * quoting, SQL generation, and data sampling.
+ */
+@DisabledOnOs(OS.WINDOWS)
+public class OracleDialectTest extends AbstractOracleContainerTest {
Review Comment:
Add `getInsertIntoStatement()`, `getUpdateStatement()`, `getDeleteStatement()`, `getRowExistsStatement()`, `getUpsertStatement()` and other corresponding unit tests, and it is best to add `FieldNamedPreparedStatement.prepareStatement()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feat][Connector-v2][JDBC][Oracle] Add Testcontainers-based unit tests [seatunnel]
Posted by "zooo-code (via GitHub)" <gi...@apache.org>.
zooo-code commented on code in PR #10435:
URL: https://github.com/apache/seatunnel/pull/10435#discussion_r2767904140
##########
seatunnel-connectors-v2/connector-jdbc/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/oracle/container/OracleDialectContainerTest.java:
##########
@@ -0,0 +1,216 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.oracle.container;
+
+import org.apache.seatunnel.api.table.catalog.TablePath;
+import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.DatabaseIdentifier;
+import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.oracle.OracleDialect;
+import org.apache.seatunnel.connectors.seatunnel.jdbc.source.JdbcSourceTable;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+/**
+ * Unit tests for OracleDialect using Testcontainers. Tests dialect-specific functionality like
+ * quoting, SQL generation, and data sampling.
+ */
+public class OracleDialectContainerTest extends AbstractOracleContainerTest {
+
+ private static OracleDialect dialect;
+ private static final String TEST_TABLE = "DIALECT_TEST_TABLE";
+
+ @BeforeAll
+ public static void setupDialect() throws SQLException {
+ dialect = new OracleDialect();
+
+ String createTableSql =
+ String.format(
+ "CREATE TABLE %s.%s ("
+ + "ID NUMBER(10) PRIMARY KEY, "
+ + "VARCHAR_COL VARCHAR2(100), "
+ + "NUMBER_COL NUMBER(10,2), "
+ + "DATE_COL DATE"
+ + ")",
+ quoteIdentifier(SCHEMA), quoteIdentifier(TEST_TABLE));
+
+ try (Statement stmt = connection.createStatement()) {
+ stmt.execute(createTableSql);
+ }
+
+ String insertSql =
+ String.format(
+ "INSERT INTO %s.%s (ID, VARCHAR_COL, NUMBER_COL, DATE_COL) "
+ + "VALUES (1, 'test1', 100.50, SYSDATE)",
+ quoteIdentifier(SCHEMA), quoteIdentifier(TEST_TABLE));
+ try (Statement stmt = connection.createStatement()) {
+ stmt.execute(insertSql);
+ // Note: Auto-commit is enabled by default, so no explicit commit needed
+ }
+ }
+
+ @Test
+ public void testDialectName() {
+ Assertions.assertEquals(DatabaseIdentifier.ORACLE, dialect.dialectName());
+ }
+
+ @Test
+ public void testQuoteIdentifier() {
+ Assertions.assertEquals("\"table_name\"", dialect.quoteIdentifier("table_name"));
+ Assertions.assertEquals("\"COLUMN\"", dialect.quoteIdentifier("COLUMN"));
+ }
+
+ @Test
+ public void testTableIdentifierWithSchema() {
+ // OracleDialect.tableIdentifier(String, String) ignores database parameter
+ String identifier = dialect.tableIdentifier(SCHEMA, TEST_TABLE);
+ Assertions.assertTrue(identifier.contains(TEST_TABLE));
+ }
+
+ @Test
+ public void testTableIdentifierWithTablePath() {
+ TablePath tablePath = TablePath.of(null, SCHEMA, TEST_TABLE);
+ String identifier = dialect.tableIdentifier(tablePath);
+ Assertions.assertTrue(identifier.contains(SCHEMA));
+ Assertions.assertTrue(identifier.contains(TEST_TABLE));
+ }
+
+ @Test
+ public void testParse() {
+ TablePath parsedPath = dialect.parse(SCHEMA + "." + TEST_TABLE);
+ Assertions.assertEquals(SCHEMA, parsedPath.getSchemaName());
+ Assertions.assertEquals(TEST_TABLE, parsedPath.getTableName());
+
+ TablePath singlePath = dialect.parse(TEST_TABLE);
+ Assertions.assertEquals(TEST_TABLE, singlePath.getTableName());
+ }
+
+ @Test
+ public void testHashModForField() {
+ String result = dialect.hashModForField("ID", 10);
+ Assertions.assertTrue(result.contains("MOD"));
+ Assertions.assertTrue(result.contains("ORA_HASH"));
+ Assertions.assertTrue(result.contains("\"ID\""));
+ Assertions.assertTrue(result.contains("10"));
+ }
+
+ @Test
+ public void testDualTable() {
+ String dualTable = dialect.dualTable();
+ Assertions.assertEquals(" FROM dual ", dualTable);
+ }
+
+ @Test
+ public void testSampleDataFromColumn() throws Exception {
+ TablePath tablePath = TablePath.of(DATABASE, SCHEMA, TEST_TABLE);
+ JdbcSourceTable table =
+ JdbcSourceTable.builder()
+ .tablePath(tablePath)
+ .useSelectCount(false)
+ .skipAnalyze(false)
+ .build();
+
+ Object[] samples = dialect.sampleDataFromColumn(connection, table, "ID", 1, 1024);
+ Assertions.assertNotNull(samples);
+ Assertions.assertTrue(samples.length > 0);
+ }
+
+ @Test
+ public void testSampleDataFromColumnWithQuery() throws Exception {
+ TablePath tablePath = TablePath.of(DATABASE, SCHEMA, TEST_TABLE);
+ JdbcSourceTable table =
+ JdbcSourceTable.builder()
+ .tablePath(tablePath)
+ .query(
+ "select * from "
+ + quoteIdentifier(SCHEMA)
+ + "."
+ + quoteIdentifier(TEST_TABLE)
+ + " where ID = 1")
+ .useSelectCount(false)
+ .skipAnalyze(false)
+ .build();
+
+ Object[] samples = dialect.sampleDataFromColumn(connection, table, "ID", 1, 1024);
+ Assertions.assertNotNull(samples);
+ }
+
+ @Test
+ public void testApproximateRowCntStatement() throws Exception {
+ TablePath tablePath = TablePath.of(DATABASE, SCHEMA, TEST_TABLE);
+ JdbcSourceTable table =
+ JdbcSourceTable.builder()
+ .tablePath(tablePath)
+ .useSelectCount(false)
+ .skipAnalyze(false)
+ .build();
+
+ Long rowCount = dialect.approximateRowCntStatement(connection, table);
+ Assertions.assertNotNull(rowCount);
+ Assertions.assertTrue(rowCount >= 0);
+ }
+
+ @Test
+ public void testQueryNextChunkMax() throws Exception {
+ TablePath tablePath = TablePath.of(DATABASE, SCHEMA, TEST_TABLE);
+ JdbcSourceTable table =
+ JdbcSourceTable.builder()
+ .tablePath(tablePath)
+ .useSelectCount(false)
+ .skipAnalyze(false)
+ .build();
+
+ Object maxValue = dialect.queryNextChunkMax(connection, table, "ID", 10, 0);
+ Assertions.assertNotNull(maxValue);
+ Assertions.assertEquals(1, ((Number) maxValue).intValue());
+ }
+
+ @Test
+ public void testGetRowConverter() {
+ Assertions.assertNotNull(dialect.getRowConverter());
+ }
+
+ @Test
+ public void testGetTypeConverter() {
+ Assertions.assertNotNull(dialect.getTypeConverter());
+ }
+
+ @Test
+ public void testGetJdbcDialectTypeMapper() {
+ Assertions.assertNotNull(dialect.getJdbcDialectTypeMapper());
+ }
+
+ @Test
+ public void testCreatPreparedStatement() throws Exception {
+ PreparedStatement preparedStatement =
+ dialect.creatPreparedStatement(
+ connection,
+ "SELECT * FROM "
+ + quoteIdentifier(SCHEMA)
+ + "."
+ + quoteIdentifier(TEST_TABLE),
+ 128);
+
+ Assertions.assertNotNull(preparedStatement);
Review Comment:
@LiJie20190102 I've changed it to use try-with-resources pattern to ensure the PreparedStatement is always closed. Fixed in the latest commit.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feat][Connector-v2][JDBC][Oracle] Add Testcontainers-based unit tests [seatunnel]
Posted by "zooo-code (via GitHub)" <gi...@apache.org>.
zooo-code commented on code in PR #10435:
URL: https://github.com/apache/seatunnel/pull/10435#discussion_r2767904140
##########
seatunnel-connectors-v2/connector-jdbc/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/oracle/container/OracleDialectContainerTest.java:
##########
@@ -0,0 +1,216 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.oracle.container;
+
+import org.apache.seatunnel.api.table.catalog.TablePath;
+import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.DatabaseIdentifier;
+import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.oracle.OracleDialect;
+import org.apache.seatunnel.connectors.seatunnel.jdbc.source.JdbcSourceTable;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+/**
+ * Unit tests for OracleDialect using Testcontainers. Tests dialect-specific functionality like
+ * quoting, SQL generation, and data sampling.
+ */
+public class OracleDialectContainerTest extends AbstractOracleContainerTest {
+
+ private static OracleDialect dialect;
+ private static final String TEST_TABLE = "DIALECT_TEST_TABLE";
+
+ @BeforeAll
+ public static void setupDialect() throws SQLException {
+ dialect = new OracleDialect();
+
+ String createTableSql =
+ String.format(
+ "CREATE TABLE %s.%s ("
+ + "ID NUMBER(10) PRIMARY KEY, "
+ + "VARCHAR_COL VARCHAR2(100), "
+ + "NUMBER_COL NUMBER(10,2), "
+ + "DATE_COL DATE"
+ + ")",
+ quoteIdentifier(SCHEMA), quoteIdentifier(TEST_TABLE));
+
+ try (Statement stmt = connection.createStatement()) {
+ stmt.execute(createTableSql);
+ }
+
+ String insertSql =
+ String.format(
+ "INSERT INTO %s.%s (ID, VARCHAR_COL, NUMBER_COL, DATE_COL) "
+ + "VALUES (1, 'test1', 100.50, SYSDATE)",
+ quoteIdentifier(SCHEMA), quoteIdentifier(TEST_TABLE));
+ try (Statement stmt = connection.createStatement()) {
+ stmt.execute(insertSql);
+ // Note: Auto-commit is enabled by default, so no explicit commit needed
+ }
+ }
+
+ @Test
+ public void testDialectName() {
+ Assertions.assertEquals(DatabaseIdentifier.ORACLE, dialect.dialectName());
+ }
+
+ @Test
+ public void testQuoteIdentifier() {
+ Assertions.assertEquals("\"table_name\"", dialect.quoteIdentifier("table_name"));
+ Assertions.assertEquals("\"COLUMN\"", dialect.quoteIdentifier("COLUMN"));
+ }
+
+ @Test
+ public void testTableIdentifierWithSchema() {
+ // OracleDialect.tableIdentifier(String, String) ignores database parameter
+ String identifier = dialect.tableIdentifier(SCHEMA, TEST_TABLE);
+ Assertions.assertTrue(identifier.contains(TEST_TABLE));
+ }
+
+ @Test
+ public void testTableIdentifierWithTablePath() {
+ TablePath tablePath = TablePath.of(null, SCHEMA, TEST_TABLE);
+ String identifier = dialect.tableIdentifier(tablePath);
+ Assertions.assertTrue(identifier.contains(SCHEMA));
+ Assertions.assertTrue(identifier.contains(TEST_TABLE));
+ }
+
+ @Test
+ public void testParse() {
+ TablePath parsedPath = dialect.parse(SCHEMA + "." + TEST_TABLE);
+ Assertions.assertEquals(SCHEMA, parsedPath.getSchemaName());
+ Assertions.assertEquals(TEST_TABLE, parsedPath.getTableName());
+
+ TablePath singlePath = dialect.parse(TEST_TABLE);
+ Assertions.assertEquals(TEST_TABLE, singlePath.getTableName());
+ }
+
+ @Test
+ public void testHashModForField() {
+ String result = dialect.hashModForField("ID", 10);
+ Assertions.assertTrue(result.contains("MOD"));
+ Assertions.assertTrue(result.contains("ORA_HASH"));
+ Assertions.assertTrue(result.contains("\"ID\""));
+ Assertions.assertTrue(result.contains("10"));
+ }
+
+ @Test
+ public void testDualTable() {
+ String dualTable = dialect.dualTable();
+ Assertions.assertEquals(" FROM dual ", dualTable);
+ }
+
+ @Test
+ public void testSampleDataFromColumn() throws Exception {
+ TablePath tablePath = TablePath.of(DATABASE, SCHEMA, TEST_TABLE);
+ JdbcSourceTable table =
+ JdbcSourceTable.builder()
+ .tablePath(tablePath)
+ .useSelectCount(false)
+ .skipAnalyze(false)
+ .build();
+
+ Object[] samples = dialect.sampleDataFromColumn(connection, table, "ID", 1, 1024);
+ Assertions.assertNotNull(samples);
+ Assertions.assertTrue(samples.length > 0);
+ }
+
+ @Test
+ public void testSampleDataFromColumnWithQuery() throws Exception {
+ TablePath tablePath = TablePath.of(DATABASE, SCHEMA, TEST_TABLE);
+ JdbcSourceTable table =
+ JdbcSourceTable.builder()
+ .tablePath(tablePath)
+ .query(
+ "select * from "
+ + quoteIdentifier(SCHEMA)
+ + "."
+ + quoteIdentifier(TEST_TABLE)
+ + " where ID = 1")
+ .useSelectCount(false)
+ .skipAnalyze(false)
+ .build();
+
+ Object[] samples = dialect.sampleDataFromColumn(connection, table, "ID", 1, 1024);
+ Assertions.assertNotNull(samples);
+ }
+
+ @Test
+ public void testApproximateRowCntStatement() throws Exception {
+ TablePath tablePath = TablePath.of(DATABASE, SCHEMA, TEST_TABLE);
+ JdbcSourceTable table =
+ JdbcSourceTable.builder()
+ .tablePath(tablePath)
+ .useSelectCount(false)
+ .skipAnalyze(false)
+ .build();
+
+ Long rowCount = dialect.approximateRowCntStatement(connection, table);
+ Assertions.assertNotNull(rowCount);
+ Assertions.assertTrue(rowCount >= 0);
+ }
+
+ @Test
+ public void testQueryNextChunkMax() throws Exception {
+ TablePath tablePath = TablePath.of(DATABASE, SCHEMA, TEST_TABLE);
+ JdbcSourceTable table =
+ JdbcSourceTable.builder()
+ .tablePath(tablePath)
+ .useSelectCount(false)
+ .skipAnalyze(false)
+ .build();
+
+ Object maxValue = dialect.queryNextChunkMax(connection, table, "ID", 10, 0);
+ Assertions.assertNotNull(maxValue);
+ Assertions.assertEquals(1, ((Number) maxValue).intValue());
+ }
+
+ @Test
+ public void testGetRowConverter() {
+ Assertions.assertNotNull(dialect.getRowConverter());
+ }
+
+ @Test
+ public void testGetTypeConverter() {
+ Assertions.assertNotNull(dialect.getTypeConverter());
+ }
+
+ @Test
+ public void testGetJdbcDialectTypeMapper() {
+ Assertions.assertNotNull(dialect.getJdbcDialectTypeMapper());
+ }
+
+ @Test
+ public void testCreatPreparedStatement() throws Exception {
+ PreparedStatement preparedStatement =
+ dialect.creatPreparedStatement(
+ connection,
+ "SELECT * FROM "
+ + quoteIdentifier(SCHEMA)
+ + "."
+ + quoteIdentifier(TEST_TABLE),
+ 128);
+
+ Assertions.assertNotNull(preparedStatement);
Review Comment:
@LiJie20190102 I've changed it to use try-with-resources pattern toensure the PreparedStatement is always closed. Fixed in the latest commit.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feat][Connector-v2][JDBC][Oracle] Add Testcontainers-based unit tests [seatunnel]
Posted by "DanielCarter-stack (via GitHub)" <gi...@apache.org>.
DanielCarter-stack commented on PR #10435:
URL: https://github.com/apache/seatunnel/pull/10435#issuecomment-3832926343
<!-- code-pr-reviewer -->
<!-- cpr:pr_reply_v2_parts {"group": "apache/seatunnel#10435", "part": 1, "total": 1} -->
## Issue 1: Test method lacks assertions
**Location**: `OracleDialectContainerTest.java:172-183`
```java
@Test
public void testQueryNextChunkMax() throws Exception {
TablePath tablePath = TablePath.of(DATABASE, SCHEMA, TEST_TABLE);
JdbcSourceTable table =
JdbcSourceTable.builder()
.tablePath(tablePath)
.useSelectCount(false)
.skipAnalyze(false)
.build();
Object maxValue = dialect.queryNextChunkMax(connection, table, "ID", 10, 0);
}
```
**Related Context**:
- Reference: `DuckDBDialectTest.java:167-173` has complete assertions for the same method
- Method under test: `OracleDialect.queryNextChunkMax()` (OracleDialect.java:263-310)
**Problem Description**:
This test method calls `queryNextChunkMax()` but does not perform any assertion verification on the return value. Referencing the same test in `DuckDBDialectTest`, the returned maximum value should be verified as expected. The current implementation will "pass" even if the method returns null or throws an exception (unless the exception directly causes failure).
**Potential Risks**:
- Cannot verify the logic correctness of `queryNextChunkMax()`
- Cannot catch regression issues (e.g., future modifications breaking this method)
- False high test coverage (method is called but not verified)
**Impact Scope**:
- Direct impact: `OracleDialect.queryNextChunkMax()` method
- Indirect impact: Oracle data source reading functionality that depends on chunk sharding
- Affected area: Oracle Connector's data sharding logic
**Severity**: MAJOR
**Improvement Suggestions**:
```java
@Test
public void testQueryNextChunkMax() throws Exception {
TablePath tablePath = TablePath.of(DATABASE, SCHEMA, TEST_TABLE);
JdbcSourceTable table =
JdbcSourceTable.builder()
.tablePath(tablePath)
.useSelectCount(false)
.skipAnalyze(false)
.build();
// Test first chunk
Object firstChunkMax = dialect.queryNextChunkMax(connection, table, "ID", 3, 1);
Assertions.assertNotNull(firstChunkMax);
Assertions.assertEquals(1, ((Number) firstChunkMax).intValue());
// Test second chunk
Object secondChunkMax = dialect.queryNextChunkMax(connection, table, "ID", 3, 1);
Assertions.assertNotNull(secondChunkMax);
// Should return the only ID value (1) since table only has one row
Assertions.assertEquals(1, ((Number) secondChunkMax).intValue());
}
```
**Rationale**: Referencing the implementation of `DuckDBDialectTest`, the return value should be verified as expected. Since only one row of data (ID=1) was inserted in the test table, the chunk sharding should correctly handle this case.
---
## Issue 2: Testcontainers version is outdated
**Location**: `pom.xml:431-439`
```xml
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>oracle-xe</artifactId>
<version>${testcontainer.version}</version>
<scope>test</scope>
</dependency>
```
**Related Context**:
- Parent POM definition: `testcontainer.version = 1.17.6` (pom.xml:141)
- Other modules in the project: connector-databend-e2e uses 1.20.2, connector-hudi-e2e uses 1.19.1
**Problem Description**:
Testcontainers 1.17.6 was released in 2022 and is relatively old. Although this version works, there are the following issues:
1. Lacks new features and bug fixes
2. May have known security issues
3. Inconsistent with versions used in other modules of the project (e.g., databend 1.20.2)
**Potential Risks**:
- Possible unfixed bugs affecting test stability
- Compatibility issues with newer Docker/Java versions
- Security vulnerabilities (although test dependencies don't affect production, CI environment is still affected)
**Impact Scope**:
- Direct impact: Oracle tests in the connector-jdbc module
- Indirect impact: Test execution in CI environment
- Affected area: Test dependencies of a single module
**Severity**: MINOR
**Improvement Suggestions**:
Consider upgrading Testcontainers to version 1.19.x or 1.20.x to align with other modules in the project. However, this requires:
1. Upgrading the `testcontainer.version` property in the parent POM
2. Verifying compatibility of all modules using Testcontainers
3. Handling in a separate issue, should not block the current PR
**Rationale**: Although the version is old, it does not affect functionality. Suggested as a follow-up optimization item to be handled together when upgrading Testcontainers version globally.
---
## Issue 3: Debug output should use logging framework
**Location**:
- `OracleCatalogContainerTest.java:52`
- `OracleCatalogContainerTest.java:180`
```java
System.out.println("Available databases: " + databases);
System.out.println("Tables found: " + tables);
```
**Related Context**:
- Production code uses Slf4j + Logback (see OracleDialect.java:39 uses `@Slf4j`)
- Test code should also follow unified standards
**Problem Description**:
Test code uses `System.out.println` for debug output instead of using a logging framework. This practice in CI environments may lead to:
1. Inconsistent log output format
2. Unable to control output through log levels
3. Confused output during concurrent testing
**Potential Risks**:
- Reduced CI log readability
- Unable to disable debug output through configuration
- Inconsistent with project logging standards
**Impact Scope**:
- Direct impact: Log output of OracleCatalogContainerTest
- Indirect impact: CI log readability
- Affected area: Test code quality
**Severity**: MINOR
**Improvement Suggestions**:
```java
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class OracleCatalogContainerTest extends AbstractOracleContainerTest {
@Test
public void testDatabaseExists() {
List<String> databases = catalog.listDatabases();
log.info("Available databases: {}", databases);
// ...
}
@Test
public void testListTables() throws SQLException {
// ...
log.info("Tables found: {}", tables);
// ...
}
}
```
**Rationale**: Using Slf4j maintains consistency with the project's logging framework, supports log level control, and avoids generating excessive noise in CI. For debug information, `log.debug()` should be used instead of `log.info()`, or removed after confirming test stability.
---
## Issue 4: Windows platform disablement lacks documentation
**Location**: `AbstractOracleContainerTest.java:40`
```java
@DisabledOnOs(OS.WINDOWS)
public abstract class AbstractOracleContainerTest {
```
**Related Context**:
- PR description mentions "Disabled on Windows for CI compatibility"
- Other test classes do not use this annotation (e.g., DuckDBDialectTest)
**Problem Description**:
The test uses `@DisabledOnOs(OS.WINDOWS)` to disable the Windows platform, but does not explain the reason in JavaDoc or code comments. This may lead to:
1. Confusion among Windows developers about why the test is skipped
2. Unclear whether it's a Docker Desktop for Windows limitation or other reasons
**Potential Risks**:
- Windows developers may mistakenly think there's an issue with the test
- Cannot track whether there are plans to support Windows in the future
**Impact Scope**:
- Direct impact: Developers on Windows platform
- Indirect impact: Test documentation completeness
- Affected area: Cross-platform test support
**Severity**: MINOR
**Improvement Suggestions**:
```java
/**
* Base class for Oracle Testcontainers-based unit tests. Provides shared Oracle container setup and
* connection management.
*
* <p>Note: Tests are disabled on Windows due to Docker Desktop limitations with shared memory
* configuration required by Oracle container. Use WSL2 or Linux/macOS for running these tests.
*/
@DisabledOnOs(OS.WINDOWS)
public abstract class AbstractOracleContainerTest {
```
**Rationale**: Documenting the reason for disablement in JavaDoc helps Windows developers understand the limitation and provides alternative solutions (WSL2).
---
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feat][Connector-v2][JDBC][Oracle] Add Testcontainers-based unit tests [seatunnel]
Posted by "zooo-code (via GitHub)" <gi...@apache.org>.
zooo-code commented on PR #10435:
URL: https://github.com/apache/seatunnel/pull/10435#issuecomment-3852854499
I followed the pattern in #10252 PR, with a few adjustments to align with project conventions
- Disabled tests on Windows due to missing Docker environment in CI
- Renamed test classes to align with naming conventions (removed "Container")
- Applied try-with-resources
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feat][Connector-v2][JDBC][Oracle] Add Testcontainers-based unit tests [seatunnel]
Posted by "zooo-code (via GitHub)" <gi...@apache.org>.
zooo-code commented on PR #10435:
URL: https://github.com/apache/seatunnel/pull/10435#issuecomment-3877198662
> Thank you for your contribution. Could you migrate the unit tests from the jdbc-e2e module to connector-jdbc later? Or could you submit them together this time
Thanks for the approval! @LiJie20190102
I am open to both approaches.
If you prefer merging them together in this PR, I can work on the migration now.
Or, if you prefer keeping this PR focused, I can submit a separate PR for the migration later.
Please let me know which one you prefer!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feat][Connector-v2][JDBC][Oracle] Add Testcontainers-based unit tests [seatunnel]
Posted by "zooo-code (via GitHub)" <gi...@apache.org>.
zooo-code commented on code in PR #10435:
URL: https://github.com/apache/seatunnel/pull/10435#discussion_r2793669027
##########
seatunnel-connectors-v2/connector-jdbc/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/oracle/container/OracleDialectTest.java:
##########
@@ -0,0 +1,218 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.oracle.container;
+
+import org.apache.seatunnel.api.table.catalog.TablePath;
+import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.DatabaseIdentifier;
+import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.oracle.OracleDialect;
+import org.apache.seatunnel.connectors.seatunnel.jdbc.source.JdbcSourceTable;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.DisabledOnOs;
+import org.junit.jupiter.api.condition.OS;
+
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+/**
+ * Unit tests for OracleDialect using Testcontainers. Tests dialect-specific functionality like
+ * quoting, SQL generation, and data sampling.
+ */
+@DisabledOnOs(OS.WINDOWS)
+public class OracleDialectTest extends AbstractOracleContainerTest {
Review Comment:
@chl-wxp Thanks for the review!
I've added all the requested tests as suggested.
(10 new tests)
1. DML Statements
- Covered Insert, Update, Delete, RowExists, and Upsert logic.
2. FieldNamedPreparedStatement
- Covered parameter parsing, duplicate handling, and execution.
All tests passed locally.
Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feat][Connector-v2][JDBC][Oracle] Add Testcontainers-based unit tests [seatunnel]
Posted by "zooo-code (via GitHub)" <gi...@apache.org>.
zooo-code commented on code in PR #10435:
URL: https://github.com/apache/seatunnel/pull/10435#discussion_r2767899226
##########
seatunnel-connectors-v2/connector-jdbc/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/oracle/container/AbstractOracleContainerTest.java:
##########
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.oracle.container;
+
+import org.apache.seatunnel.connectors.seatunnel.jdbc.catalog.oracle.OracleCatalog;
+import org.apache.seatunnel.connectors.seatunnel.jdbc.catalog.oracle.OracleURLParser;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.condition.DisabledOnOs;
+import org.junit.jupiter.api.condition.OS;
+import org.testcontainers.containers.OracleContainer;
+import org.testcontainers.utility.DockerImageName;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.time.Duration;
+
+/**
+ * Base class for Oracle Testcontainers-based unit tests. Provides shared Oracle container setup and
+ * connection management.
+ */
+@DisabledOnOs(OS.WINDOWS)
+public abstract class AbstractOracleContainerTest {
+
+ protected static final String ORACLE_IMAGE = "gvenzl/oracle-free:23-slim";
+ protected static final String USERNAME = "TESTUSER";
+ protected static final String PASSWORD = "testPassword";
+ protected static final String DATABASE = "XE";
+ protected static final String SCHEMA = USERNAME;
+
+ protected static OracleContainer oracleContainer;
+ protected static Connection connection;
+ protected static OracleCatalog catalog;
+
+ @BeforeAll
+ public static void startContainer() throws SQLException {
+ DockerImageName imageName =
+ DockerImageName.parse(ORACLE_IMAGE).asCompatibleSubstituteFor("gvenzl/oracle-xe");
+
+ oracleContainer =
+ new OracleContainer(imageName)
+ .withDatabaseName(DATABASE)
+ .withUsername(USERNAME)
+ .withPassword(PASSWORD)
+ .withSharedMemorySize(1073741824L) // 1GB shared memory
+ .withStartupTimeout(Duration.ofMinutes(5)) // Increase timeout for ARM
+ .withEnv("ORACLE_CHARACTERSET", "AL32UTF8")
+ .withReuse(false);
+
+ oracleContainer.start();
+
+ String jdbcUrl = oracleContainer.getJdbcUrl();
+ connection =
+ DriverManager.getConnection(
+ jdbcUrl, oracleContainer.getUsername(), oracleContainer.getPassword());
+
+ catalog =
+ new OracleCatalog(
+ "oracle",
+ oracleContainer.getUsername(),
+ oracleContainer.getPassword(),
+ OracleURLParser.parse(jdbcUrl),
+ SCHEMA,
+ null);
+ catalog.open();
+ }
+
+ @AfterAll
+ public static void stopContainer() throws SQLException {
+ if (catalog != null) {
+ catalog.close();
Review Comment:
Added try-catch blocks to ensure all resources are closed even if catalog.close() throws an exception.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feat][Connector-v2][JDBC][Oracle] Add Testcontainers-based unit tests [seatunnel]
Posted by "LiJie20190102 (via GitHub)" <gi...@apache.org>.
LiJie20190102 commented on code in PR #10435:
URL: https://github.com/apache/seatunnel/pull/10435#discussion_r2764261941
##########
seatunnel-connectors-v2/connector-jdbc/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/oracle/container/AbstractOracleContainerTest.java:
##########
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.oracle.container;
+
+import org.apache.seatunnel.connectors.seatunnel.jdbc.catalog.oracle.OracleCatalog;
+import org.apache.seatunnel.connectors.seatunnel.jdbc.catalog.oracle.OracleURLParser;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.condition.DisabledOnOs;
+import org.junit.jupiter.api.condition.OS;
+import org.testcontainers.containers.OracleContainer;
+import org.testcontainers.utility.DockerImageName;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.time.Duration;
+
+/**
+ * Base class for Oracle Testcontainers-based unit tests. Provides shared Oracle container setup and
+ * connection management.
+ */
+@DisabledOnOs(OS.WINDOWS)
+public abstract class AbstractOracleContainerTest {
+
+ protected static final String ORACLE_IMAGE = "gvenzl/oracle-free:23-slim";
+ protected static final String USERNAME = "TESTUSER";
+ protected static final String PASSWORD = "testPassword";
+ protected static final String DATABASE = "XE";
+ protected static final String SCHEMA = USERNAME;
+
+ protected static OracleContainer oracleContainer;
+ protected static Connection connection;
+ protected static OracleCatalog catalog;
+
+ @BeforeAll
+ public static void startContainer() throws SQLException {
+ DockerImageName imageName =
+ DockerImageName.parse(ORACLE_IMAGE).asCompatibleSubstituteFor("gvenzl/oracle-xe");
+
+ oracleContainer =
+ new OracleContainer(imageName)
+ .withDatabaseName(DATABASE)
+ .withUsername(USERNAME)
+ .withPassword(PASSWORD)
+ .withSharedMemorySize(1073741824L) // 1GB shared memory
+ .withStartupTimeout(Duration.ofMinutes(5)) // Increase timeout for ARM
+ .withEnv("ORACLE_CHARACTERSET", "AL32UTF8")
+ .withReuse(false);
+
+ oracleContainer.start();
+
+ String jdbcUrl = oracleContainer.getJdbcUrl();
+ connection =
+ DriverManager.getConnection(
+ jdbcUrl, oracleContainer.getUsername(), oracleContainer.getPassword());
+
+ catalog =
+ new OracleCatalog(
+ "oracle",
+ oracleContainer.getUsername(),
+ oracleContainer.getPassword(),
+ OracleURLParser.parse(jdbcUrl),
+ SCHEMA,
+ null);
+ catalog.open();
+ }
+
+ @AfterAll
+ public static void stopContainer() throws SQLException {
+ if (catalog != null) {
+ catalog.close();
Review Comment:
Thank you for your contribution. If an exception is thrown when closing the `catalog`, will the following be unable to close
##########
seatunnel-connectors-v2/connector-jdbc/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/oracle/container/OracleDialectContainerTest.java:
##########
@@ -0,0 +1,216 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.oracle.container;
+
+import org.apache.seatunnel.api.table.catalog.TablePath;
+import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.DatabaseIdentifier;
+import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.oracle.OracleDialect;
+import org.apache.seatunnel.connectors.seatunnel.jdbc.source.JdbcSourceTable;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+/**
+ * Unit tests for OracleDialect using Testcontainers. Tests dialect-specific functionality like
+ * quoting, SQL generation, and data sampling.
+ */
+public class OracleDialectContainerTest extends AbstractOracleContainerTest {
+
+ private static OracleDialect dialect;
+ private static final String TEST_TABLE = "DIALECT_TEST_TABLE";
+
+ @BeforeAll
+ public static void setupDialect() throws SQLException {
+ dialect = new OracleDialect();
+
+ String createTableSql =
+ String.format(
+ "CREATE TABLE %s.%s ("
+ + "ID NUMBER(10) PRIMARY KEY, "
+ + "VARCHAR_COL VARCHAR2(100), "
+ + "NUMBER_COL NUMBER(10,2), "
+ + "DATE_COL DATE"
+ + ")",
+ quoteIdentifier(SCHEMA), quoteIdentifier(TEST_TABLE));
+
+ try (Statement stmt = connection.createStatement()) {
+ stmt.execute(createTableSql);
+ }
+
+ String insertSql =
+ String.format(
+ "INSERT INTO %s.%s (ID, VARCHAR_COL, NUMBER_COL, DATE_COL) "
+ + "VALUES (1, 'test1', 100.50, SYSDATE)",
+ quoteIdentifier(SCHEMA), quoteIdentifier(TEST_TABLE));
+ try (Statement stmt = connection.createStatement()) {
+ stmt.execute(insertSql);
+ // Note: Auto-commit is enabled by default, so no explicit commit needed
+ }
+ }
+
+ @Test
+ public void testDialectName() {
+ Assertions.assertEquals(DatabaseIdentifier.ORACLE, dialect.dialectName());
+ }
+
+ @Test
+ public void testQuoteIdentifier() {
+ Assertions.assertEquals("\"table_name\"", dialect.quoteIdentifier("table_name"));
+ Assertions.assertEquals("\"COLUMN\"", dialect.quoteIdentifier("COLUMN"));
+ }
+
+ @Test
+ public void testTableIdentifierWithSchema() {
+ // OracleDialect.tableIdentifier(String, String) ignores database parameter
+ String identifier = dialect.tableIdentifier(SCHEMA, TEST_TABLE);
+ Assertions.assertTrue(identifier.contains(TEST_TABLE));
+ }
+
+ @Test
+ public void testTableIdentifierWithTablePath() {
+ TablePath tablePath = TablePath.of(null, SCHEMA, TEST_TABLE);
+ String identifier = dialect.tableIdentifier(tablePath);
+ Assertions.assertTrue(identifier.contains(SCHEMA));
+ Assertions.assertTrue(identifier.contains(TEST_TABLE));
+ }
+
+ @Test
+ public void testParse() {
+ TablePath parsedPath = dialect.parse(SCHEMA + "." + TEST_TABLE);
+ Assertions.assertEquals(SCHEMA, parsedPath.getSchemaName());
+ Assertions.assertEquals(TEST_TABLE, parsedPath.getTableName());
+
+ TablePath singlePath = dialect.parse(TEST_TABLE);
+ Assertions.assertEquals(TEST_TABLE, singlePath.getTableName());
+ }
+
+ @Test
+ public void testHashModForField() {
+ String result = dialect.hashModForField("ID", 10);
+ Assertions.assertTrue(result.contains("MOD"));
+ Assertions.assertTrue(result.contains("ORA_HASH"));
+ Assertions.assertTrue(result.contains("\"ID\""));
+ Assertions.assertTrue(result.contains("10"));
+ }
+
+ @Test
+ public void testDualTable() {
+ String dualTable = dialect.dualTable();
+ Assertions.assertEquals(" FROM dual ", dualTable);
+ }
+
+ @Test
+ public void testSampleDataFromColumn() throws Exception {
+ TablePath tablePath = TablePath.of(DATABASE, SCHEMA, TEST_TABLE);
+ JdbcSourceTable table =
+ JdbcSourceTable.builder()
+ .tablePath(tablePath)
+ .useSelectCount(false)
+ .skipAnalyze(false)
+ .build();
+
+ Object[] samples = dialect.sampleDataFromColumn(connection, table, "ID", 1, 1024);
+ Assertions.assertNotNull(samples);
+ Assertions.assertTrue(samples.length > 0);
+ }
+
+ @Test
+ public void testSampleDataFromColumnWithQuery() throws Exception {
+ TablePath tablePath = TablePath.of(DATABASE, SCHEMA, TEST_TABLE);
+ JdbcSourceTable table =
+ JdbcSourceTable.builder()
+ .tablePath(tablePath)
+ .query(
+ "select * from "
+ + quoteIdentifier(SCHEMA)
+ + "."
+ + quoteIdentifier(TEST_TABLE)
+ + " where ID = 1")
+ .useSelectCount(false)
+ .skipAnalyze(false)
+ .build();
+
+ Object[] samples = dialect.sampleDataFromColumn(connection, table, "ID", 1, 1024);
+ Assertions.assertNotNull(samples);
+ }
+
+ @Test
+ public void testApproximateRowCntStatement() throws Exception {
+ TablePath tablePath = TablePath.of(DATABASE, SCHEMA, TEST_TABLE);
+ JdbcSourceTable table =
+ JdbcSourceTable.builder()
+ .tablePath(tablePath)
+ .useSelectCount(false)
+ .skipAnalyze(false)
+ .build();
+
+ Long rowCount = dialect.approximateRowCntStatement(connection, table);
+ Assertions.assertNotNull(rowCount);
+ Assertions.assertTrue(rowCount >= 0);
+ }
+
+ @Test
+ public void testQueryNextChunkMax() throws Exception {
+ TablePath tablePath = TablePath.of(DATABASE, SCHEMA, TEST_TABLE);
+ JdbcSourceTable table =
+ JdbcSourceTable.builder()
+ .tablePath(tablePath)
+ .useSelectCount(false)
+ .skipAnalyze(false)
+ .build();
+
+ Object maxValue = dialect.queryNextChunkMax(connection, table, "ID", 10, 0);
+ Assertions.assertNotNull(maxValue);
+ Assertions.assertEquals(1, ((Number) maxValue).intValue());
+ }
+
+ @Test
+ public void testGetRowConverter() {
+ Assertions.assertNotNull(dialect.getRowConverter());
+ }
+
+ @Test
+ public void testGetTypeConverter() {
+ Assertions.assertNotNull(dialect.getTypeConverter());
+ }
+
+ @Test
+ public void testGetJdbcDialectTypeMapper() {
+ Assertions.assertNotNull(dialect.getJdbcDialectTypeMapper());
+ }
+
+ @Test
+ public void testCreatPreparedStatement() throws Exception {
+ PreparedStatement preparedStatement =
+ dialect.creatPreparedStatement(
+ connection,
+ "SELECT * FROM "
+ + quoteIdentifier(SCHEMA)
+ + "."
+ + quoteIdentifier(TEST_TABLE),
+ 128);
+
+ Assertions.assertNotNull(preparedStatement);
Review Comment:
If the assertion here fails, `preparedStatement` cannot be closed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feat][Connector-v2][JDBC][Oracle] Add Testcontainers-based unit tests [seatunnel]
Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #10435:
URL: https://github.com/apache/seatunnel/pull/10435#issuecomment-4278478146
Thanks for adding real Oracle Testcontainers coverage. I reviewed the PR locally and traced where the new tests run and which production paths they exercise.
Local review context:
- Review branch: `seatunnel-review-10435`
- PR HEAD: `1549222be5dbd5fe48e97151791643f3e6bdcd93`
- Merge base: `17448dd989079ef3cded93ac3ebe67df90dcb2bb`
- Current `upstream/dev` observed locally: `b9cdfeb79e2df010718acde1d6e45b956a76f4fa`
- `git diff --check upstream/dev...HEAD`: clean
- `git merge-tree $(git merge-base upstream/dev HEAD) upstream/dev HEAD | rg '<<<<<<<|changed in both|CONFLICT|removed in'`: no conflict markers observed
- I did not run tests locally. I used local source review plus the current GitHub checks. `Build`, `Notify test workflow`, and `labeler` are green.
# What This PR Fixes
- User pain point: Oracle JDBC catalog and dialect behavior previously had limited direct coverage against a real Oracle database, so SQL generation, catalog table operations, DML, upsert, and named-parameter execution could regress without being caught early.
- Fix approach: the PR adds the `org.testcontainers:oracle-xe` test-scope dependency, creates a shared Oracle container test base, and adds `OracleCatalogTest` plus `OracleDialectTest`.
- One-line summary: this is a test coverage improvement that validates Oracle JDBC behavior against a real containerized Oracle database without changing runtime code.
Simple example: when `OracleDialect.getUpsertStatement()` changes, a plain string assertion can miss whether Oracle actually accepts the generated `MERGE INTO ... USING ...` SQL. This PR creates a real Oracle table, executes the generated upsert SQL, and checks the inserted/updated row.
## Full Runtime/Test Path
```text
Maven unit-test phase
-> surefire runs *Test and excludes *IT [root pom.xml L663-L672]
-> OracleCatalogTest / OracleDialectTest
Container setup
-> AbstractOracleContainerTest.startContainer() [L53-L83]
-> DockerImageName.parse("gvenzl/oracle-free:23-slim")
-> new OracleContainer(imageName)
-> oracleContainer.start()
-> DriverManager.getConnection(oracleContainer.getJdbcUrl(), ...)
-> new OracleCatalog(... OracleURLParser.parse(jdbcUrl) ...)
-> catalog.open()
Catalog production API coverage
-> OracleCatalogTest.testCreateTableViaAPI() [L112-L143]
-> builds CatalogTable / TableSchema / PrimaryKey
-> catalog.createTable()
-> catalog.getTable()
-> catalog.dropTable()
Dialect production SQL coverage
-> OracleDialectTest.setupDialect() [L51-L77]
-> creates DIALECT_TEST_TABLE and inserts one baseline row
-> OracleDialectTest.testInsertIntoStatement() [L236-L249]
-> OracleDialectTest.testUpdateStatement() [L251-L279]
-> OracleDialectTest.testDeleteStatement() [L281-L297]
-> OracleDialectTest.testUpsertStatement() [L319-L354]
-> calls OracleDialect SQL generators
-> executes generated SQL against the Oracle container
-> asserts row counts and values
Cleanup
-> OracleDialectTest.cleanupTestData() [L80-L89]
-> keeps the baseline row and removes extra rows after each test
-> AbstractOracleContainerTest.stopContainer() [L86-L111]
-> closes catalog, JDBC connection, and container
```
## Findings
No blocking issues found.
Compatibility:
- No public API changes.
- No config changes.
- No default-value changes.
- No protocol or serialization changes.
- No runtime behavior changes.
- The new dependency is test scope only.
Performance / side effects:
- Production runtime is unaffected.
- Test runtime becomes heavier because Oracle containers start in the regular `*Test` path. This is consistent with the existing connector-jdbc container-test pattern, and the current Build is green, so I do not consider it blocking.
- Resource cleanup is present for catalog, JDBC connection, and container.
Error handling / logging:
- Cleanup exceptions are ignored to let subsequent cleanup continue. That is acceptable for disposable test resources, though future diagnostics could be improved if cleanup ever becomes flaky.
Test coverage:
- The PR adds meaningful coverage for Oracle catalog operations, real SQL execution, insert/update/delete/upsert generation, and `FieldNamedPreparedStatement`.
- Remaining gap: this is not a full SeaTunnel Source -> Sink E2E workflow, so existing e2e tests still need to cover job-level behavior.
# Merge Conclusion
### Conclusion: can merge
1. Blocking items:
- None.
2. Recommended non-blocking improvements:
- If the community later wants a stricter separation between fast unit tests and Docker-backed tests, these classes could be renamed to `*IT` or gated by a profile. Given the existing module pattern and the green CI, this does not block this PR.
Overall, this is a useful and well-scoped test coverage improvement for Oracle JDBC behavior. It does not touch production code, the dependency is test-only, CI is green, and I did not find merge-blocking risks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feat][Connector-v2][JDBC][Oracle] Add Testcontainers-based unit tests [seatunnel]
Posted by "Carl-Zhou-CN (via GitHub)" <gi...@apache.org>.
Carl-Zhou-CN merged PR #10435:
URL: https://github.com/apache/seatunnel/pull/10435
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org