Skip to content

Commit

Permalink
source-mongodb-v2: adopt cleaned-up cdk (airbytehq#34748)
Browse files Browse the repository at this point in the history
  • Loading branch information
postamar authored and jatinyadav-cc committed Feb 26, 2024
1 parent 8ed3374 commit 1bb81cd
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 47 deletions.
57 changes: 18 additions & 39 deletions airbyte-integrations/connectors/source-mongodb-v2/build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
plugins {
id 'application'
id 'airbyte-java-connector'
alias(libs.plugins.kotlin.jvm)
}

airbyteJavaConnector {
cdkVersionRequired = '0.16.3'
features = ['db-sources']
cdkVersionRequired = '0.19.0'
features = ['db-sources', 'datastore-mongo']
useLocalCdk = false
}

airbyteJavaConnector.addCdkDependencies()

application {
mainClass = 'io.airbyte.integrations.source.mongodb.MongoDbSource'
applicationDefaultJvmArgs = ['-XX:+ExitOnOutOfMemoryError', '-XX:MaxRAMPercentage=75.0']
Expand Down Expand Up @@ -42,43 +39,25 @@ java {
}

dependencies {
implementation libs.mongo.driver.sync

implementation libs.debezium.api
implementation libs.debezium.embedded
implementation libs.debezium.mongodb

testImplementation libs.testcontainers.mongodb
implementation 'io.debezium:debezium-embedded:2.4.0.Final'
implementation 'io.debezium:debezium-connector-mongodb:2.4.0.Final'

integrationTestJavaImplementation libs.apache.commons.lang
integrationTestJavaImplementation project(':airbyte-integrations:connectors:source-mongodb-v2')

dataGeneratorImplementation platform(libs.fasterxml)
dataGeneratorImplementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310'
testImplementation 'org.testcontainers:mongodb:1.19.0'

dataGeneratorImplementation project(':airbyte-integrations:connectors:source-mongodb-v2')
dataGeneratorImplementation libs.mongo.driver.sync
dataGeneratorImplementation libs.kotlin.logging
dataGeneratorImplementation libs.kotlinx.cli
dataGeneratorImplementation (libs.java.faker) {
exclude module: 'snakeyaml'
}
dataGeneratorImplementation libs.jackson.databind
dataGeneratorImplementation libs.bundles.slf4j
dataGeneratorImplementation libs.slf4j.simple
dataGeneratorImplementation libs.kotlinx.cli.jvm
dataGeneratorImplementation 'org.yaml:snakeyaml:2.2'

debeziumTestImplementation libs.debezium.api
debeziumTestImplementation libs.debezium.embedded
debeziumTestImplementation libs.debezium.sqlserver
debeziumTestImplementation libs.debezium.mysql
debeziumTestImplementation libs.debezium.postgres
debeziumTestImplementation libs.debezium.mongodb
debeziumTestImplementation libs.bundles.slf4j
debeziumTestImplementation libs.slf4j.simple
debeziumTestImplementation libs.kotlinx.cli.jvm
debeziumTestImplementation libs.spotbugs.annotations
dataGeneratorImplementation platform('com.fasterxml.jackson:jackson-bom:2.15.2')
dataGeneratorImplementation 'com.fasterxml.jackson.core:jackson-databind'
dataGeneratorImplementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'

dataGeneratorImplementation ('com.github.javafaker:javafaker:1.0.2') { exclude module: 'snakeyaml' }
dataGeneratorImplementation 'io.github.oshai:kotlin-logging-jvm:5.1.0'
dataGeneratorImplementation 'org.jetbrains.kotlinx:kotlinx-cli-jvm:0.3.5'
dataGeneratorImplementation 'org.mongodb:mongodb-driver-sync:4.10.2'

debeziumTestImplementation 'io.debezium:debezium-embedded:2.4.0.Final'
debeziumTestImplementation 'io.debezium:debezium-connector-mongodb:2.4.0.Final'
debeziumTestImplementation 'org.jetbrains.kotlinx:kotlinx-cli-jvm:0.3.5'
debeziumTestImplementation 'com.github.spotbugs:spotbugs-annotations:4.7.3'
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ data:
connectorSubtype: database
connectorType: source
definitionId: b2e713cd-cc36-4c0a-b5bd-b47cb8a0561e
dockerImageTag: 1.2.7
dockerImageTag: 1.2.8
dockerRepository: airbyte/source-mongodb-v2
documentationUrl: https://docs.airbyte.com/integrations/sources/mongodb-v2
githubIssueLabel: source-mongodb-v2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
import io.airbyte.cdk.db.DataTypeUtils;
import io.airbyte.commons.json.Jsons;
import java.nio.charset.Charset;
import java.util.Base64;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.apache.commons.codec.binary.Base64;
import org.bson.BsonBinary;
import org.bson.BsonBoolean;
import org.bson.BsonDateTime;
Expand All @@ -46,7 +46,6 @@
import org.bson.types.Decimal128;
import org.bson.types.ObjectId;
import org.junit.jupiter.api.Test;
import org.testcontainers.shaded.com.google.common.collect.ImmutableMap;

class MongoDbCdcEventUtilsTest {

Expand Down Expand Up @@ -89,14 +88,14 @@ void testNormalizeObjectId() {
void testNormalizeObjectIdNoSchema() {
var objectNode = (ObjectNode) Jsons.jsonNode(Map.of(DOCUMENT_OBJECT_ID_FIELD, Map.of(OBJECT_ID_FIELD, OBJECT_ID)));
objectNode.set(SCHEMALESS_MODE_DATA_FIELD,
Jsons.jsonNode(ImmutableMap.of(DOCUMENT_OBJECT_ID_FIELD, Map.of(OBJECT_ID_FIELD, OBJECT_ID))));
Jsons.jsonNode(Map.of(DOCUMENT_OBJECT_ID_FIELD, Map.of(OBJECT_ID_FIELD, OBJECT_ID))));

final JsonNode data = MongoDbCdcEventUtils.normalizeObjectIdNoSchema(objectNode);
assertEquals(OBJECT_ID, data.get(DOCUMENT_OBJECT_ID_FIELD).asText());
assertEquals(OBJECT_ID, data.get(SCHEMALESS_MODE_DATA_FIELD).get(DOCUMENT_OBJECT_ID_FIELD).asText());

objectNode = (ObjectNode) Jsons.jsonNode(Map.of(DOCUMENT_OBJECT_ID_FIELD, Map.of()));
objectNode.set(SCHEMALESS_MODE_DATA_FIELD, Jsons.jsonNode(ImmutableMap.of(DOCUMENT_OBJECT_ID_FIELD, Map.of())));
objectNode.set(SCHEMALESS_MODE_DATA_FIELD, Jsons.jsonNode(Map.of(DOCUMENT_OBJECT_ID_FIELD, Map.of())));
final JsonNode dataWithoutObjectId = MongoDbCdcEventUtils.normalizeObjectIdNoSchema(objectNode);
assertNotEquals(OBJECT_ID, dataWithoutObjectId.get(DOCUMENT_OBJECT_ID_FIELD).asText());
assertNotEquals(OBJECT_ID, dataWithoutObjectId.get(SCHEMALESS_MODE_DATA_FIELD).get(DOCUMENT_OBJECT_ID_FIELD).asText());
Expand Down Expand Up @@ -143,7 +142,7 @@ void testTransformDataTypes() {
assertEquals(4.0, transformed.get("field5").asDouble());
assertEquals(expectedTimestamp, transformed.get("field6").asText());
assertEquals(expectedTimestamp, transformed.get("field7").asText());
assertEquals(Base64.encodeBase64String("test".getBytes(Charset.defaultCharset())), transformed.get("field8").asText());
assertEquals(Base64.getEncoder().encodeToString("test".getBytes(Charset.defaultCharset())), transformed.get("field8").asText());
assertEquals("test2", transformed.get("field9").asText());
assertEquals("test3", transformed.get("field10").asText());
assertEquals(OBJECT_ID, transformed.get("field11").asText());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.util.List;
import java.util.Map;
import org.junit.jupiter.api.Test;
import org.testcontainers.shaded.com.google.common.collect.ImmutableMap;

class MongoDbDebeziumEventConverterTest {

Expand Down Expand Up @@ -115,7 +114,7 @@ void testConvertMongoDbChangeEventNoSchema() throws IOException {
final ConfiguredAirbyteCatalog deleteNoBeforeConfiguredAirbyteCatalog = buildFromAirbyteMessage(expectedDeleteNoBefore);

final JsonNode noSchemaConfig =
Jsons.jsonNode(ImmutableMap.builder().put(MongoDbDebeziumConstants.Configuration.SCHEMA_ENFORCED_CONFIGURATION_KEY, false).build());
Jsons.jsonNode(Map.of(MongoDbDebeziumConstants.Configuration.SCHEMA_ENFORCED_CONFIGURATION_KEY, false));
final AirbyteMessage actualInsert = new MongoDbDebeziumEventConverter(
cdcMetadataInjector, buildFromAirbyteMessage(expectedInsert), emittedAt, noSchemaConfig)
.toAirbyteMessage(insertChangeEvent);
Expand Down
1 change: 1 addition & 0 deletions docs/integrations/sources/mongodb-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ For more information regarding configuration parameters, please see [MongoDb Doc

| Version | Date | Pull Request | Subject |
|:--------|:-----------|:---------------------------------------------------------|:----------------------------------------------------------------------------------------------------------|
| 1.2.8 | 2024-02-08 | [34748](https://github.com/airbytehq/airbyte/pull/34748) | Adopt CDK 0.19.0 |
| 1.2.7 | 2024-02-01 | [34759](https://github.com/airbytehq/airbyte/pull/34759) | Fail sync if initial snapshot for any stream fails. |
| 1.2.6 | 2024-01-31 | [34594](https://github.com/airbytehq/airbyte/pull/34594) | Scope initial resume token to streams of interest. |
| 1.2.5 | 2024-01-29 | [34641](https://github.com/airbytehq/airbyte/pull/34641) | Allow resuming an initial snapshot when Id type is not of default ObjectId . |
Expand Down

0 comments on commit 1bb81cd

Please sign in to comment.