Skip to content

Commit

Permalink
Rename source acceptance test to connector acceptance test (#21846)
Browse files Browse the repository at this point in the history
Rename source acceptance test to connector acceptance test
  • Loading branch information
Joe Reuter authored Feb 2, 2023
1 parent bb12599 commit 6a10ae3
Show file tree
Hide file tree
Showing 1,849 changed files with 2,660 additions and 2,676 deletions.
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CDK and SAT
# CDK and Connector Acceptance Tests
/airbyte-cdk/ @airbytehq/connector-extensibility
/airbyte-integrations/bases/source-acceptance-tests/ @airbytehq/connector-extensibility
/airbyte-integrations/bases/connector-acceptance-tests/ @airbytehq/connector-extensibility
/airbyte-integrations/connector-templates/ @airbytehq/connector-extensibility

# Oauth
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/connector_integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
python -m pip install --upgrade pip
pip install PyYAML requests
- name: Launch Integration Tests
run: python ./tools/bin/ci_integration_workflow_launcher.py base-normalization source-acceptance-test source:beta source:GA destination:beta destination:GA
run: python ./tools/bin/ci_integration_workflow_launcher.py base-normalization connector-acceptance-test source:beta source:GA destination:beta destination:GA
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT_MAINTENANCE_OSS }}
launch_integration_tests_alpha_only:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def split_config(config: Mapping[str, Any]) -> Tuple[dict, InternalConfig]:
config - Dict object that has been loaded from config file.
:return tuple of user defined config dict with filtered out internal
parameters and SAT internal config object.
parameters and connector acceptance test internal config object.
"""
main_config = {}
internal_config = {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*
!Dockerfile
!source_acceptance_test
!connector_acceptance_test
!setup.py
!pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## 0.5.0
Re-release of 0.3.0 [#21451](https://github.com/airbytehq/airbyte/pull/21451)

# Renamed image from `airbyte/source-acceptance-test` to `airbyte/connector-acceptance-test` - Older versions are only available under the old name

## 0.4.0
Revert 0.3.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ RUN pip install --prefix=/install -r *.egg-info/requires.txt

# build a clean environment
FROM base
WORKDIR /airbyte/source_acceptance_test
WORKDIR /airbyte/connector_acceptance_test

# copy all loaded and built libraries to a pure basic image
COPY --from=builder /install /usr/local
Expand All @@ -30,10 +30,10 @@ ENV ACCEPTANCE_TEST_DOCKER_CONTAINER 1

# copy payload code only
COPY pytest.ini setup.py ./
COPY source_acceptance_test ./source_acceptance_test
COPY connector_acceptance_test ./connector_acceptance_test
RUN pip install .

LABEL io.airbyte.version=0.5.0
LABEL io.airbyte.name=airbyte/source-acceptance-test
LABEL io.airbyte.name=airbyte/connector-acceptance-test

ENTRYPOINT ["python", "-m", "pytest", "-p", "source_acceptance_test.plugin", "-r", "fEsx"]
ENTRYPOINT ["python", "-m", "pytest", "-p", "connector_acceptance_test.plugin", "-r", "fEsx"]
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Source Acceptance Tests
This package gathers multiple test suites to assess the sanity of any Airbyte **source** connector.
# Connector Acceptance Tests
This package gathers multiple test suites to assess the sanity of any Airbyte connector.
It is shipped as a [pytest](https://docs.pytest.org/en/7.1.x/) plugin and relies on pytest to discover, configure and execute tests.
Test-specific documentation can be found [here](https://docs.airbyte.com/connector-development/testing-connectors/source-acceptance-tests-reference/)).
Test-specific documentation can be found [here](https://docs.airbyte.com/connector-development/testing-connectors/connector-acceptance-tests-reference/)).

## Running the acceptance tests on a source connector:
1. `cd` into your connector project (e.g. `airbyte-integrations/connectors/source-pokeapi`)
2. Edit `acceptance-test-config.yml` according to your need. Please refer to our [Source Acceptance Test Reference](https://docs.airbyte.com/connector-development/testing-connectors/source-acceptance-tests-reference/) if you need details about the available options.
1. `cd` into your connector project (e.g. `airbyte-integrations/connectors/source-pokeapi`)
2. Edit `acceptance-test-config.yml` according to your need. Please refer to our [Connector Acceptance Test Reference](https://docs.airbyte.com/connector-development/testing-connectors/connector-acceptance-tests-reference/) if you need details about the available options.
3. Build the connector docker image ( e.g.: `docker build . -t airbyte/source-pokeapi:dev`)
4. Use one of the following ways to run tests (**from your connector project directory**)

Expand All @@ -17,45 +17,45 @@ _Note: this will assume that docker image for connector is already built_

**Using Gradle**
```bash
./gradlew :airbyte-integrations:connectors:source-<name>:sourceAcceptanceTest
./gradlew :airbyte-integrations:connectors:source-<name>:connectorAcceptanceTest
```
_Note: this way will also build docker image for the connector_

**Using Bash**
```bash
./acceptance-test-docker.sh
```
_Note: this will use the latest docker image for source-acceptance-test and will also build docker image for the connector_
_Note: this will use the latest docker image for connector-acceptance-test and will also build docker image for the connector_

## When does SAT run?
## When does acceptance test run?
* When running local acceptance tests on connector:
* When running `sourceAcceptanceTest` `gradle` task
* When running `connectorAcceptanceTest` `gradle` task
* When running or `./acceptance-test-docker.sh` in a connector project
* When running `/test` command on a GitHub pull request.
* When running `/publish` command on a GitHub pull request.
* When running ` integration-test` GitHub action that is creating the JSON files linked to from [connector builds summary](https://github.com/airbytehq/airbyte/blob/master/airbyte-integrations/builds.md).

## Developing on the SAT
You may want to iterate on the SAT project: adding new tests, fixing a bug etc.
## Developing on the acceptance tests
You may want to iterate on the acceptance test project itself: adding new tests, fixing a bug etc.
These iterations are more conveniently achieved by remaining in the current directory.

1. Create a `virtualenv`: `python -m venv .venv`
2. Activate the `virtualenv`: `source ./.venv/bin/activate`
3. Install requirements: `pip install -e .`
4. Run the unit tests on SAT: `python -m pytest unit_tests` (add the `--pdb` option if you want to enable the debugger on test failure)
4. Run the unit tests on the acceptance tests themselves: `python -m pytest unit_tests` (add the `--pdb` option if you want to enable the debugger on test failure)
5. Make the changes you want:
* Global pytest fixtures are defined in `./source_acceptance_test/conftest.py`
* Existing test modules are defined in `./source_acceptance_test/tests`
* `acceptance-test-config.yaml` structure is defined in `./source_acceptance_test/config.py`
* Global pytest fixtures are defined in `./connector_acceptance_test/conftest.py`
* Existing test modules are defined in `./connector_acceptance_test/tests`
* `acceptance-test-config.yaml` structure is defined in `./connector_acceptance_test/config.py`
6. Unit test your changes by adding tests to `./unit_tests`
7. Run the unit tests on SAT again: `python -m pytest unit_tests`, make sure the coverage did not decrease. You can bypass slow tests by using the `slow` marker: `python -m pytest unit_tests -m "not slow"`.
8. Manually test the changes you made by running SAT on a specific connector. e.g. `python -m pytest -p source_acceptance_test.plugin --acceptance-test-config=../../connectors/source-pokeapi`
9. Make sure you updated `docs/connector-development/testing-connectors/source-acceptance-tests-reference.md` according to your changes
10. Bump the SAT version in `airbyte-integrations/bases/source-acceptance-test/Dockerfile`
11. Update the project changelog `airbyte-integrations/bases/source-acceptance-test/CHANGELOG.md`
7. Run the unit tests on the acceptance tests again: `python -m pytest unit_tests`, make sure the coverage did not decrease. You can bypass slow tests by using the `slow` marker: `python -m pytest unit_tests -m "not slow"`.
8. Manually test the changes you made by running acceptance tests on a specific connector. e.g. `python -m pytest -p connector_acceptance_test.plugin --acceptance-test-config=../../connectors/source-pokeapi`
9. Make sure you updated `docs/connector-development/testing-connectors/connector-acceptance-tests-reference.md` according to your changes
10. Bump the acceptance test docker image version in `airbyte-integrations/bases/connector-acceptance-test/Dockerfile`
11. Update the project changelog `airbyte-integrations/bases/connector-acceptance-test/CHANGELOG.md`
12. Open a PR on our GitHub repository
13. Run the unit test on the CI by running `/test connector=bases/source-acceptance-test` in a GitHub comment
14. Publish the new SAT version if your PR is approved by running `/publish connector=bases/source-acceptance-test auto-bump-version=false` in a GitHub comment
13. Run the unit test on the CI by running `/test connector=bases/connector-acceptance-test` in a GitHub comment
14. Publish the new acceptance test version if your PR is approved by running `/publish connector=bases/connector-acceptance-test auto-bump-version=false` in a GitHub comment
15. Merge your PR

## Migrating `acceptance-test-config.yml` to latest configuration format
Expand All @@ -66,5 +66,5 @@ To migrate a legacy configuration to the latest configuration format please run:
```bash
python -m venv .venv # If you don't have a virtualenv already
source ./.venv/bin/activate # If you're not in your virtualenv already
python source_acceptance_test/tools/strictness_level_migration/config_migration.py ../../connectors/source-to-migrate/acceptance-test-config.yml
python connector_acceptance_test/tools/strictness_level_migration/config_migration.py ../../connectors/source-to-migrate/acceptance-test-config.yml
```
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ plugins {
}

airbytePython {
moduleDirectory 'source_acceptance_test'
moduleDirectory 'connector_acceptance_test'
}

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

import inflection
import pytest
from source_acceptance_test.config import Config
from connector_acceptance_test.config import Config


@pytest.mark.usefixtures("inputs")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@

import pytest
from airbyte_cdk.models import AirbyteRecordMessage, AirbyteStream, ConfiguredAirbyteCatalog, ConnectorSpecification, Type
from docker import errors
from source_acceptance_test.base import BaseTest
from source_acceptance_test.config import Config, EmptyStreamConfiguration, ExpectedRecordsConfig
from source_acceptance_test.tests import TestBasicRead
from source_acceptance_test.utils import (
from connector_acceptance_test.base import BaseTest
from connector_acceptance_test.config import Config, EmptyStreamConfiguration, ExpectedRecordsConfig
from connector_acceptance_test.tests import TestBasicRead
from connector_acceptance_test.utils import (
ConnectorRunner,
SecretDict,
build_configured_catalog_from_custom_catalog,
Expand All @@ -28,6 +27,7 @@
load_config,
load_yaml_or_json_path,
)
from docker import errors


@pytest.fixture(name="acceptance_test_config", scope="session")
Expand Down Expand Up @@ -348,7 +348,7 @@ def pytest_sessionfinish(session, exitstatus):
print() # create a line break
logger.info(
# session.startdir gives local path to the connector folder, so we can verify which cnctr was tested
f"{session.startdir} - SAT run - "
f"{session.startdir} - Connector Acceptance Test run - "
# using subprocess.check_output to run cmd to get git hash
f"{check_output('git rev-parse HEAD', stderr=STDOUT, shell=True).decode('ascii').strip()}"
f" - {result}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import pytest
from _pytest.config import Config
from _pytest.config.argparsing import Parser
from source_acceptance_test.base import BaseTest
from source_acceptance_test.config import Config as AcceptanceTestConfig
from source_acceptance_test.config import GenericTestConfig
from source_acceptance_test.utils import diff_dicts, load_config
from connector_acceptance_test.base import BaseTest
from connector_acceptance_test.config import Config as AcceptanceTestConfig
from connector_acceptance_test.config import GenericTestConfig
from connector_acceptance_test.utils import diff_dicts, load_config

HERE = Path(__file__).parent.absolute()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@
TraceType,
Type,
)
from docker.errors import ContainerError
from jsonschema._utils import flatten
from source_acceptance_test.base import BaseTest
from source_acceptance_test.config import (
from connector_acceptance_test.base import BaseTest
from connector_acceptance_test.config import (
BasicReadTestConfig,
Config,
ConnectionTestConfig,
Expand All @@ -37,15 +35,17 @@
ExpectedRecordsConfig,
SpecTestConfig,
)
from source_acceptance_test.utils import ConnectorRunner, SecretDict, filter_output, make_hashable, verify_records_schema
from source_acceptance_test.utils.backward_compatibility import CatalogDiffChecker, SpecDiffChecker, validate_previous_configs
from source_acceptance_test.utils.common import (
from connector_acceptance_test.utils import ConnectorRunner, SecretDict, filter_output, make_hashable, verify_records_schema
from connector_acceptance_test.utils.backward_compatibility import CatalogDiffChecker, SpecDiffChecker, validate_previous_configs
from connector_acceptance_test.utils.common import (
build_configured_catalog_from_custom_catalog,
build_configured_catalog_from_discovered_catalog_and_empty_streams,
find_all_values_for_key_in_schema,
find_keyword_schema,
)
from source_acceptance_test.utils.json_schema_helper import JsonSchemaHelper, get_expected_schema_structure, get_object_structure
from connector_acceptance_test.utils.json_schema_helper import JsonSchemaHelper, get_expected_schema_structure, get_object_structure
from docker.errors import ContainerError
from jsonschema._utils import flatten


@pytest.fixture(name="connector_spec_dict")
Expand Down Expand Up @@ -629,7 +629,7 @@ def _validate_records_structure(records: List[AirbyteRecordMessage], configured_
there no common pathes then raise an alert.
:param records: List of airbyte record messages gathered from connector instances.
:param configured_catalog: SAT testcase parameters parsed from yaml file
:param configured_catalog: Testcase parameters parsed from yaml file
"""
schemas: Dict[str, Set] = {}
for stream in configured_catalog.streams:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

