Skip to content

Commit

Permalink
standard source tests (#686)
Browse files Browse the repository at this point in the history
  • Loading branch information
cgardens authored Oct 23, 2020
1 parent 300556c commit 4d1a788
Show file tree
Hide file tree
Showing 19 changed files with 774 additions and 3 deletions.
4 changes: 4 additions & 0 deletions airbyte-integrations/bases/standard-source-test/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*
!Dockerfile
!build
!entrypoint.sh
30 changes: 30 additions & 0 deletions airbyte-integrations/bases/standard-source-test/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM openjdk:14.0.2-slim

# Install Docker to launch worker images. Eventually should be replaced with Docker-java.
# See https://gitter.im/docker-java/docker-java?at=5f3eb87ba8c1780176603f4e for more information on why we are not currently using Docker-java
RUN apt-get update && apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
RUN add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
stable"
RUN apt-get update && apt-get install -y docker-ce-cli jq

ENV APPLICATION standard-source-test

WORKDIR /app

COPY entrypoint.sh .
COPY build/distributions/${APPLICATION}*.tar ${APPLICATION}.tar

RUN tar xf ${APPLICATION}.tar --strip-components=1

ENTRYPOINT ["/app/entrypoint.sh"]

LABEL io.airbyte.version=0.1.0
LABEL io.airbyte.name=airbyte/standard-source-test
23 changes: 23 additions & 0 deletions airbyte-integrations/bases/standard-source-test/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
plugins {
id 'application'
}

apply from: rootProject.file('tools/gradle/commons/integrations/image.gradle')

dependencies {
implementation project(':airbyte-config:models')
implementation project(':airbyte-protocol:models')
implementation project(':airbyte-workers')

// todo (cgardens) - Using JUnit4 instead of five. See TestMain.java for more details.
implementation group: 'junit', name: 'junit', version: '4.12'


implementation 'net.sourceforge.argparse4j:argparse4j:0.8.1'
}

application {
mainClass = 'io.airbyte.integrations.base.TestSourceMain'
}

buildImage.dependsOn(assemble)
5 changes: 5 additions & 0 deletions airbyte-integrations/bases/standard-source-test/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

set -e

/app/bin/${APPLICATION} "$@"
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* MIT License
*
* Copyright (c) 2020 Airbyte
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package io.airbyte.integrations.base;

import com.fasterxml.jackson.databind.JsonNode;
import io.airbyte.commons.io.IOs;
import io.airbyte.commons.json.Jsons;
import io.airbyte.protocol.models.AirbyteCatalog;
import io.airbyte.protocol.models.ConnectorSpecification;
import java.nio.file.Path;

/**
* Extends TestSource such that it can be called using resources pulled from the file system. Will
* also add the ability to execute arbitrary scripts in the next version.
*/
public class ExecutableTestSource extends TestSource {

public static class TestConfig {

private final String imageName;
private final Path specPath;
private final Path configPath;
private final Path catalogPath;

public TestConfig(String imageName, Path specPath, Path configPath, Path catalogPath) {
this.imageName = imageName;
this.specPath = specPath;
this.configPath = configPath;
this.catalogPath = catalogPath;
}

public String getImageName() {
return imageName;
}

public Path getSpecPath() {
return specPath;
}

public Path getConfigPath() {
return configPath;
}

public Path getCatalogPath() {
return catalogPath;
}

}

public static TestConfig TEST_CONFIG;

@Override
protected ConnectorSpecification getSpec() {
return Jsons.deserialize(IOs.readFile(TEST_CONFIG.getSpecPath()), ConnectorSpecification.class);
}

@Override
protected String getImageName() {
return TEST_CONFIG.getImageName();
}

@Override
protected JsonNode getConfig() {
return Jsons.deserialize(IOs.readFile(TEST_CONFIG.getConfigPath()));
}

@Override
protected AirbyteCatalog getCatalog() {
return Jsons.deserialize(IOs.readFile(TEST_CONFIG.getCatalogPath()), AirbyteCatalog.class);
}

@Override
protected void setup(TestDestinationEnv testEnv) throws Exception {
// no-op, for now
}

@Override
protected void tearDown(TestDestinationEnv testEnv) throws Exception {
// no-op, for now
}

}
Loading

0 comments on commit 4d1a788

Please sign in to comment.