Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Source Zendesk Talk: migrate to CDK #7173

Merged
merged 23 commits into from
Nov 13, 2021
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"sourceDefinitionId": "c8630570-086d-4a40-99ae-ea5b18673071",
"name": "Zendesk Talk",
"dockerRepository": "airbyte/source-zendesk-talk",
"dockerImageTag": "0.1.2",
"dockerImageTag": "0.1.3",
"documentationUrl": "https://docs.airbyte.io/integrations/sources/zendesk-talk"
}
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@
- name: Zendesk Talk
sourceDefinitionId: c8630570-086d-4a40-99ae-ea5b18673071
dockerRepository: airbyte/source-zendesk-talk
dockerImageTag: 0.1.2
dockerImageTag: 0.1.3
documentationUrl: https://docs.airbyte.io/integrations/sources/zendesk-talk
sourceType: api
- sourceDefinitionId: cdaf146a-9b75-49fd-9dd2-9d64a0bb4781
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
*
!Dockerfile
!Dockerfile.test
!main.py
!source_zendesk_talk
!setup.py
!secrets
14 changes: 6 additions & 8 deletions airbyte-integrations/connectors/source-zendesk-talk/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
FROM airbyte/integration-base-python:0.1.1
FROM python:3.7-slim

# 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_zendesk_talk"
ENV AIRBYTE_IMPL_MODULE="source_zendesk_talk"
ENV AIRBYTE_IMPL_PATH="SourceZendeskTalk"

WORKDIR /airbyte/integration_code
COPY $CODE_PATH ./$CODE_PATH
COPY source_zendesk_talk ./source_zendesk_talk
COPY main.py ./
COPY setup.py ./
RUN pip install .

ENV AIRBYTE_ENTRYPOINT "/airbyte/base.sh"
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.1.2
LABEL io.airbyte.version=0.1.3
LABEL io.airbyte.name=airbyte/source-zendesk-talk
63 changes: 46 additions & 17 deletions airbyte-integrations/connectors/source-zendesk-talk/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Zendesk Talk Source
# Zendesk Talk Source

This is the repository for the Zendesk Talk source connector, written in Python.
This is the repository for the Zendesk Talk source connector, written in Python.
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.io/integrations/sources/zendesk-talk).

## Local development
Expand Down Expand Up @@ -44,19 +44,12 @@ See `sample_files/sample_config.json` for a sample config file.
**If you are an Airbyte core member**, copy the credentials in Lastpass under the secret name `source zendesk-talk test creds`
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:
```
python -m pytest unit_tests
python main.py spec
python main.py check --config secrets/config.json
python main.py discover --config secrets/config.json
python main.py read --config secrets/config.json --catalog sample_files/configured_catalog.json
```