import pytest
from airbyte_cdk.models import ConfiguredAirbyteCatalog, Type
from source_acceptance_test.base import BaseTest
from source_acceptance_test.config import ConnectionTestConfig
from source_acceptance_test.utils import ConnectorRunner, JsonSchemaHelper, SecretDict, full_refresh_only_catalog, make_hashable
from source_acceptance_test.utils.json_schema_helper import CatalogField
from connector_acceptance_test.base import BaseTest
from connector_acceptance_test.config import ConnectionTestConfig
from connector_acceptance_test.utils import ConnectorRunner, JsonSchemaHelper, SecretDict, full_refresh_only_catalog, make_hashable
from connector_acceptance_test.utils.json_schema_helper import CatalogField


def primary_keys_by_stream(configured_catalog: ConfiguredAirbyteCatalog) -> Mapping[str, List[CatalogField]]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import pendulum
import pytest
from airbyte_cdk.models import AirbyteMessage, AirbyteStateMessage, AirbyteStateType, ConfiguredAirbyteCatalog, SyncMode, Type
from source_acceptance_test import BaseTest
from source_acceptance_test.config import Config, EmptyStreamConfiguration, IncrementalConfig
from source_acceptance_test.utils import ConnectorRunner, JsonSchemaHelper, SecretDict, filter_output, incremental_only_catalog
from connector_acceptance_test import BaseTest
from connector_acceptance_test.config import Config, EmptyStreamConfiguration, IncrementalConfig
from connector_acceptance_test.utils import ConnectorRunner, JsonSchemaHelper, SecretDict, filter_output, incremental_only_catalog


