-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add Validation for PK Mode Against PK Fields and Unit Tests #335
Conversation
a79a78f
to
56b5e7e
Compare
|
||
final Config config = new JdbcSinkConnector().validate(props); | ||
|
||
assertFalse(config.configValues().stream().allMatch(cv -> cv.errorMessages().size() > 0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This asserts that there's at least one property that didn't have an error message. I'm guessing we actually want to assert that no properties have error messages?
assertFalse(config.configValues().stream().allMatch(cv -> cv.errorMessages().size() > 0)); | |
assertFalse(config.configValues().stream().anyMatch(cv -> cv.errorMessages().size() > 0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Joel-hanson, this looks fantastic! Only have one small comment about a test case, everything else LGTM. If the suggestion makes sense, you can just amend the single current commit and force push, then we can merge.
Signed-off-by: Joel Hanson <joelhanson025@gmail.com> Signed-off-by: Joel Hanson <joel.hanson2@ibm.com>
56b5e7e
to
fa39b97
Compare
@C0urante you are right and I have added in that change. |
Recently added validations (see PR Aiven-Open#335) are preventing the support of schema evolution use-cases, e.g. Documentation: ``` If 'pk.mode' is 'record_key' and 'pk.fields' is empty, then all fields from the key struct will be used. ``` Configuration: ``` "pk.mode": "record_key", "auto.create": "true", "auto.evolve": "true", ``` Validation rule: ``` Primary key fields must be set when pkMode is 'record_key'. ``` The purpose of this PR is to re-enable this feature for `record_key` mode.
Recently added validations (see PR Aiven-Open#335) are preventing the support of schema evolution use-cases, e.g. Documentation: ``` If 'pk.mode' is 'record_key' and 'pk.fields' is empty, then all fields from the key struct will be used. ``` Configuration: ``` "pk.mode": "record_key", "auto.create": "true", "auto.evolve": "true", ``` Validation rule: ``` Primary key fields must be set when pkMode is 'record_key'. ``` The purpose of this PR is to re-enable this feature for both `record_key` and `record_value` modes.
* chore(deps): bump testcontainersVersion from 1.20.1 to 1.20.2 Bumps `testcontainersVersion` from 1.20.1 to 1.20.2. Updates `org.testcontainers:junit-jupiter` from 1.20.1 to 1.20.2 - [Release notes](https://github.com/testcontainers/testcontainers-java/releases) - [Changelog](https://github.com/testcontainers/testcontainers-java/blob/main/CHANGELOG.md) - [Commits](testcontainers/testcontainers-java@1.20.1...1.20.2) Updates `org.testcontainers:kafka` from 1.20.1 to 1.20.2 - [Release notes](https://github.com/testcontainers/testcontainers-java/releases) - [Changelog](https://github.com/testcontainers/testcontainers-java/blob/main/CHANGELOG.md) - [Commits](testcontainers/testcontainers-java@1.20.1...1.20.2) Updates `org.testcontainers:testcontainers` from 1.20.1 to 1.20.2 - [Release notes](https://github.com/testcontainers/testcontainers-java/releases) - [Changelog](https://github.com/testcontainers/testcontainers-java/blob/main/CHANGELOG.md) - [Commits](testcontainers/testcontainers-java@1.20.1...1.20.2) Updates `org.testcontainers:postgresql` from 1.20.1 to 1.20.2 - [Release notes](https://github.com/testcontainers/testcontainers-java/releases) - [Changelog](https://github.com/testcontainers/testcontainers-java/blob/main/CHANGELOG.md) - [Commits](testcontainers/testcontainers-java@1.20.1...1.20.2) Updates `org.testcontainers:oracle-free` from 1.20.1 to 1.20.2 - [Release notes](https://github.com/testcontainers/testcontainers-java/releases) - [Changelog](https://github.com/testcontainers/testcontainers-java/blob/main/CHANGELOG.md) - [Commits](testcontainers/testcontainers-java@1.20.1...1.20.2) --- updated-dependencies: - dependency-name: org.testcontainers:junit-jupiter dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.testcontainers:kafka dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.testcontainers:testcontainers dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.testcontainers:postgresql dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.testcontainers:oracle-free dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * fix: re-allow empty `pk.fields` for some `pk.mode` Recently added validations (see PR Aiven-Open#335) are preventing the support of schema evolution use-cases, e.g. Documentation: ``` If 'pk.mode' is 'record_key' and 'pk.fields' is empty, then all fields from the key struct will be used. ``` Configuration: ``` "pk.mode": "record_key", "auto.create": "true", "auto.evolve": "true", ``` Validation rule: ``` Primary key fields must be set when pkMode is 'record_key'. ``` The purpose of this PR is to re-enable this feature for both `record_key` and `record_value` modes. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Anatoly Popov <anatolii.popov@aiven.io> Co-authored-by: Julien Clarysse <julien.clarysse@aiven.io> Co-authored-by: Jonas Keeling <jonas.keeling@aiven.io>
This PR introduces validation logic for the primary key mode (
pk.mode
) against the primary key fields (pk.fields
) in theJdbcSinkConfig
class, ensuring that the configurations adhere to the documented requirements. Additionally, unit tests have been added to verify the correctness of the validation logic.Changes:
validatePKModeAgainstPKFields
method to validate the primary key mode against the primary key fields.pk.mode
andpk.fields
to ensure configurations are valid according to the documentation.