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

   Fixes #57
   
   ### Motivation
   
   The Solr sink connector module (`solr/`) had only mock-based coverage:
   `SolrSinkConfigTest` (config parsing) and `SolrGenericRecordSinkTest`, which
   merely verifies `sink.open(...)` succeeds against an embedded Solr and never
   asserts that a written record actually lands in Solr. Nothing exercised the
   end-to-end write path of `SolrGenericRecordSink` against a real Solr server.
   
   ### Modifications
   
   Add `SolrGenericRecordSinkIntegrationTest`, a Testcontainers-based 
integration
   test that:
   
   - Starts a real Solr container (`solr:9.8`, matching the repo's `solr = 
"9.8.0"`
     version catalog entry) using `GenericContainer` with `solr-precreate` to 
create
     the target core, and waits on the Cores STATUS HTTP endpoint.
   - Opens `SolrGenericRecordSink` in `Standalone` mode pointed at the 
container.
   - Writes 5 `GenericRecord` documents (built from an Avro schema, the same
     approach used by the existing mock test) through the sink, tracking each
     record's `ack()`/`fail()` via a `CompletableFuture`.
   - Reads the documents back via SolrJ and asserts `numFound` plus each 
document's
     field values (`id`, `title`, `category`).
   - Is bounded with `@Test(timeOut = 300_000)` and polls with Awaitility (the 
sink
     commits asynchronously via `commitWithin`) instead of `Thread.sleep`.
   
   Build changes: add `testImplementation(libs.testcontainers)` to
   `solr/build.gradle.kts`. No version catalog change was needed — the 
Testcontainers
   core module (`libs.testcontainers`) already exists and its version comes 
from the
   imported Testcontainers BOM. `GenericContainer` + `solr-precreate` was 
chosen over
   `SolrContainer` because it needs no new catalog entry and works out of the 
box with
   Solr 9.8.
   
   ### Verifying this change
   
   Run locally against Docker:
   
   - `./gradlew :solr:test` — all 10 tests pass:
     ```
     SolrGenericRecordSinkIntegrationTest > testWriteAndReadBack PASSED
     ... (SolrSinkConfigTest x8, SolrGenericRecordSinkTest x1 also PASSED)
     BUILD SUCCESSFUL
     ```
   - `./gradlew :solr:check` — passes (spotless).
   
   Mutation check (to prove the test is not vacuous): I temporarily pointed the 
sink
   at a nonexistent collection. The test then **FAILED** as expected:
   ```
   SolrGenericRecordSinkIntegrationTest > testWriteAndReadBack FAILED
       
org.apache.solr.client.solrj.impl.BaseHttpSolrClient$RemoteSolrException: Error 
from server ...
   BUILD FAILED
   ```
   Reverting the mutation returned the suite to green. This confirms the 
assertions
   genuinely depend on the write-through-and-read-back path.
   
   ### Note on #26 (KeyValue schema unwrapping)
   
   Open PR #26 fixes Solr `KeyValue`-schema (Debezium CDC) unwrapping and has no
   integration test. I intentionally did **not** add a KeyValue test case here: 
this
   PR targets `master`, which does not include #26, so a KeyValue-schema record 
would
   exercise the not-yet-fixed code path and the test would fail on `master`. 
Such a
   test belongs with #26 itself (or a follow-up once #26 merges), where it would
   actually guard the fixed behavior.
   


-- 
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