@pytest.fixture(name="future_state_configuration")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

import jsonschema
from airbyte_cdk.models import ConnectorSpecification
from connector_acceptance_test.utils import SecretDict
from deepdiff import DeepDiff
from hypothesis import HealthCheck, Verbosity, given, settings
from hypothesis_jsonschema import from_schema
from source_acceptance_test.utils import SecretDict


class BackwardIncompatibilityContext(Enum):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
DestinationSyncMode,
SyncMode,
)
from source_acceptance_test.config import Config, EmptyStreamConfiguration
from connector_acceptance_test.config import Config, EmptyStreamConfiguration


def load_config(path: str) -> Config:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[pytest]

addopts = -r fEsx --capture=no -vv --log-level=INFO --color=yes --force-sugar --cov=source_acceptance_test --no-cov-on-fail
addopts = -r fEsx --capture=no -vv --log-level=INFO --color=yes --force-sugar --cov=connector_acceptance_test --no-cov-on-fail
testpaths =
source_acceptance_test/tests
connector_acceptance_test/tests

markers =
default_timeout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
"pytest-mock~=3.6.1",
"pytest-cov~=3.0.0",
"hypothesis~=6.54.1",
"hypothesis-jsonschema~=0.20.1", # TODO alafanechere upgrade to latest when jsonschema lib is upgraded to >= 4.0.0 in airbyte-cdk and SAT
"hypothesis-jsonschema~=0.20.1", # TODO alafanechere upgrade to latest when jsonschema lib is upgraded to >= 4.0.0 in airbyte-cdk and connector acceptance tests
]

