1
0
mirror of synced 2025-12-19 18:14:56 -05:00

Bulk load cdk: Update spec test to run against cloud+oss modes (#46300)

This commit is contained in:
Edward Gao
2024-10-03 12:48:25 -07:00
committed by GitHub
parent 6de3c9c44c
commit 7dc73752cf
6 changed files with 64 additions and 9 deletions

View File

@@ -1,6 +1,7 @@
airbyte-integrations/bases/base-normalization/integration_tests/normalization_test_output airbyte-integrations/bases/base-normalization/integration_tests/normalization_test_output
airbyte-ci/connectors/pipelines/tests/test_changelog/result_files airbyte-ci/connectors/pipelines/tests/test_changelog/result_files
airbyte-integrations/bases/connector-acceptance-test/unit_tests/data/docs airbyte-integrations/bases/connector-acceptance-test/unit_tests/data/docs
airbyte-integrations/connectors/destination-*/src/test-integration/resources/expected-spec*.json
# Ignore manifest files in manifest-only connectors # Ignore manifest files in manifest-only connectors
# This is done due to prettier being overly opinionated on the formatting of quotes # This is done due to prettier being overly opinionated on the formatting of quotes

View File

@@ -17,6 +17,7 @@ import io.airbyte.cdk.test.util.FakeDataDumper
import io.airbyte.cdk.test.util.IntegrationTest import io.airbyte.cdk.test.util.IntegrationTest
import io.airbyte.cdk.test.util.NoopDestinationCleaner import io.airbyte.cdk.test.util.NoopDestinationCleaner
import io.airbyte.cdk.test.util.NoopExpectedRecordMapper import io.airbyte.cdk.test.util.NoopExpectedRecordMapper
import io.airbyte.cdk.test.util.TestDeploymentMode
import io.airbyte.cdk.util.Jsons import io.airbyte.cdk.util.Jsons
import io.airbyte.protocol.models.v0.AirbyteMessage import io.airbyte.protocol.models.v0.AirbyteMessage
import java.nio.file.Files import java.nio.file.Files
@@ -25,9 +26,6 @@ import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertAll import org.junit.jupiter.api.assertAll
private const val EXPECTED_SPEC_FILENAME = "expected-spec.json"
private val expectedSpecPath = Path.of(EXPECTED_SPEC_FILENAME)
/** /**
* This is largely copied from [io.airbyte.cdk.spec.SpecTest], but adapted to use our * This is largely copied from [io.airbyte.cdk.spec.SpecTest], but adapted to use our
* [DestinationProcessFactory]. * [DestinationProcessFactory].
@@ -43,12 +41,28 @@ abstract class SpecTest :
NoopExpectedRecordMapper, NoopExpectedRecordMapper,
) { ) {
@Test @Test
fun testSpec() { fun testSpecOss() {
testSpec(TestDeploymentMode.OSS)
}
@Test
fun testSpecCloud() {
testSpec(TestDeploymentMode.CLOUD)
}
private fun testSpec(deploymentMode: TestDeploymentMode) {
val expectedSpecFilename = "expected-spec-${deploymentMode.name.lowercase()}.json"
val expectedSpecPath = Path.of("src/test-integration/resources", expectedSpecFilename)
if (!Files.exists(expectedSpecPath)) { if (!Files.exists(expectedSpecPath)) {
Files.createFile(expectedSpecPath) Files.createFile(expectedSpecPath)
} }
val expectedSpec = Files.readString(expectedSpecPath) val expectedSpec = Files.readString(expectedSpecPath)
val process = destinationProcessFactory.createDestinationProcess("spec") val process =
destinationProcessFactory.createDestinationProcess(
"spec",
deploymentMode = deploymentMode
)
process.run() process.run()
val messages = process.readMessages() val messages = process.readMessages()
val specMessages = messages.filter { it.type == AirbyteMessage.Type.SPEC } val specMessages = messages.filter { it.type == AirbyteMessage.Type.SPEC }
@@ -73,7 +87,7 @@ abstract class SpecTest :
val diff: JsonDiff = val diff: JsonDiff =
DiffGenerator.diff(expectedSpec, Jsons.writeValueAsString(spec), jsonMatcher) DiffGenerator.diff(expectedSpec, Jsons.writeValueAsString(spec), jsonMatcher)
assertAll( assertAll(
"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.", "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.",
{ assertEquals("", OnlyErrorDiffViewer.from(diff).toString()) }, { assertEquals("", OnlyErrorDiffViewer.from(diff).toString()) },
{ assertEquals(expectedSpec, actualSpecPrettyPrint) } { assertEquals(expectedSpec, actualSpecPrettyPrint) }
) )

View File

@@ -4,7 +4,6 @@
package io.airbyte.integrations.destination.dev_null package io.airbyte.integrations.destination.dev_null
import io.airbyte.cdk.test.spec.SpecTest
import io.airbyte.cdk.test.util.NoopDestinationCleaner import io.airbyte.cdk.test.util.NoopDestinationCleaner
import io.airbyte.cdk.test.util.NoopExpectedRecordMapper import io.airbyte.cdk.test.util.NoopExpectedRecordMapper
import io.airbyte.cdk.test.write.BasicFunctionalityIntegrationTest import io.airbyte.cdk.test.write.BasicFunctionalityIntegrationTest
@@ -29,5 +28,3 @@ class DevNullBasicFunctionalityIntegrationTest :
super.testBasicWrite() super.testBasicWrite()
} }
} }
class DevNullSpecTest : SpecTest()

View File

@@ -0,0 +1,9 @@
/*
* Copyright (c) 2024 Airbyte, Inc., all rights reserved.
*/
package io.airbyte.integrations.destination.dev_null
import io.airbyte.cdk.test.spec.SpecTest
class DevNullSpecTest : SpecTest()

View File

@@ -0,0 +1,34 @@
{
"documentationUrl" : "https://docs.airbyte.com/integrations/destinations/dev-null",
"connectionSpecification" : {
"$schema" : "http://json-schema.org/draft-07/schema#",
"title" : "E2E Test Destination Spec",
"type" : "object",
"additionalProperties" : true,
"properties" : {
"test_destination" : {
"oneOf" : [ {
"title" : "Silent",
"type" : "object",
"additionalProperties" : true,
"properties" : {
"test_destination_type" : {
"type" : "string",
"enum" : [ "SILENT" ],
"default" : "SILENT"
}
},
"required" : [ "test_destination_type" ]
} ],
"description" : "The type of destination to be used",
"title" : "Test Destination",
"type" : "object"
}
},
"required" : [ "test_destination" ]
},
"supportsIncremental" : true,
"supportsNormalization" : false,
"supportsDBT" : false,
"supported_destination_sync_modes" : [ "overwrite", "append", "append_dedup" ]
}