-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Rbroughan/component tests operations test 1 #67624
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
Draft
tryangul
wants to merge
3
commits into
master
Choose a base branch
from
rbroughan/component-tests-operations-test-1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+186
−4
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
81 changes: 81 additions & 0 deletions
81
...re/load/src/testFixtures/kotlin/io/airbyte/cdk/load/component/CoreTableOperationsSuite.kt
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,81 @@ | ||
/* | ||
* Copyright (c) 2025 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.cdk.load.component | ||
|
||
import io.airbyte.cdk.load.CoreTableOperationsClient | ||
import io.airbyte.cdk.load.command.Append | ||
import io.airbyte.cdk.load.command.DestinationStream | ||
import io.airbyte.cdk.load.command.NamespaceMapper | ||
import io.airbyte.cdk.load.data.ObjectType | ||
import io.airbyte.cdk.load.orchestration.db.ColumnNameMapping | ||
import io.airbyte.cdk.load.orchestration.db.TableName | ||
import java.util.UUID | ||
import kotlinx.coroutines.test.runTest | ||
import org.junit.jupiter.api.assertDoesNotThrow | ||
|
||
interface CoreTableOperationsSuite { | ||
val client: CoreTableOperationsClient | ||
|
||
fun `connect to database`() = runTest { | ||
assertDoesNotThrow { client.ping() } | ||
} | ||
|
||
fun `create and drop namespaces`() = runTest { | ||
val testNamespace = "namespace-test-${UUID.randomUUID()}" | ||
|
||
require(!client.namespaceExists(testNamespace)) { "test namespace: $testNamespace already exists. Please validate it's deleted before running again." } | ||
|
||
client.createNamespace(testNamespace) | ||
|
||
assert(client.namespaceExists(testNamespace)) | ||
|
||
client.dropNamespace(testNamespace) | ||
|
||
assert(!client.namespaceExists(testNamespace)) | ||
} | ||
|
||
fun `create and drop tables`() = runTest { | ||
val uniquePostFix = UUID.randomUUID() | ||
val testTable = TableName( | ||
"table-test-namespace-$uniquePostFix", | ||
"table-test-table-$uniquePostFix", | ||
) | ||
|
||
require(!client.tableExists(testTable)) { "test table: ${testTable.namespace}.${testTable.name} already exists. Please validate it's deleted before running again." } | ||
|
||
client.createTable( | ||
stream = DestinationStream( | ||
unmappedNamespace = testTable.namespace, | ||
unmappedName = testTable.name, | ||
importType = Append, | ||
generationId = 1, | ||
minimumGenerationId = 0, | ||
syncId = 1, | ||
includeFiles = false, | ||
schema = ObjectType(linkedMapOf()), | ||
namespaceMapper = NamespaceMapper(), | ||
), | ||
tableName = testTable, | ||
columnNameMapping = ColumnNameMapping(mapOf()), | ||
replace = false, | ||
) | ||
|
||
assert(client.tableExists(testTable)) | ||
|
||
client.dropTable(testTable) | ||
|
||
assert(!client.tableExists(testTable)) | ||
} | ||
|
||
fun `count table rows`() {} | ||
|
||
fun `overwrite tables`() {} | ||
|
||
fun `copy tables`() {} | ||
|
||
fun `upsert tables`() {} | ||
|
||
fun `get generation id`() {} | ||
} |
21 changes: 21 additions & 0 deletions
21
...dk/bulk/toolkits/load-db/src/main/kotlin/io/airbyte/cdk/load/CoreTableOperationsClient.kt
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,21 @@ | ||
package io.airbyte.cdk.load | ||
|
||
import io.airbyte.cdk.load.client.AirbyteClient | ||
import io.airbyte.cdk.load.orchestration.db.TableName | ||
import io.airbyte.cdk.load.orchestration.db.direct_load_table.DirectLoadTableNativeOperations | ||
import io.airbyte.cdk.load.orchestration.db.direct_load_table.DirectLoadTableSqlOperations | ||
|
||
interface CoreTableOperationsClient : | ||
AirbyteClient, | ||
DirectLoadTableSqlOperations, | ||
DirectLoadTableNativeOperations { | ||
|
||
suspend fun ping() = Unit | ||
|
||
suspend fun namespaceExists(namespace: String) = false | ||
|
||
suspend fun dropNamespace(namespace: String) = Unit | ||
|
||
suspend fun tableExists(table: TableName) = false | ||
|
||
} |
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
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
47 changes: 47 additions & 0 deletions
47
...io/airbyte/integrations/destination/clickhouse/component/ClickhouseTableOperationsTest.kt
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,47 @@ | ||
package io.airbyte.integrations.destination.clickhouse.component | ||
|
||
import io.airbyte.cdk.load.component.CoreTableOperationsSuite | ||
import io.airbyte.integrations.destination.clickhouse.client.ClickhouseAirbyteClient | ||
import io.micronaut.test.extensions.junit5.annotation.MicronautTest | ||
import jakarta.inject.Inject | ||
import org.junit.jupiter.api.Test | ||
|
||
@MicronautTest | ||
class ClickhouseTableOperationsTest: CoreTableOperationsSuite { | ||
@Inject | ||
override lateinit var client: ClickhouseAirbyteClient | ||
|
||
@Test | ||
override fun `connect to database`() { | ||
super.`connect to database`() | ||
} | ||
|
||
@Test | ||
override fun `create and drop tables`() { | ||
super.`create and drop tables`() | ||
} | ||
|
||
override fun `create and drop namespaces`() { | ||
super.`create and drop namespaces`() | ||
} | ||
|
||
override fun `count table rows`() { | ||
super.`count table rows`() | ||
} | ||
|
||
override fun `overwrite tables`() { | ||
super.`overwrite tables`() | ||
} | ||
|
||
override fun `copy tables`() { | ||
super.`copy tables`() | ||
} | ||
|
||
override fun `upsert tables`() { | ||
super.`upsert tables`() | ||
} | ||
|
||
override fun `get generation id`() { | ||
super.`get generation id`() | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...o/airbyte/integrations/destination/clickhouse/component/config/TestConfigBeanOverrides.kt
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,24 @@ | ||
package io.airbyte.integrations.destination.clickhouse.component.config | ||
|
||
import io.airbyte.cdk.util.Jsons | ||
import io.airbyte.integrations.destination.clickhouse.spec.ClickhouseConfiguration | ||
import io.airbyte.integrations.destination.clickhouse.spec.ClickhouseConfigurationFactory | ||
import io.airbyte.integrations.destination.clickhouse.spec.ClickhouseSpecificationOss | ||
import io.micronaut.context.annotation.Factory | ||
import io.micronaut.context.annotation.Primary | ||
import jakarta.inject.Singleton | ||
import java.nio.file.Files | ||
import kotlin.io.path.Path | ||
|
||
@Factory | ||
class TestConfigBeanOverrides { | ||
@Singleton | ||
@Primary | ||
fun config(): ClickhouseConfiguration { | ||
val configPath = Path("secrets/test-instance.json") | ||
val configStr = Files.readString(configPath) | ||
val spec = Jsons.readValue(configStr, ClickhouseSpecificationOss::class.java) | ||
|
||
return ClickhouseConfigurationFactory().makeWithoutExceptionHandling(spec) | ||
} | ||
} |
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.
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.
@edgao I've got a file named
test-instance.json
in the secrets dir with creds etc in there and I want this to be injected for the tests.