-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
feat(airbyte-ci): Enable manifest-only connector unit tests in CI #48790
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
airbyte-integrations/connectors/source-the-guardian-api/unit_tests/conftest.py
Show resolved
Hide resolved
.../connectors/pipelines/pipelines/airbyte_ci/connectors/test/steps/manifest_only_connectors.py
Outdated
Show resolved
Hide resolved
[tool.poetry.dependencies] | ||
python = "^3.10" | ||
airbyte-cdk = "5.17.0" | ||
pytest = "^8" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two things to note:
- I opted out of dev dependencies as the whole project is just a testing harness and I don't believe there is any need for separation of main/dev deps.
- For this iteration, the CDK version will have to be manually matched to whatever is listed in the connector's
metadata
. It should be a small pull to add some logic to up-to-date that automatically does this for us.
def test_page_increment(components_module, current_page, total_pages, expected_next_page): | ||
"""Test the CustomPageIncrement pagination for various page combinations""" | ||
|
||
CustomPageIncrement = components_module.CustomPageIncrement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just highlighting that this is how we can reference individual components within test files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work. Just had a few questions. Nothing that should be blocking though
.../connectors/pipelines/pipelines/airbyte_ci/connectors/test/steps/manifest_only_connectors.py
Outdated
Show resolved
Hide resolved
.../connectors/pipelines/pipelines/airbyte_ci/connectors/test/steps/manifest_only_connectors.py
Outdated
Show resolved
Hide resolved
airbyte-integrations/connectors/source-the-guardian-api/unit_tests/conftest.py
Show resolved
Hide resolved
/format-fix
|
], | ||
ids=["First page", "Middle page", "Penultimate page", "Last page", "Single page"] | ||
) | ||
def test_page_increment(connector_dir, components_module, current_page, total_pages, expected_next_page): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ChristoGrab I see something sus.
Since you import components_module
at the top and reference it as an argument.
Which is it using?
What happens if you remove the argument version?
def test_page_increment(connector_dir, components_module, current_page, total_pages, expected_next_page): | |
def test_page_increment(connector_dir, current_page, total_pages, expected_next_page): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switched to using the plugin approach and it works without the import statement 🎉
import airbyte_cdk | ||
import pytest | ||
import requests | ||
from airbyte_cdk.test.utils.manifest_only_fixtures import components_module, connector_dir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Why do we have to import?
Should this not be a pytest plugin that adds the fixture as an option for any test?
e.g.
# conftest.py
pytest_plugins = ["airbyte_cdk.test_fixtures"]
# some_unit_test.py
def test_ connector_dir(connector_dir):
assert connector_dir.exists()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, this approach seems to work and allows us to remove the import 👍 Should see the results in CI soon
/format-fix
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done, well implemented
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
Co-authored-by: Octavia Squidington III <[email protected]>
What
Enables unit testing capabilities for manifest-only connectors and validates the approach using
source-the-guardian-api
as a proof of concept. This change allows manifest-only connectors to maintain test coverage of custom components while benefiting from the simplified manifest-based architecture.Demo: https://www.loom.com/share/80b3ae7282e94dd0acfa34854b877462?sid=18b54fd6-79e0-4154-83ba-462d4345ddcb
Note
The changes in this PR are reliant on the availability of the test fixtures in the CDK. The PR to include those fixtures can be found here: airbytehq/airbyte-python-cdk#121
How
Guardian API PoC:
components.py
airbyte-ci
airbyte-ci
to support running unit tests for manifest-only connectors:ManifestConnectorUnitTests
class inheriting fromPytestStep
This approach provides a bridge for maintaining test coverage as we transition connectors to the manifest-only format, ensuring we can continue to maintain existing unit tests for custom Python components.
How to Test
airbyte-integrations/connectors/source-the-guardian-api/unit_tests
folderpoetry install
andpoetry run pytest
to verify the tests run locally.airbyte-ci/connectors/pipelines
and runpoetry install
andpoetry shell
airbyte-ci connectors --name=source-the-guardian-api test --only-step=unit
to run just the unit test suite against a built connector image.Can this PR be safely reverted and rolled back?