From eae41d87a27419012a3d816149613cd0e4157282 Mon Sep 17 00:00:00 2001 From: Eugene Kulak Date: Sun, 18 Apr 2021 20:55:28 +0300 Subject: [PATCH] add gradle command --- .../bases/standard-test/build.gradle | 2 +- .../connectors/source-hubspot/build.gradle | 20 +-------- .../main/groovy/airbyte-standard-test.gradle | 44 +++++++++++++++++++ settings.gradle | 1 + 4 files changed, 47 insertions(+), 20 deletions(-) create mode 100644 buildSrc/src/main/groovy/airbyte-standard-test.gradle diff --git a/airbyte-integrations/bases/standard-test/build.gradle b/airbyte-integrations/bases/standard-test/build.gradle index b8349aab61aa..f524631b291c 100644 --- a/airbyte-integrations/bases/standard-test/build.gradle +++ b/airbyte-integrations/bases/standard-test/build.gradle @@ -4,7 +4,7 @@ plugins { } airbytePython { - moduleDirectory 'base_python_test' + moduleDirectory 'standard_test' } diff --git a/airbyte-integrations/connectors/source-hubspot/build.gradle b/airbyte-integrations/connectors/source-hubspot/build.gradle index 5e625a30dc66..0bbc709e3e9c 100644 --- a/airbyte-integrations/connectors/source-hubspot/build.gradle +++ b/airbyte-integrations/connectors/source-hubspot/build.gradle @@ -1,32 +1,14 @@ plugins { id 'airbyte-python' id 'airbyte-docker' - id 'airbyte-standard-source-test-file' + id 'airbyte-standard-test' } airbytePython { moduleDirectory 'source_hubspot' } -airbyteStandardSourceTestFile { - // For more information on standard source tests, see https://docs.airbyte.io/contributing-to-airbyte/building-new-connector/testing-connectors - - // All these input paths must live inside this connector's directory (or subdirectories) - // TODO update the spec JSON file - specPath = "source_hubspot/spec.json" - - // configPath points to a config file which matches the spec.json supplied above. secrets/ is gitignored by default, so place your config file - // there (in case it contains any credentials) - // TODO update the config file to contain actual credentials - configPath = "secrets/config.json" - // TODO update the sample configured_catalog JSON for use in testing - // Note: If your source supports incremental syncing, then make sure that the catalog that is returned in the get_catalog method is configured - // for incremental syncing (e.g. include cursor fields, etc). - configuredCatalogPath = "sample_files/configured_catalog.json" -} - dependencies { - implementation files(project(':airbyte-integrations:bases:base-standard-source-test-file').airbyteDocker.outputs) implementation files(project(':airbyte-integrations:bases:base-python').airbyteDocker.outputs) } diff --git a/buildSrc/src/main/groovy/airbyte-standard-test.gradle b/buildSrc/src/main/groovy/airbyte-standard-test.gradle new file mode 100644 index 000000000000..cd9557ea492f --- /dev/null +++ b/buildSrc/src/main/groovy/airbyte-standard-test.gradle @@ -0,0 +1,44 @@ +import org.gradle.api.Plugin +import org.gradle.api.Project + +class AirbyteStandardTestPlugin implements Plugin { + void apply(Project project) { + project.task('standardTest') { + doFirst { + project.exec { + def targetMountDirectory = "/test_input" + def args = [ + 'docker', 'run', '--rm', '-i', + // provide access to the docker daemon + '-v', "/var/run/docker.sock:/var/run/docker.sock", + // A container within a container mounts from the host filesystem, not the parent container. + // this forces /tmp to be the same directory for host, parent container, and child container. + '-v', "/tmp:/tmp", + // mount the project dir. all provided input paths must be relative to that dir. + '-v', "${project.projectDir.absolutePath}:${targetMountDirectory}", + 'airbyte/standard-test:dev', + '--standard_test_config', "$targetMountDirectory", + ] + commandLine args + } + } + + outputs.upToDateWhen { false } + } + + project.standardTest.dependsOn(':airbyte-integrations:bases:standard-test:airbyteDocker') + project.standardTest.dependsOn(project.build) + project.standardTest.dependsOn(project.airbyteDocker) + if (project.hasProperty('airbyteDockerTest')){ + project.standardTest.dependsOn(project.airbyteDockerTest) + } + + // make sure we create the integrationTest task once in case a java integration test was already initialized + if (!project.hasProperty('integrationTest')) { + project.task('integrationTest') + } + + project.integrationTest.dependsOn(project.standardTest) + } +} + diff --git a/settings.gradle b/settings.gradle index 9cf125f95aa1..f4f69d5ce5e7 100644 --- a/settings.gradle +++ b/settings.gradle @@ -32,6 +32,7 @@ include ':airbyte-integrations:bases:base-singer' include ':airbyte-integrations:bases:base-standard-source-test-file' include ':airbyte-integrations:bases:standard-destination-test' include ':airbyte-integrations:bases:standard-source-test' +include ':airbyte-integrations:bases:standard-test' include ':airbyte-integrations:connector-templates:generator' include ':airbyte-json-validation' include ':airbyte-migration'