Skip to content

Commit 7dc7375

Browse files
authored
Bulk load cdk: Update spec test to run against cloud+oss modes (airbytehq#46300)
1 parent 6de3c9c commit 7dc7375

File tree

6 files changed

+64
-9
lines changed

6 files changed

+64
-9
lines changed

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
airbyte-integrations/bases/base-normalization/integration_tests/normalization_test_output
22
airbyte-ci/connectors/pipelines/tests/test_changelog/result_files
33
airbyte-integrations/bases/connector-acceptance-test/unit_tests/data/docs
4+
airbyte-integrations/connectors/destination-*/src/test-integration/resources/expected-spec*.json
45

56
# Ignore manifest files in manifest-only connectors
67
# This is done due to prettier being overly opinionated on the formatting of quotes

airbyte-cdk/bulk/core/load/src/testFixtures/kotlin/io/airbyte/cdk/test/spec/SpecTest.kt

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import io.airbyte.cdk.test.util.FakeDataDumper
1717
import io.airbyte.cdk.test.util.IntegrationTest
1818
import io.airbyte.cdk.test.util.NoopDestinationCleaner
1919
import io.airbyte.cdk.test.util.NoopExpectedRecordMapper
20+
import io.airbyte.cdk.test.util.TestDeploymentMode
2021
import io.airbyte.cdk.util.Jsons
2122
import io.airbyte.protocol.models.v0.AirbyteMessage
2223
import java.nio.file.Files
@@ -25,9 +26,6 @@ import org.junit.jupiter.api.Assertions.assertEquals
2526
import org.junit.jupiter.api.Test
2627
import org.junit.jupiter.api.assertAll
2728

28-
private const val EXPECTED_SPEC_FILENAME = "expected-spec.json"
29-
private val expectedSpecPath = Path.of(EXPECTED_SPEC_FILENAME)
30-
3129
/**
3230
* This is largely copied from [io.airbyte.cdk.spec.SpecTest], but adapted to use our
3331
* [DestinationProcessFactory].
@@ -43,12 +41,28 @@ abstract class SpecTest :
4341
NoopExpectedRecordMapper,
4442
) {
4543
@Test
46-
fun testSpec() {
44+
fun testSpecOss() {
45+
testSpec(TestDeploymentMode.OSS)
46+
}
47+
48+
@Test
49+
fun testSpecCloud() {
50+
testSpec(TestDeploymentMode.CLOUD)
51+
}
52+
53+
private fun testSpec(deploymentMode: TestDeploymentMode) {
54+
val expectedSpecFilename = "expected-spec-${deploymentMode.name.lowercase()}.json"
55+
val expectedSpecPath = Path.of("src/test-integration/resources", expectedSpecFilename)
56+
4757
if (!Files.exists(expectedSpecPath)) {
4858
Files.createFile(expectedSpecPath)
4959
}
5060
val expectedSpec = Files.readString(expectedSpecPath)
51-
val process = destinationProcessFactory.createDestinationProcess("spec")
61+
val process =
62+
destinationProcessFactory.createDestinationProcess(
63+
"spec",
64+
deploymentMode = deploymentMode
65+
)
5266
process.run()
5367
val messages = process.readMessages()
5468
val specMessages = messages.filter { it.type == AirbyteMessage.Type.SPEC }
@@ -73,7 +87,7 @@ abstract class SpecTest :
7387
val diff: JsonDiff =
7488
DiffGenerator.diff(expectedSpec, Jsons.writeValueAsString(spec), jsonMatcher)
7589
assertAll(
76-
"Spec snapshot test failed. Run this test locally and then `git diff <...>/expected_spec.json` to see what changed, and commit the diff if that change was intentional.",
90+
"Spec snapshot test failed. Run this test locally and then `git diff <...>/$expectedSpecFilename` to see what changed, and commit the diff if that change was intentional.",
7791
{ assertEquals("", OnlyErrorDiffViewer.from(diff).toString()) },
7892
{ assertEquals(expectedSpec, actualSpecPrettyPrint) }
7993
)

airbyte-integrations/connectors/destination-dev-null/src/test-integration/kotlin/io/airbyte/integrations/destination/dev_null/DevNullBasicFunctionalityIntegrationTest.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
package io.airbyte.integrations.destination.dev_null
66

7-
import io.airbyte.cdk.test.spec.SpecTest
87
import io.airbyte.cdk.test.util.NoopDestinationCleaner
98
import io.airbyte.cdk.test.util.NoopExpectedRecordMapper
109
import io.airbyte.cdk.test.write.BasicFunctionalityIntegrationTest
@@ -29,5 +28,3 @@ class DevNullBasicFunctionalityIntegrationTest :
2928
super.testBasicWrite()
3029
}
3130
}
32-
33-
class DevNullSpecTest : SpecTest()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
* Copyright (c) 2024 Airbyte, Inc., all rights reserved.
3+
*/
4+
5+
package io.airbyte.integrations.destination.dev_null
6+
7+
import io.airbyte.cdk.test.spec.SpecTest
8+
9+
class DevNullSpecTest : SpecTest()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"documentationUrl" : "https://docs.airbyte.com/integrations/destinations/dev-null",
3+
"connectionSpecification" : {
4+
"$schema" : "http://json-schema.org/draft-07/schema#",
5+
"title" : "E2E Test Destination Spec",
6+
"type" : "object",
7+
"additionalProperties" : true,
8+
"properties" : {
9+
"test_destination" : {
10+
"oneOf" : [ {
11+
"title" : "Silent",
12+
"type" : "object",
13+
"additionalProperties" : true,
14+
"properties" : {
15+
"test_destination_type" : {
16+
"type" : "string",
17+
"enum" : [ "SILENT" ],
18+
"default" : "SILENT"
19+
}
20+
},
21+
"required" : [ "test_destination_type" ]
22+
} ],
23+
"description" : "The type of destination to be used",
24+
"title" : "Test Destination",
25+
"type" : "object"
26+
}
27+
},
28+
"required" : [ "test_destination" ]
29+
},
30+
"supportsIncremental" : true,
31+
"supportsNormalization" : false,
32+
"supportsDBT" : false,
33+
"supported_destination_sync_modes" : [ "overwrite", "append", "append_dedup" ]
34+
}

0 commit comments

Comments
 (0)