david-streamlio opened a new pull request, #60:
URL: https://github.com/apache/pulsar-connectors/pull/60

   Fixes #43
   
   ### Motivation
   
   The `debezium/mssql` module has zero tests — `DebeziumMsSqlSource` is not 
exercised at all in CI. This adds a Testcontainers-based integration test 
following the existing pattern in `debezium/mysql` (`DebeziumMysqlSourceTest`).
   
   ### Modifications
   
   - `gradle/libs.versions.toml`: add a `testcontainers-mssqlserver` catalog 
entry (no version needed — it resolves via the Testcontainers BOM imported by 
the dependencies platform).
   - `debezium/mssql/build.gradle.kts`: add `testImplementation` dependencies 
(`testcontainers-mssqlserver`, `testcontainers-pulsar`, `pulsar-client`).
   - 
`debezium/mssql/src/test/java/org/apache/pulsar/io/debezium/mssql/DebeziumMsSqlSourceTest.java`:
 new integration test that
     - starts an `MSSQLServerContainer` 
(`mcr.microsoft.com/mssql/server:2022-latest`) with `MSSQL_AGENT_ENABLED=true` 
— the SQL Server Agent is required to run the CDC capture jobs,
     - creates `testdb`, enables CDC on the database (`sys.sp_cdc_enable_db`) 
and on a `products` table (`sys.sp_cdc_enable_table`), and inserts two rows 
over plain JDBC as `sa`,
     - starts a `PulsarContainer` for the Debezium schema history topic,
     - opens `DebeziumMsSqlSource` and asserts (via Awaitility) that the 
initial snapshot yields at least 2 CDC records from `source.read()`.
   
   One SQL Server-specific detail: the test sets `task.id=0` explicitly. The 
SQL Server connector runs in multi-partition mode and its metrics require a 
task id, but `DebeziumSource` starts the connector task directly (it does not 
set the adapter's `kafkaConnectorSourceClass` config), so 
`SqlServerConnector.taskConfigs()` — which would normally assign the task id — 
never runs. Without it, `source.open()` fails with an NPE in Debezium's JMX 
metric-name construction.
   
   ### Verifying this change
   
   Ran locally with Docker (macOS, Docker Desktop):
   
   - `./gradlew :debezium:pulsar-io-debezium-mssql:compileTestJava` — BUILD 
SUCCESSFUL
   - `./gradlew :debezium:pulsar-io-debezium-mssql:test` — 
`DebeziumMsSqlSourceTest > testMsSqlCdcEvents PASSED`, BUILD SUCCESSFUL in 48s 
(with images already pulled)
   - `./gradlew :debezium:pulsar-io-debezium-mssql:check -x test` — BUILD 
SUCCESSFUL
   
   ### Documentation
   
   - [x] `doc-not-needed`
   
   Test-only change; no user-facing behavior is modified.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to