forked from airbytehq/airbyte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test connector templates (airbytehq#2081)
- Loading branch information
1 parent
d2218b1
commit 9a2ec03
Showing
22 changed files
with
508 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
airbyte-integrations/connector-templates/source-singer/secrets/config.json.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
{ | ||
// TODO populate with needed configuration for integration tests or delete this file and any references to it | ||
// the schema of this file should match what is in your spec.json | ||
"fix-me": "TODO populate with needed configuration for integration tests or delete this file and any references to it. The schema of this file should match what is in your spec.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,15 +30,12 @@ setup( | |
author="Airbyte", | ||
author_email="[email protected]", | ||
packages=find_packages(), | ||
install_requires=["airbyte-protocol"], | ||
install_requires=["{{ tap_name }}", "airbyte-protocol", "base-singer", "base-python"], | ||
package_data={"": ["*.json"]}, | ||
setup_requires=["pytest-runner"], | ||
tests_require=["pytest"], | ||
extras_require={ | ||
# Dependencies required by the main package but not tests should go in main. Deps required by | ||
# integration tests but not the main package go in tests. Deps required by both should go in | ||
# install_requires. | ||
"main": ["base-singer", "base-python"], | ||
"main": [], | ||
"tests": ["airbyte-python-test", "pytest"], | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
airbyte-integrations/connectors/source-scaffold-source-python/.dockerignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
* | ||
!Dockerfile | ||
!Dockerfile.test | ||
!source_scaffold_source_python | ||
!setup.py | ||
!secrets |
1 change: 1 addition & 0 deletions
1
airbyte-integrations/connectors/source-scaffold-source-python/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
NEW_SOURCE_CHECKLIST.md |
16 changes: 16 additions & 0 deletions
16
airbyte-integrations/connectors/source-scaffold-source-python/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM airbyte/integration-base-python:dev | ||
|
||
# Bash is installed for more convenient debugging. | ||
RUN apt-get update && apt-get install -y bash && rm -rf /var/lib/apt/lists/* | ||
|
||
ENV CODE_PATH="source_scaffold_source_python" | ||
ENV AIRBYTE_IMPL_MODULE="source_scaffold_source_python" | ||
ENV AIRBYTE_IMPL_PATH="SourceScaffoldSourcePython" | ||
|
||
WORKDIR /airbyte/integration_code | ||
COPY $CODE_PATH ./$CODE_PATH | ||
COPY setup.py ./ | ||
RUN pip install ".[main]" | ||
|
||
LABEL io.airbyte.version=0.1.0 | ||
LABEL io.airbyte.name=airbyte/source-scaffold-source-python |
64 changes: 64 additions & 0 deletions
64
airbyte-integrations/connectors/source-scaffold-source-python/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Scaffold Source Python Source | ||
|
||
This is the repository for the Scaffold Source Python source connector, written in Python. | ||
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.io/integrations/sources/scaffold-source-python). | ||
|
||
## Local development | ||
|
||
### Prerequisites | ||
**To iterate on this connector, make sure to complete this prerequisites section.** | ||
|
||
#### Build & Activate Virtual Environment | ||
First, build the module by running the following from the `airbyte` project root directory: | ||
``` | ||
./gradlew :airbyte-integrations:connectors:source-scaffold-source-python:build | ||
``` | ||
|
||
This will generate a virtualenv for this module in `source-scaffold-source-python/.venv`. Make sure this venv is active in your | ||
development environment of choice. To activate the venv from the terminal, run: | ||
``` | ||
cd airbyte-integrations/connectors/source-scaffold-source-python # cd into the connector directory | ||
source .venv/bin/activate | ||
``` | ||
If you are in an IDE, follow your IDE's instructions to activate the virtualenv. | ||
|
||
#### Create credentials | ||
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/sources/scaffold-source-python) | ||
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_scaffold_source_python/spec.json` file. | ||
See `sample_files/sample_config.json` for a sample config file. | ||
|
||
**If you are an Airbyte core member**, copy the credentials in RPass under the secret name `source-scaffold-source-python-integration-test-config` | ||
and place them into `secrets/config.json`. | ||
|
||
|
||
### Locally running the connector | ||
``` | ||
python main_dev.py spec | ||
python main_dev.py check --config secrets/config.json | ||
python main_dev.py discover --config secrets/config.json | ||
python main_dev.py read --config secrets/config.json --catalog sample_files/configured_catalog.json | ||
``` | ||
|
||
### Unit Tests | ||
To run unit tests locally, from the connector directory run: | ||
``` | ||
pytest unit_tests | ||
``` | ||
|
||
### Locally running the connector docker image | ||
``` | ||
# in airbyte root directory | ||
./gradlew :airbyte-integrations:connectors:source-scaffold-source-python:airbyteDocker | ||
docker run --rm airbyte/source-scaffold-source-python:dev spec | ||
docker run --rm -v $(pwd)/airbyte-integrations/connectors/source-scaffold-source-python/secrets:/secrets airbyte/source-scaffold-source-python:dev check --config /secrets/config.json | ||
docker run --rm -v $(pwd)/airbyte-integrations/connectors/source-scaffold-source-python/secrets:/secrets airbyte/source-scaffold-source-python:dev discover --config /secrets/config.json | ||
docker run --rm -v $(pwd)/airbyte-integrations/connectors/source-scaffold-source-python/secrets:/secrets -v $(pwd)/airbyte-integrations/connectors/source-scaffold-source-python/sample_files:/sample_files airbyte/source-scaffold-source-python:dev read --config /secrets/config.json --catalog /sample_files/configured_catalog.json | ||
``` | ||
|
||
### Integration Tests | ||
1. From the airbyte project root, run `./gradlew :airbyte-integrations:connectors:source-scaffold-source-python:standardSourceTestPython` to run the standard integration test suite. | ||
1. To run additional integration tests, place your integration tests in a new directory `integration_tests` and run them with `pytest integration_tests`. | ||
Make sure to familiarize yourself with [pytest test discovery](https://docs.pytest.org/en/latest/goodpractices.html#test-discovery) to know how your test files and methods should be named. | ||
|
||
## Dependency Management | ||
All of your dependencies should go in `setup.py`, NOT `requirements.txt`. The requirements file is only used to connect internal Airbyte dependencies in the monorepo for local development. |
32 changes: 32 additions & 0 deletions
32
airbyte-integrations/connectors/source-scaffold-source-python/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
plugins { | ||
id 'airbyte-python' | ||
id 'airbyte-docker' | ||
id 'airbyte-standard-source-test-file' | ||
} | ||
|
||
airbytePython { | ||
moduleDirectory 'source_scaffold_source_python' | ||
} | ||
|
||
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_scaffold_source_python/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) | ||
} |
32 changes: 32 additions & 0 deletions
32
airbyte-integrations/connectors/source-scaffold-source-python/main_dev.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
""" | ||
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. | ||
""" | ||
|
||
import sys | ||
|
||
from base_python.entrypoint import launch | ||
from source_scaffold_source_python import SourceScaffoldSourcePython | ||
|
||
if __name__ == "__main__": | ||
source = SourceScaffoldSourcePython() | ||
launch(source, sys.argv[1:]) |
4 changes: 4 additions & 0 deletions
4
airbyte-integrations/connectors/source-scaffold-source-python/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-e ../../bases/airbyte-protocol | ||
-e ../../bases/base-python | ||
-e ../../bases/base-python-test | ||
-e . |
39 changes: 39 additions & 0 deletions
39
airbyte-integrations/connectors/source-scaffold-source-python/sample_files/catalog.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"streams": [ | ||
{ | ||
"name": "TODO fix this file", | ||
"supported_sync_modes": ["full_refresh", "incremental"], | ||
"source_defined_cursor": true, | ||
"default_cursor_field": "column1", | ||
"json_schema": { | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"properties": { | ||
"column1": { | ||
"type": "string" | ||
}, | ||
"column2": { | ||
"type": "number" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"name": "table1", | ||
"supported_sync_modes": ["full_refresh", "incremental"], | ||
"source_defined_cursor": false, | ||
"json_schema": { | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
"properties": { | ||
"column1": { | ||
"type": "string" | ||
}, | ||
"column2": { | ||
"type": "number" | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} |
21 changes: 21 additions & 0 deletions
21
...ntegrations/connectors/source-scaffold-source-python/sample_files/configured_catalog.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"streams": [ | ||
{ | ||
"stream": { | ||
"name": "table_name", | ||
"json_schema": { | ||
"properties": { | ||
"column_name": { | ||
"type": "string" | ||
} | ||
}, | ||
"type": "object", | ||
"additionalProperties": false | ||
}, | ||
"supported_sync_modes": ["full_refresh"], | ||
"source_defined_cursor": false, | ||
"default_cursor_field": ["column_name"] | ||
} | ||
} | ||
] | ||
} |
Oops, something went wrong.