Bulk load cdk: Update spec test to run against cloud+oss modes (#46300)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
airbyte-integrations/bases/base-normalization/integration_tests/normalization_test_output
|
||||
airbyte-ci/connectors/pipelines/tests/test_changelog/result_files
|
||||
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
|
||||
# This is done due to prettier being overly opinionated on the formatting of quotes
|
||||
|
||||
@@ -17,6 +17,7 @@ import io.airbyte.cdk.test.util.FakeDataDumper
|
||||
import io.airbyte.cdk.test.util.IntegrationTest
|
||||
import io.airbyte.cdk.test.util.NoopDestinationCleaner
|
||||
import io.airbyte.cdk.test.util.NoopExpectedRecordMapper
|
||||
import io.airbyte.cdk.test.util.TestDeploymentMode
|
||||
import io.airbyte.cdk.util.Jsons
|
||||
import io.airbyte.protocol.models.v0.AirbyteMessage
|
||||
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.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
|
||||
* [DestinationProcessFactory].
|
||||
@@ -43,12 +41,28 @@ abstract class SpecTest :
|
||||
NoopExpectedRecordMapper,
|
||||
) {
|
||||
@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)) {
|
||||
Files.createFile(expectedSpecPath)
|
||||
}
|
||||
val expectedSpec = Files.readString(expectedSpecPath)
|
||||
val process = destinationProcessFactory.createDestinationProcess("spec")
|
||||
val process =
|
||||
destinationProcessFactory.createDestinationProcess(
|
||||
"spec",
|
||||
deploymentMode = deploymentMode
|
||||
)
|
||||
process.run()
|
||||
val messages = process.readMessages()
|
||||
val specMessages = messages.filter { it.type == AirbyteMessage.Type.SPEC }
|
||||
@@ -73,7 +87,7 @@ abstract class SpecTest :
|
||||
val diff: JsonDiff =
|
||||
DiffGenerator.diff(expectedSpec, Jsons.writeValueAsString(spec), jsonMatcher)
|
||||
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(expectedSpec, actualSpecPrettyPrint) }
|
||||
)
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
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.NoopExpectedRecordMapper
|
||||
import io.airbyte.cdk.test.write.BasicFunctionalityIntegrationTest
|
||||
@@ -29,5 +28,3 @@ class DevNullBasicFunctionalityIntegrationTest :
|
||||
super.testBasicWrite()
|
||||
}
|
||||
}
|
||||
|
||||
class DevNullSpecTest : SpecTest()
|
||||
|
||||
@@ -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()
|
||||
@@ -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" ]
|
||||
}
|
||||
Reference in New Issue
Block a user