### Locally running the connector docker image
Expand All @@ -82,19 +75,55 @@ docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-zendesk-talk:dev check
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-zendesk-talk:dev discover --config /secrets/config.json
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/sample_files:/sample_files airbyte/source-zendesk-talk:dev read --config /secrets/config.json --catalog /sample_files/configured_catalog.json
```
## Testing
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.
First install test dependencies into your virtual environment:
```
pip install .[tests]
```
### Unit Tests
To run unit tests locally, from the connector directory run:
```
python -m pytest unit_tests
```

### Integration Tests
1. From the airbyte project root, run `./gradlew :airbyte-integrations:connectors:source-zendesk-talk:integrationTest` 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 `python -m pytest -s 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.
There are two types of integration tests: Acceptance Tests (Airbyte's test suite for all source connectors) and custom integration tests (which are specific to this connector).
#### Custom Integration tests
Place custom tests inside `integration_tests/` folder, then, from the connector root, run
```
python -m pytest integration_tests
```
#### Acceptance Tests
Customize `acceptance-test-config.yml` file to configure tests. See [Source Acceptance Tests](https://docs.airbyte.io/connector-development/testing-connectors/source-acceptance-tests-reference) for more information.
If your connector requires to create or destroy resources for use during acceptance tests create fixtures for it and place them inside integration_tests/acceptance.py.
To run your integration tests with acceptance tests, from the connector root, run
```
python -m pytest integration_tests -p integration_tests.acceptance
```
To run your integration tests with docker

### Using gradle to run tests
All commands should be run from airbyte project root.
To run unittest run:
```
./gradlew :airbyte-integrations:connectors:source-zendesk-talk:unitTest
```
To run acceptance and custom integration tests run:
```
./gradlew :airbyte-integrations:connectors:source-zendesk-talk:IntegrationTest
```

## 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.
We split dependencies between two groups, dependencies that are:
* required for your connector to work need to go to `MAIN_REQUIREMENTS` list.
* required for the testing need to go to `TEST_REQUIREMENTS` list

### Publishing a new version of the connector
You've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what?
1. Make sure your changes are passing unit and integration tests
1. Bump the connector version in `Dockerfile` -- just increment the value of the `LABEL io.airbyte.version` appropriately (we use SemVer).
1. Bump the connector version in `Dockerfile` -- just increment the value of the `LABEL io.airbyte.version` appropriately (we use [SemVer](https://semver.org/)).
1. Create a Pull Request
1. Pat yourself on the back for being an awesome contributor
1. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# See [Source Acceptance Tests](https://docs.airbyte.io/connector-development/testing-connectors/source-acceptance-tests-reference)
# for more information about how to configure these tests
# intentionally left out explicit configured_catalog.json to test all streams from discovery
connector_image: airbyte/source-zendesk-talk:dev
tests:
spec:
- spec_path: "integration_tests/spec.json"
connection:
- config_path: "secrets/config.json"
status: "succeed"
- config_path: "integration_tests/invalid_config.json"
status: "failed"
discovery:
- config_path: "secrets/config.json"
basic_read:
- config_path: "secrets/config.json"
incremental:
- config_path: "secrets/config.json"
future_state_path: "integration_tests/abnormal_state.json"
full_refresh:
- config_path: "secrets/config.json"
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env sh

# Build latest connector image
docker build . -t $(cat acceptance-test-config.yml | grep "connector_image" | head -n 1 | cut -d: -f2)

# Pull latest acctest image
docker pull airbyte/source-acceptance-test:latest

# Run
docker run --rm -it \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp:/tmp \
-v $(pwd):/test_input \
airbyte/source-acceptance-test \
--acceptance-test-config /test_input

Original file line number Diff line number Diff line change
@@ -1,27 +1,13 @@
plugins {
id 'airbyte-python'
id 'airbyte-docker'
id 'airbyte-standard-source-test-file'
id 'airbyte-source-acceptance-test'
}

airbytePython {
moduleDirectory 'source_zendesk_talk'
}

airbyteStandardSourceTestFile {
specPath = "source_zendesk_talk/spec.json"
configPath = "secrets/config.json"
configuredCatalogPath = "sample_files/configured_catalog.json"
}

task("pythonIntegrationTests", type: PythonTask, dependsOn: installTestReqs) {
module = "pytest"
command = "-s integration_tests"
}

integrationTest.dependsOn("pythonIntegrationTests")

dependencies {
implementation files(project(':airbyte-integrations:bases:base-standard-source-test-file').airbyteDocker.outputs)
implementation files(project(':airbyte-integrations:bases:base-python').airbyteDocker.outputs)
implementation files(project(':airbyte-integrations:bases:source-acceptance-test').airbyteDocker.outputs)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#
# Copyright (c) 2021 Airbyte, Inc., all rights reserved.
#
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"calls": {
"updated_at": "2121-01-01T00:00:00Z"
},
"call_legs": {
"updated_at": "2121-01-01T00:00:00Z"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# Copyright (c) 2021 Airbyte, Inc., all rights reserved.
#


import pytest

pytest_plugins = ("source_acceptance_test.plugin",)


@pytest.fixture(scope="session", autouse=True)
def connector_setup():
"""This fixture is a placeholder for external resources that acceptance test might require."""
yield

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"email": "integration-test@airbyte.io",
"access_token": "some_token",
"subdomain": "domain",
"start_date": "2021-04-01T00:00:00Z"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"documentationUrl": "https://docs.airbyte.io/integrations/sources/zendesk-talk",
"changelogUrl": "https://docs.airbyte.io/integrations/sources/zendesk-talk",
"connectionSpecification": {
"title": "Zendesk Talk Spec",
"type": "object",
"properties": {
"subdomain": {
"title": "Subdomain",
"description": "The subdomain for your Zendesk Talk.",
"type": "string"
},
"access_token": {
"title": "Access Token",
"description": "The value of the API token generated. See the <a href=\"https://docs.airbyte.io/integrations/sources/zendesk-talk\">docs</a> for more information.",
"airbyte_secret": true,
"type": "string"
},
"email": {
"title": "Email",
"description": "The user email for your Zendesk account.",
"type": "string"
},
"start_date": {
"title": "Replication Start Date",
"description": "The date from which you'd like to replicate data for Zendesk Talk API, in the format YYYY-MM-DDT00:00:00Z.",
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$",
"examples": ["2017-01-25T00:00:00Z"],
"type": "string",
"format": "date-time"
}
},
"required": ["subdomain", "access_token", "email", "start_date"]
},
"supportsIncremental": true,
"supportsNormalization": false,
"supportsDBT": false,
"supported_destination_sync_modes": ["append"],
"authSpecification": null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can probably omit this for now if it is null

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is how it is stored in ConnectorSpecification, don't think this has any effect on behavior since this file is just for SAT

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import sys

from base_python.entrypoint import launch
from airbyte_cdk.entrypoint import launch
from source_zendesk_talk import SourceZendeskTalk

if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# This file is autogenerated -- only edit if you know what you are doing. Use setup.py for declaring dependencies.
-e ../../bases/airbyte-protocol
-e ../../bases/base-python
-e ../../bases/source-acceptance-test
-e .
Loading