DBZ-3943 Add ConfigDef unit tests to verify all Debezium Field instances have a proper documentation/description set;
Also adding missing descriptions.
This commit is contained in:
parent
6f1577a70b
commit
b92e5c5efe
@ -413,7 +413,11 @@ public static SnapshotMode parse(String value, String defaultValue) {
|
|||||||
.withWidth(Width.LONG)
|
.withWidth(Width.LONG)
|
||||||
.withImportance(Importance.MEDIUM)
|
.withImportance(Importance.MEDIUM)
|
||||||
.withValidation(MongoDbConnectorConfig::validateFieldRenamesList)
|
.withValidation(MongoDbConnectorConfig::validateFieldRenamesList)
|
||||||
.withDescription("");
|
.withDescription("A comma-separated list of the fully-qualified replacements of fields that" +
|
||||||
|
" should be used to rename fields in change event message values. Fully-qualified replacements" +
|
||||||
|
" for fields are of the form databaseName.collectionName.fieldName.nestedFieldName:newNestedFieldName," +
|
||||||
|
" where databaseName and collectionName may contain the wildcard (*) which matches any characters," +
|
||||||
|
" the colon character (:) is used to determine rename mapping of field.");
|
||||||
|
|
||||||
public static final Field SNAPSHOT_MODE = Field.create("snapshot.mode")
|
public static final Field SNAPSHOT_MODE = Field.create("snapshot.mode")
|
||||||
.withDisplayName("Snapshot mode")
|
.withDisplayName("Snapshot mode")
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* Copyright Debezium Authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*/
|
||||||
|
package io.debezium.connector.mongodb;
|
||||||
|
|
||||||
|
import io.debezium.config.ConfigDefinitionMetadataTest;
|
||||||
|
|
||||||
|
public class MongoDbConnectorConfigDefTest extends ConfigDefinitionMetadataTest {
|
||||||
|
|
||||||
|
public MongoDbConnectorConfigDefTest() {
|
||||||
|
super(new MongoDbConnector());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* Copyright Debezium Authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*/
|
||||||
|
package io.debezium.connector.mongodb;
|
||||||
|
|
||||||
|
import io.debezium.config.TransformationConfigDefinitionMetadataTest;
|
||||||
|
import io.debezium.connector.mongodb.transforms.ExtractNewDocumentState;
|
||||||
|
|
||||||
|
public class MongoDbTransformationConfigDefTest extends TransformationConfigDefinitionMetadataTest {
|
||||||
|
|
||||||
|
public MongoDbTransformationConfigDefTest() {
|
||||||
|
super(new ExtractNewDocumentState<>());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* Copyright Debezium Authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*/
|
||||||
|
package io.debezium.connector.mysql;
|
||||||
|
|
||||||
|
import io.debezium.config.ConfigDefinitionMetadataTest;
|
||||||
|
|
||||||
|
public class MySqlConnectorConfigDefTest extends ConfigDefinitionMetadataTest {
|
||||||
|
|
||||||
|
public MySqlConnectorConfigDefTest() {
|
||||||
|
super(new MySqlConnector());
|
||||||
|
}
|
||||||
|
}
|
@ -285,7 +285,13 @@ public class OracleConnectorConfig extends HistorizedRelationalDatabaseConnector
|
|||||||
public static final Field LOG_MINING_BUFFER_TYPE = Field.create("log.mining.buffer.type")
|
public static final Field LOG_MINING_BUFFER_TYPE = Field.create("log.mining.buffer.type")
|
||||||
.withDisplayName("Controls which buffer type implementation to be used")
|
.withDisplayName("Controls which buffer type implementation to be used")
|
||||||
.withEnum(LogMiningBufferType.class, LogMiningBufferType.MEMORY)
|
.withEnum(LogMiningBufferType.class, LogMiningBufferType.MEMORY)
|
||||||
.withImportance(Importance.LOW);
|
.withImportance(Importance.LOW)
|
||||||
|
.withDescription("The buffer type controls how the connector manages buffering transaction data." + System.lineSeparator() +
|
||||||
|
System.lineSeparator() +
|
||||||
|
"memory - Uses the JVM process' heap to buffer all transaction data." + System.lineSeparator() +
|
||||||
|
System.lineSeparator() +
|
||||||
|
"infinispan - This option uses an embedded Infinispan cache to buffer transaction data and persist it to disk." +
|
||||||
|
" Use the log.mining.buffer.location property to define the location for storing cache files.");
|
||||||
|
|
||||||
public static final Field LOG_MINING_BUFFER_LOCATION = Field.create("log.mining.buffer.location")
|
public static final Field LOG_MINING_BUFFER_LOCATION = Field.create("log.mining.buffer.location")
|
||||||
.withDisplayName("Location where Infinispan stores buffer caches")
|
.withDisplayName("Location where Infinispan stores buffer caches")
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* Copyright Debezium Authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*/
|
||||||
|
package io.debezium.connector.oracle;
|
||||||
|
|
||||||
|
import io.debezium.config.ConfigDefinitionMetadataTest;
|
||||||
|
|
||||||
|
public class OracleConnectorConfigDefTest extends ConfigDefinitionMetadataTest {
|
||||||
|
|
||||||
|
public OracleConnectorConfigDefTest() {
|
||||||
|
super(new OracleConnector());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* Copyright Debezium Authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*/
|
||||||
|
package io.debezium.connector.postgresql;
|
||||||
|
|
||||||
|
import io.debezium.config.ConfigDefinitionMetadataTest;
|
||||||
|
|
||||||
|
public class PostgresConnectorConfigDefTest extends ConfigDefinitionMetadataTest {
|
||||||
|
|
||||||
|
public PostgresConnectorConfigDefTest() {
|
||||||
|
super(new PostgresConnector());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* Copyright Debezium Authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*/
|
||||||
|
package io.debezium.connector.sqlserver;
|
||||||
|
|
||||||
|
import io.debezium.config.ConfigDefinitionMetadataTest;
|
||||||
|
|
||||||
|
public class SqlServerConnectorConfigDefTest extends ConfigDefinitionMetadataTest {
|
||||||
|
|
||||||
|
public SqlServerConnectorConfigDefTest() {
|
||||||
|
super(new SqlServerConnector());
|
||||||
|
}
|
||||||
|
}
|
@ -88,10 +88,11 @@ public static DeleteHandling parse(String value, String defaultValue) {
|
|||||||
+ "rewrite - __deleted field is added to records.");
|
+ "rewrite - __deleted field is added to records.");
|
||||||
|
|
||||||
public static final Field ROUTE_BY_FIELD = Field.create("route.by.field")
|
public static final Field ROUTE_BY_FIELD = Field.create("route.by.field")
|
||||||
.withDisplayName("The column which determines how the events will be routed, the value will replace the topic name.")
|
.withDisplayName("Route by field name")
|
||||||
.withType(ConfigDef.Type.STRING)
|
.withType(ConfigDef.Type.STRING)
|
||||||
.withWidth(ConfigDef.Width.LONG)
|
.withWidth(ConfigDef.Width.LONG)
|
||||||
.withImportance(ConfigDef.Importance.LOW)
|
.withImportance(ConfigDef.Importance.LOW)
|
||||||
|
.withDescription("The column which determines how the events will be routed, the value will replace the topic name.")
|
||||||
.withDefault("");
|
.withDefault("");
|
||||||
|
|
||||||
public static final Field ADD_FIELDS_PREFIX = Field.create("add.fields.prefix")
|
public static final Field ADD_FIELDS_PREFIX = Field.create("add.fields.prefix")
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright Debezium Authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*/
|
||||||
|
package io.debezium.config;
|
||||||
|
|
||||||
|
import static org.fest.assertions.Assertions.assertThat;
|
||||||
|
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.apache.kafka.common.config.ConfigDef;
|
||||||
|
import org.apache.kafka.common.config.ConfigDef.ConfigKey;
|
||||||
|
import org.apache.kafka.connect.source.SourceConnector;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies basic checks of completeness for the connector-specific configuration metadata.
|
||||||
|
*/
|
||||||
|
public abstract class ConfigDefinitionMetadataTest {
|
||||||
|
|
||||||
|
private final ConfigDef config;
|
||||||
|
|
||||||
|
protected ConfigDefinitionMetadataTest(SourceConnector connector) {
|
||||||
|
this.config = connector.config();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void allFieldsShouldHaveDescription() {
|
||||||
|
for (Entry<String, ConfigKey> configKey : config.configKeys().entrySet()) {
|
||||||
|
assertThat(configKey.getValue().documentation)
|
||||||
|
.describedAs("Description of config key \"" + configKey.getKey() + "\"")
|
||||||
|
.isNotNull()
|
||||||
|
.isNotEmpty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright Debezium Authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*/
|
||||||
|
package io.debezium.config;
|
||||||
|
|
||||||
|
import io.debezium.transforms.ByLogicalTableRouter;
|
||||||
|
import io.debezium.transforms.ExtractNewRecordState;
|
||||||
|
import io.debezium.transforms.outbox.EventRouter;
|
||||||
|
import io.debezium.transforms.tracing.ActivateTracingSpan;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies basic checks of completeness of the SMT-specific configuration metadata for the Debezium core SMTs.
|
||||||
|
*/
|
||||||
|
public class CoreTransformationConfigDefinitionMetadataTest extends TransformationConfigDefinitionMetadataTest {
|
||||||
|
|
||||||
|
public CoreTransformationConfigDefinitionMetadataTest() {
|
||||||
|
super(
|
||||||
|
new ByLogicalTableRouter<>(),
|
||||||
|
new ExtractNewRecordState<>(),
|
||||||
|
new EventRouter<>(),
|
||||||
|
new ActivateTracingSpan<>());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright Debezium Authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*/
|
||||||
|
package io.debezium.config;
|
||||||
|
|
||||||
|
import static org.fest.assertions.Assertions.assertThat;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.apache.kafka.common.config.ConfigDef.ConfigKey;
|
||||||
|
import org.apache.kafka.connect.transforms.Transformation;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies basic checks of completeness for the SMT-specific configuration metadata.
|
||||||
|
*/
|
||||||
|
public abstract class TransformationConfigDefinitionMetadataTest {
|
||||||
|
|
||||||
|
private final Set<Transformation<?>> transforms;
|
||||||
|
|
||||||
|
public TransformationConfigDefinitionMetadataTest(Transformation<?>... transforms) {
|
||||||
|
Set<Transformation<?>> tmp = new HashSet<>();
|
||||||
|
Collections.addAll(tmp, transforms);
|
||||||
|
this.transforms = Collections.unmodifiableSet(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void allFieldsShouldHaveDescription() {
|
||||||
|
for (Transformation<?> transformation : transforms) {
|
||||||
|
for (Entry<String, ConfigKey> configKey : transformation.config().configKeys().entrySet()) {
|
||||||
|
assertThat(configKey.getValue().documentation)
|
||||||
|
.describedAs("Description of config key \"" + configKey.getKey() + "\" of transform class " + transformation.getClass().getName())
|
||||||
|
.isNotNull()
|
||||||
|
.isNotEmpty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* Copyright Debezium Authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*/
|
||||||
|
package io.debezium.transforms;
|
||||||
|
|
||||||
|
import io.debezium.config.TransformationConfigDefinitionMetadataTest;
|
||||||
|
|
||||||
|
public class ScriptingTransformationConfigDefTest extends TransformationConfigDefinitionMetadataTest {
|
||||||
|
|
||||||
|
public ScriptingTransformationConfigDefTest() {
|
||||||
|
super(new Filter<>(), new ContentBasedRouter<>());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user