ryanmeowy opened a new pull request, #12735:
URL: https://github.com/apache/seatunnel/pull/12735

   ### Purpose of this pull request
   
   Related #11007
   
   Migrate the MongoDB CDC source validation from the imperative checks in 
`MongodbSourceConfigProvider` to declarative `OptionRule` validation.
   
   Changes:
   
   - Add value domains to `MongodbIncrementalSourceFactory.optionRule()`: 
`batch.size >= 0`, `poll.max.batch.size > 0`, `poll.await.time.ms > 0`, 
`heartbeat.interval.ms >= 0`, `incremental.snapshot.chunk.size.mb > 0`.
   - Reject an empty `schema` map and an empty `tables_configs` list with 
`Conditions.mapNotEmpty` / `notEmpty`; the two options stay mutually exclusive.
   - Validate `stop.timestamp` against `startup.timestamp` through a 
`ConditionExtension`, reusing the derived change-stream positions so the second 
precision of MongoDB timestamps is respected.
   - Extend `MongodbIncrementalSourceFactoryTest` with cases for each rule.
   - The existing runtime checks in `MongodbSourceConfigProvider` are kept so 
the public builder still fails fast for programmatic callers; the same errors 
are now surfaced earlier by configuration validation. Happy to drop them here 
if you would rather have a strict one-to-one migration.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Only the validation timing and the error reporting path change.
   
   - Option names, defaults and accepted value ranges are unchanged; no 
previously valid configuration becomes invalid.
   - A configuration that was previously rejected while the job was being built 
is now rejected by `ConfigValidator` with `OptionValidationException` during 
standard configuration validation.
   
   ### How was this patch tested?
   
   Added focused cases to `MongodbIncrementalSourceFactoryTest`: the value 
domains (default, boundary, out-of-range), an empty `schema` / 
`tables_configs`, their exclusivity, and the timestamp range (`T` and `T+1000` 
valid, `T-1000` and `T+500` rejected because MongoDB timestamps have second 
precision).
   
   ```bash
   ./mvnw -pl seatunnel-connectors-v2/connector-cdc/connector-cdc-mongodb \
     -Dtest=MongodbIncrementalSourceFactoryTest \
     -Dsurefire.failIfNoSpecifiedTests=false test
   ```
   
   Full module suite: 45 tests, 0 failures (JDK 11).
   


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