forked from airbytehq/airbyte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Part 1 ] : Hackday project to debug connections (airbytehq#33027)
Co-authored-by: akashkulk <[email protected]>
- Loading branch information
Showing
13 changed files
with
129 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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 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
2 changes: 1 addition & 1 deletion
2
airbyte-cdk/java/airbyte-cdk/core/src/main/resources/version.properties
This file contains 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 |
---|---|---|
@@ -1 +1 @@ | ||
version=0.7.0 | ||
version=0.7.1 |
54 changes: 54 additions & 0 deletions
54
...yte-cdk/db-sources/src/testFixtures/java/io/airbyte/cdk/integrations/debug/DebugUtil.java
This file contains 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,54 @@ | ||
/* | ||
* Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.cdk.integrations.debug; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import io.airbyte.cdk.integrations.base.Source; | ||
import io.airbyte.commons.json.Jsons; | ||
import io.airbyte.commons.resources.MoreResources; | ||
import io.airbyte.commons.util.AutoCloseableIterator; | ||
import io.airbyte.protocol.models.v0.AirbyteMessage; | ||
import io.airbyte.protocol.models.v0.AirbyteStateMessage; | ||
import io.airbyte.protocol.models.v0.ConfiguredAirbyteCatalog; | ||
import java.util.Collections; | ||
|
||
/** | ||
* Utility class defined to debug a source. Copy over any relevant configurations, catalogs & state | ||
* in the resources/debug_resources directory. | ||
*/ | ||
public class DebugUtil { | ||
|
||
@SuppressWarnings({"unchecked", "deprecation", "resource"}) | ||
public static void debug(final Source debugSource) throws Exception { | ||
final JsonNode debugConfig = DebugUtil.getConfig(); | ||
final ConfiguredAirbyteCatalog configuredAirbyteCatalog = DebugUtil.getCatalog(); | ||
final JsonNode state = DebugUtil.getState(); | ||
|
||
debugSource.check(debugConfig); | ||
debugSource.discover(debugConfig); | ||
|
||
final AutoCloseableIterator<AirbyteMessage> messageIterator = debugSource.read(debugConfig, configuredAirbyteCatalog, state); | ||
messageIterator.forEachRemaining(message -> {}); | ||
} | ||
|
||
private static JsonNode getConfig() throws Exception { | ||
final JsonNode originalConfig = new ObjectMapper().readTree(MoreResources.readResource("debug_resources/config.json")); | ||
final JsonNode debugConfig = ((ObjectNode) originalConfig.deepCopy()).put("debug_mode", true); | ||
return debugConfig; | ||
} | ||
|
||
private static ConfiguredAirbyteCatalog getCatalog() throws Exception { | ||
final String catalog = MoreResources.readResource("debug_resources/configured_catalog.json"); | ||
return Jsons.deserialize(catalog, ConfiguredAirbyteCatalog.class); | ||
} | ||
|
||
private static JsonNode getState() throws Exception { | ||
final AirbyteStateMessage message = Jsons.deserialize(MoreResources.readResource("debug_resources/state.json"), AirbyteStateMessage.class); | ||
return Jsons.jsonNode(Collections.singletonList(message)); | ||
} | ||
|
||
} |
This file contains 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 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 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 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 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
20 changes: 20 additions & 0 deletions
20
...urce-postgres/src/test/java/io/airbyte/integrations/source/postgres/PostgresDebugger.java
This file contains 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,20 @@ | ||
/* | ||
* Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.integrations.source.postgres; | ||
|
||
import io.airbyte.cdk.integrations.debug.DebugUtil; | ||
import io.airbyte.commons.features.EnvVariableFeatureFlags; | ||
import io.airbyte.commons.features.FeatureFlagsWrapper; | ||
|
||
public class PostgresDebugger { | ||
|
||
@SuppressWarnings({"unchecked", "deprecation", "resource"}) | ||
public static void main(final String[] args) throws Exception { | ||
final PostgresSource postgresSource = new PostgresSource(); | ||
postgresSource.setFeatureFlags(FeatureFlagsWrapper.overridingUseStreamCapableState(new EnvVariableFeatureFlags(), true)); | ||
DebugUtil.debug(postgresSource); | ||
} | ||
|
||
} |
This file contains 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 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 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