david-streamlio opened a new pull request, #59:
URL: https://github.com/apache/pulsar-connectors/pull/59
Fixes #45
### Motivation
The `jdbc/mariadb` module (`MariadbJdbcAutoSchemaSink`) currently has zero
tests. Following the pattern established for the ClickHouse JDBC sink in #33,
this adds a Testcontainers-based integration test so the MariaDB sink is
exercised end-to-end against a real MariaDB server.
### Modifications
- `gradle/libs.versions.toml`: add a `testcontainers-mariadb` catalog entry
(no version needed — it resolves via the Testcontainers BOM imported by the
`pulsar-connectors-dependencies` platform).
- `jdbc/mariadb/build.gradle.kts`: add test dependencies
(`testcontainers-mariadb`, `pulsar-client`, `pulsar-functions-instance`,
`avro`), mirroring the ClickHouse module.
-
`jdbc/mariadb/src/test/java/org/apache/pulsar/io/jdbc/MariadbJdbcSinkIntegrationTest.java`:
new integration test that
- starts a `mariadb:11.4` container via `MariaDBContainer`,
- creates a `pulsar_messages` table (`field1 VARCHAR(255), field2
VARCHAR(255), field3 INT PRIMARY KEY`) over plain JDBC,
- opens `MariadbJdbcAutoSchemaSink` with `useTransactions=true` and
`batchSize=1`,
- writes an Avro `GenericRecord` through the sink and waits for the record
to be acked,
- reads the row back over plain JDBC (`DriverManager` with the container's
URL/credentials; the driver is on the test runtime classpath via the module's
`runtimeOnly` dependency) and asserts exactly one matching row.
### Verifying this change
Ran locally with Docker:
- `./gradlew :jdbc:pulsar-io-jdbc-mariadb:compileTestJava` — BUILD SUCCESSFUL
- `./gradlew :jdbc:pulsar-io-jdbc-mariadb:test` — BUILD SUCCESSFUL;
`MariadbJdbcSinkIntegrationTest > testOpenDiscoversTableAndWrites PASSED`
- `./gradlew :jdbc:pulsar-io-jdbc-mariadb:check -x test` (spotless) — BUILD
SUCCESSFUL
--
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]