-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Debezium IO yaml #39457
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
Merged
Merged
Debezium IO yaml #39457
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
621a78c
Add Beam YAML support for DebeziumIO
Amar3tto 01c668b
Add Debezium YAML integration test
Amar3tto a226755
Fix record schema
Amar3tto 25ed2f8
With max num of records
Amar3tto aae48ec
Add setters
Amar3tto 2541fc7
Refactoring
Amar3tto 315ed95
Fix python formatter
Amar3tto b85646b
Remove primaryKeyColumns options
Amar3tto 5178343
Fix spotless
Amar3tto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 139 additions & 0 deletions
139
...um/src/test/java/org/apache/beam/io/debezium/DebeziumReadSchemaTransformProviderTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.beam.io.debezium; | ||
|
|
||
| import static org.hamcrest.MatcherAssert.assertThat; | ||
| import static org.junit.Assert.assertThrows; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.Collections; | ||
| import org.hamcrest.Matchers; | ||
| import org.junit.Test; | ||
|
|
||
| public class DebeziumReadSchemaTransformProviderTest { | ||
|
|
||
| private static DebeziumReadSchemaTransformProvider.DebeziumReadSchemaTransformConfiguration | ||
| .Builder | ||
| validConfiguration() { | ||
| return DebeziumReadSchemaTransformProvider.DebeziumReadSchemaTransformConfiguration.builder() | ||
| .setUsername("user") | ||
| .setPassword("password") | ||
| .setHost("localhost") | ||
| .setPort(5432) | ||
| .setDatabase("POSTGRES") | ||
| .setTable("inventory.customers") | ||
| .setDebeziumConnectionProperties(Collections.emptyList()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testValidConfiguration() { | ||
| validConfiguration().build().validate(); | ||
| } | ||
|
|
||
| @Test | ||
| public void testEmptyHost() { | ||
| IllegalArgumentException exception = | ||
| assertThrows( | ||
| IllegalArgumentException.class, | ||
| () -> validConfiguration().setHost("").build().validate()); | ||
|
|
||
| assertThat(exception.getMessage(), Matchers.containsString("host must not be empty")); | ||
| } | ||
|
|
||
| @Test | ||
| public void testInvalidPort() { | ||
| IllegalArgumentException exception = | ||
| assertThrows( | ||
| IllegalArgumentException.class, | ||
| () -> validConfiguration().setPort(0).build().validate()); | ||
|
|
||
| assertThat(exception.getMessage(), Matchers.containsString("port must be between")); | ||
| } | ||
|
|
||
| @Test | ||
| public void testEmptyTable() { | ||
| IllegalArgumentException exception = | ||
| assertThrows( | ||
| IllegalArgumentException.class, | ||
| () -> validConfiguration().setTable("").build().validate()); | ||
|
|
||
| assertThat(exception.getMessage(), Matchers.containsString("table must not be empty")); | ||
| } | ||
|
|
||
| @Test | ||
| public void testInvalidConnectionProperty() { | ||
| IllegalArgumentException exception = | ||
| assertThrows( | ||
| IllegalArgumentException.class, | ||
| () -> | ||
| validConfiguration() | ||
| .setDebeziumConnectionProperties(Collections.singletonList("invalid-property")) | ||
| .build() | ||
| .validate()); | ||
|
|
||
| assertThat(exception.getMessage(), Matchers.containsString("Expected key=value format")); | ||
| } | ||
|
|
||
| @Test | ||
| public void testNullConnectionProperty() { | ||
| IllegalArgumentException exception = | ||
| assertThrows( | ||
| IllegalArgumentException.class, | ||
| () -> | ||
| validConfiguration() | ||
| .setDebeziumConnectionProperties(Arrays.asList("valid=value", null)) | ||
| .build() | ||
| .validate()); | ||
|
|
||
| assertThat(exception.getMessage(), Matchers.containsString("Expected key=value format")); | ||
| } | ||
|
|
||
| @Test | ||
| public void testConnectionPropertyValueContainingEquals() { | ||
| validConfiguration() | ||
| .setDebeziumConnectionProperties( | ||
| Collections.singletonList("some.property=value=containing=equals")) | ||
| .build() | ||
| .validate(); | ||
| } | ||
|
|
||
| @Test | ||
| public void testUnsupportedConnector() { | ||
| IllegalArgumentException exception = | ||
| assertThrows( | ||
| IllegalArgumentException.class, | ||
| () -> | ||
| new DebeziumReadSchemaTransformProvider() | ||
| .from(validConfiguration().setDatabase("UNKNOWN").build())); | ||
|
|
||
| assertThat(exception.getMessage(), Matchers.containsString("Unsupported connector 'UNKNOWN'")); | ||
| assertThat(exception.getMessage(), Matchers.containsString("MYSQL")); | ||
| assertThat(exception.getMessage(), Matchers.containsString("POSTGRES")); | ||
| } | ||
|
|
||
| @Test | ||
| public void testProviderContract() { | ||
| DebeziumReadSchemaTransformProvider provider = new DebeziumReadSchemaTransformProvider(); | ||
|
|
||
| assertThat(provider.inputCollectionNames(), Matchers.empty()); | ||
| assertThat(provider.outputCollectionNames(), Matchers.contains("output")); | ||
| assertThat( | ||
| provider.identifier(), | ||
| Matchers.equalTo("beam:schematransform:org.apache.beam:debezium_read:v1")); | ||
| } | ||
| } |
50 changes: 50 additions & 0 deletions
50
sdks/python/apache_beam/yaml/extended_tests/databases/debezium.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # | ||
| # Licensed to the Apache Software Foundation (ASF) under one or more | ||
| # contributor license agreements. See the NOTICE file distributed with | ||
| # this work for additional information regarding copyright ownership. | ||
| # The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| # (the "License"); you may not use this file except in compliance with | ||
| # the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
|
|
||
| fixtures: | ||
| - name: DEBEZIUM_DB | ||
| type: "apache_beam.yaml.integration_tests.temp_debezium_postgres_database" | ||
|
|
||
| pipelines: | ||
| - pipeline: | ||
| type: chain | ||
| transforms: | ||
| - type: ReadFromDebezium | ||
| config: | ||
| connector: POSTGRES | ||
| username: "{DEBEZIUM_DB[USERNAME]}" | ||
| password: "{DEBEZIUM_DB[PASSWORD]}" | ||
| host: "{DEBEZIUM_DB[HOST]}" | ||
| port: "{DEBEZIUM_DB[PORT]}" | ||
| table: "{DEBEZIUM_DB[TABLE]}" | ||
| max_number_of_records: 2 | ||
| max_time_to_run: 600000 | ||
| connection_properties: | ||
| - "database.dbname={DEBEZIUM_DB[DATABASE]}" | ||
| - "plugin.name=pgoutput" | ||
| - "snapshot.mode=initial_only" | ||
| - type: MapToFields | ||
| config: | ||
| language: python | ||
| fields: | ||
| id: "after.id" | ||
| name: "after.name" | ||
| - type: AssertEqual | ||
| config: | ||
| elements: | ||
| - {id: 1, name: Alice} | ||
| - {id: 2, name: Bob} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.