setuptools.setup(
name="source-acceptance-test",
description="Contains acceptance tests for source connectors.",
name="connector-acceptance-test",
description="Contains acceptance tests for connectors.",
author="Airbyte",
author_email="[email protected]",
url="https://github.com/airbytehq/airbyte",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ This script will create one PR per GA connectors to migrate to `high` test stric
3. Locally migrate `acceptance_test_config.yml` to the latest format
4. Commit and push the changes on this branch
5. Open a PR for this branch
6. Run a SAT on this branch by posting a `/test` comment on the PR
6. Run a connector acceptance test on this branch by posting a `/test` comment on the PR

An example of the PR it creates can be found [here](https://github.com/airbytehq/airbyte/pull/19136)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pathlib import Path

import yaml
from source_acceptance_test.config import Config
from connector_acceptance_test.config import Config
from yaml import load

try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
logging.basicConfig(level=logging.DEBUG)
environment = Environment(loader=FileSystemLoader(TEMPLATES_FOLDER))

parser = argparse.ArgumentParser(description="Create issues for migration of GA connectors to high test strictness level in SAT")
parser = argparse.ArgumentParser(
description="Create issues for migration of GA connectors to high test strictness level in connector acceptance test"
)
parser.add_argument("-d", "--dry", default=True)


def get_issue_content(source_definition):
issue_title = f"Source {source_definition['name']}: enable `high` test strictness level in SAT"
issue_title = f"Source {source_definition['name']}: enable `high` test strictness level in connector acceptance test"

template = environment.get_template("issue.md.j2")
issue_body = template.render(connector_name=source_definition["name"], release_stage=source_definition["releaseStage"])
Expand Down
Loading

0 comments on commit 6a10ae3

Please sign in to comment.