Skip to content

debezium/dbz#2059 Freeze _debezium_cdc_log contract and add SqliteTestHelper with trigger generator#3

Draft
siddhantcvdi wants to merge 5 commits into
debezium:mainfrom
siddhantcvdi:dbz-2059-cdc-log
Draft

debezium/dbz#2059 Freeze _debezium_cdc_log contract and add SqliteTestHelper with trigger generator#3
siddhantcvdi wants to merge 5 commits into
debezium:mainfrom
siddhantcvdi:dbz-2059-cdc-log

Conversation

@siddhantcvdi

@siddhantcvdi siddhantcvdi commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Closes debezium/dbz#2059

This PR freezes the _debezium_cdc_log contract, the single table the connector reads change events from, and builds the test harness that fills it. Every later phase depends on this table's shape and on being able to run against a real SQLite file, so both land here before any read logic is built on top.

Note: This PR sits on top of PR #2 and can be reviewed only once that has been merged. Marking as draft till then.

The main changes:

  1. Freeze the contract in CdcLog: the table name, column names, operation codes, and CREATE TABLE DDL, with the DDL built from the column constants so it cannot drift from names later code reads.
  2. SqliteTestHelper, a closeable WAL-mode temporary database built on the framework' JdbcConnection. This also binds the Failsafe plugin, which the bootstrap POM never did, *IT tests run for the first time.
  3. A trigger generator that installs AFTER INSERT, UPDATE, and DELETE triggers writing shaped rows into the log json_object(). It stands in for the change-event writer so Java side is not blocked on the native extension.
  4. Test conventions: a logback-test.xml and a switch to Testing.Files, matching the connectors.
  5. installTriggers(table) plus an integration test that runs a plain insert, update, and and asserts the matching c, u, and d rows land in the log. This is the Phase 0 exit gate.

A sample _debezium_cdc_log table created on top of a customers table:

image

@siddhantcvdi siddhantcvdi force-pushed the dbz-2059-cdc-log branch 2 times, most recently from aae2f98 to 9a22d7f Compare June 16, 2026 09:03
@siddhantcvdi siddhantcvdi force-pushed the dbz-2059-cdc-log branch 2 times, most recently from a8b16c6 to 20240c9 Compare June 23, 2026 17:26
Define the _debezium_cdc_log table in one place: the table name, the six column
names, the c/u/d operation codes, and the CREATE TABLE DDL, all as named constants
in CdcLog. The DDL is built from the column constants so it cannot drift from the
names later code reads. Point SYSTEM_TABLES_FILTER at CdcLog.TABLE_NAME so the name
lives in exactly one spot.

CdcLogTest runs the DDL against an in-memory SQLite database through the framework's
JdbcConnection and asserts, via PRAGMA table_info and sqlite_master, that the columns,
types, NOT NULL flags, and the autoincrement primary key match the contract.

Signed-off-by: siddhantcvdi <dev.siddhantcvdi@gmail.com>
…ion tests

Add SqliteTestHelper, a closeable test double built on the framework's JdbcConnection.
Creating one makes a temporary .db file, switches it to WAL journal mode and verifies
SQLite reported wal back, then runs the frozen CdcLog DDL so _debezium_cdc_log exists.
Closing it closes the connection and deletes the temp file and its -wal/-shm side files.

Bind the Failsafe plugin to the integration-test and verify phases. The parent only
manages Failsafe in pluginManagement, so without this binding no *IT.java would run.
SqliteTestHelperIT is the first integration test and self-tests the helper: a WAL-mode
database with an empty _debezium_cdc_log, and temp-file cleanup on close.

Signed-off-by: siddhantcvdi <dev.siddhantcvdi@gmail.com>
Add TriggerGenerator, a test-side SQL builder that stands in for a real change-event
writer. Given a source table and its columns, it builds the AFTER INSERT, AFTER UPDATE,
and AFTER DELETE triggers that write one correctly shaped row into _debezium_cdc_log for
each change, capturing row data with SQLite's json_object() over the NEW and OLD aliases.
Insert records the new row under code c, update records both rows under code u, and
delete records the old row under code d. The committed_at value uses unixepoch('now',
'subsec') * 1000 for epoch milliseconds.

TriggerGeneratorTest installs the generated triggers in an in-memory database through
JdbcConnection, so SQLite confirms they parse, and asserts the operation codes and the
json_object column references. Wiring the generator into the helper and proving the
end-to-end c/u/d loop is the next commit.

Signed-off-by: siddhantcvdi <dev.siddhantcvdi@gmail.com>
…d Testing.Files

Add src/test/resources/logback-test.xml so test logging uses the same console layout
and levels as the other connectors, instead of logback's noisy default. Switch
SqliteTestHelper from java.nio Files.createTempFile to io.debezium.util.Testing.Files,
which places the temporary database under target/data where it is cleaned by mvn clean
and easy to find when debugging. This adds the debezium-util test-jar dependency that
Testing lives in, the same dependency the other connectors declare.

Signed-off-by: siddhantcvdi <dev.siddhantcvdi@gmail.com>
…e the CDC loop

Add SqliteTestHelper.installTriggers(table), which reads the table's columns from
PRAGMA table_info, builds the insert, update, and delete triggers with TriggerGenerator,
and runs them. CdcCaptureIT drives a plain SQL insert, update, and delete on a source
table and asserts the matching c, u, and d rows land in _debezium_cdc_log with the right
table name and JSON row data. This is the Phase 0 exit gate: a real write produces a
correctly shaped CDC row, so the development and test loop is proven end to end.

Signed-off-by: siddhantcvdi <dev.siddhantcvdi@gmail.com>
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.

Freeze _debezium_cdc_log contract and add SqliteTestHelper with trigger generator

1 participant