Skip to content

[improve][test] Add Debezium Oracle source integration test#62

Open
david-streamlio wants to merge 1 commit into
apache:masterfrom
david-streamlio:test/debezium-oracle-integration
Open

[improve][test] Add Debezium Oracle source integration test#62
david-streamlio wants to merge 1 commit into
apache:masterfrom
david-streamlio:test/debezium-oracle-integration

Conversation

@david-streamlio

Copy link
Copy Markdown
Contributor

Fixes #44

Motivation

The debezium/oracle module (DebeziumOracleSource) had no tests. This PR adds a Testcontainers integration test that exercises the connector end-to-end against a real Oracle database, mirroring the shape of the existing DebeziumMysqlSourceTest.

Oracle is the heaviest Debezium variant to test: LogMiner-based CDC requires archive log mode, supplemental logging, a common (CDB-wide) user with an extensive grant set, and PDB-aware connector configuration. All of that is handled inside the test via a container init script.

Modifications

  • New DebeziumOracleSourceTest in debezium/oracle:
    • Starts gvenzl/oracle-free:23-slim-faststart (the image family Debezium's own test infrastructure uses) plus a PulsarContainer for the schema-history topic.
    • A SYSDBA init script (src/test/resources/debezium-oracle-setup.sql, copied to /container-entrypoint-initdb.d/) enables archive log mode (SHUTDOWN IMMEDIATE / STARTUP MOUNT / ALTER DATABASE ARCHIVELOG), enables minimal supplemental logging, creates LOGMINER_TBS tablespaces in CDB and PDB, creates c##dbzuser with the LogMiner grant set from the Debezium 3.x documentation, and seeds a DEBEZIUM.PRODUCTS table (2 rows) in FREEPDB1 with SUPPLEMENTAL LOG DATA (ALL) COLUMNS. The gvenzl entrypoint runs init scripts before printing DATABASE IS READY TO USE!, so the container wait strategy also covers the DB restart.
    • Opens DebeziumOracleSource with database.dbname=FREE, database.pdb.name=FREEPDB1, table.include.list=DEBEZIUM.PRODUCTS, log.mining.strategy=online_catalog, and a Pulsar-backed schema history, then asserts the initial snapshot emits at least 2 records.
  • debezium/oracle/build.gradle.kts: adds testcontainers, testcontainers-pulsar, and pulsar-client test dependencies.

Notes on two dependency findings:

  • Oracle JDBC driver: no extra test-scoped driver is needed. io.debezium:debezium-connector-oracle:3.4.2.Final pulls com.oracle.database.jdbc:ojdbc11:21.15.0.0 (plus orai18n/xdb/xmlparserv2) transitively onto the runtime classpath, so the driver also ends up in the NAR. No runtime-driver gap in this module as built today.
  • Why GenericContainer instead of org.testcontainers.oracle.OracleContainer: debezium-bom:3.4.2.Final constrains Testcontainers core to 2.0.2, while the org.testcontainers:oracle-free module only exists up to 1.21.4 and references shaded classes removed in core 2.x (NoClassDefFoundError: org.testcontainers.shaded.org.apache.commons.lang3.StringUtils at OracleContainer.withPassword). Using GenericContainer against core 2.0.2 avoids the mixed-version breakage and matches the approach already used by DebeziumMysqlSourceTest.

Verifying this change

Run locally (Docker required):

./gradlew :debezium:pulsar-io-debezium-oracle:test

Local result (macOS/arm64, Docker Desktop): PASSED in ~37s once the image was pulled; the test received snapshot records with keys {"ID":1} and {"ID":2}. The init script was additionally verified standalone: V$DATABASE.LOG_MODE=ARCHIVELOG, SUPPLEMENTAL_LOG_DATA_MIN=YES, c##dbzuser can connect to FREEPDB1 and sees the 2 seeded rows, and the container logs contain no ORA-/SP2- errors. :debezium:pulsar-io-debezium-oracle:check (spotless/checkstyle) passes.

CI-runner risk worth calling out explicitly: the gvenzl/oracle-free:23-slim-faststart image is large (~1.6 GB) and Oracle Free wants ~2 GB of memory; the init script also restarts the database once to enable archive log mode. Startup on a standard GitHub-hosted runner will be minutes, not seconds — the test uses a 6-minute container startup timeout, a 5-minute Awaitility window for the snapshot, and a 10-minute overall test timeout. If the runner is memory-constrained alongside other container tests, this test will be the first to feel it.

Adds a Testcontainers-based integration test for the Debezium Oracle
source connector using gvenzl/oracle-free:23-slim-faststart. A SYSDBA
init script enables archive log mode and supplemental logging, creates
the c##dbzuser LogMiner user with the grant set from the Debezium
documentation, and seeds a DEBEZIUM.PRODUCTS table in FREEPDB1. The
test opens DebeziumOracleSource against the container and asserts that
the initial snapshot emits records for the two seeded rows.

Fixes apache#44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an end-to-end Testcontainers integration test for the debezium/oracle connector module (DebeziumOracleSource) by standing up a real Oracle Free database plus a Pulsar broker for Pulsar-backed schema history, then asserting the initial Debezium snapshot produces records.

Changes:

  • Added DebeziumOracleSourceTest that boots Oracle Free + Pulsar, configures the Oracle Debezium connector, and asserts snapshot records are emitted.
  • Added an Oracle container init SQL script to enable LogMiner prerequisites (archive log mode, supplemental logging), create required users/tablespaces, and seed a test table.
  • Added Testcontainers + Pulsar client test dependencies to the Oracle Debezium module.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
debezium/oracle/src/test/resources/debezium-oracle-setup.sql Initializes Oracle Free container for LogMiner CDC and seeds a test table used by the integration test.
debezium/oracle/src/test/java/org/apache/pulsar/io/debezium/oracle/DebeziumOracleSourceTest.java New Testcontainers-based integration test exercising DebeziumOracleSource against a real Oracle DB and Pulsar schema history.
debezium/oracle/build.gradle.kts Adds required test dependencies for Testcontainers and Pulsar client usage in the new test.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +148 to +158
int recordCount = 0;
Record<KeyValue<byte[], byte[]>> record;
while ((record = source.read()) != null) {
assertNotNull(record.getValue());
log.info("Received CDC record: key={}", record.getKey().orElse(null));
recordCount++;
record.ack();
if (recordCount >= 2) {
break;
}
}
@david-streamlio

Copy link
Copy Markdown
Contributor Author

@lhotari requesting your eyes on this one specifically — it's the least conventional of the integration tests in flight and touches shared build config, so an independent review seems warranted:

  1. Oracle container setup. LogMiner needs archivelog mode, supplemental logging, and a privileged c##dbzuser, all done via a SYSDBA init script (debezium-oracle-setup.sql). Verified standalone (LOG_MODE=ARCHIVELOG, SUPPLEMENTAL_LOG_DATA_MIN=YES, no ORA-/SP2- errors), but it's the kind of setup that's easy to get subtly wrong.

  2. CI cost. gvenzl/oracle-free:23-slim-faststart is ~1.6 GB and wants ~2 GB memory with a minutes-long startup. Worth a call on whether this belongs in the per-PR job or a separate/nightly one.

  3. A Testcontainers constraint worth knowing repo-wide: debezium-bom pins Testcontainers core to 2.x, while the specialized modules (oracle-free, etc.) still target 1.21.x and reference shaded classes removed in 2.x — using OracleContainer fails with NoClassDefFoundError. This PR uses the GenericContainer pattern instead (as DebeziumMysqlSourceTest already does). Any future Debezium-module test will hit the same wall.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[improve][test] Add integration tests for the Debezium Oracle source connector

2 participants