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

Make connector acceptance test gradle plugin work for destinations #22609

Merged
merged 7 commits into from
Feb 24, 2023

Conversation

flash1293
Copy link
Contributor

@flash1293 flash1293 commented Feb 8, 2023

When trying to use the connector acceptance test plugin for destinations, it didn't execute correctly (see #22317 ) This change makes the gradle plugin call the acceptance test in the same way the acceptance-test-docker.sh file from the connector template does it.

I don't notice any difference in what's actually run as part of the test, but maybe I'm missing something here.

@flash1293
Copy link
Contributor Author

flash1293 commented Feb 8, 2023

/test connector=connectors/source-s3

🕑 connectors/source-s3 https://github.com/airbytehq/airbyte/actions/runs/4128665593
❌ connectors/source-s3 https://github.com/airbytehq/airbyte/actions/runs/4128665593
🐛 https://gradle.com/s/q47q27cpnh7nu

Build Failed

Test summary info:

=========================== short test summary info ============================
FAILED test_core.py::TestBasicRead::test_read[inputs2] - Failed: Please check...
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/connector_acceptance_test/tests/test_core.py:98: The previous and actual specifications are identical.
SKIPPED [6] ../usr/local/lib/python3.9/site-packages/connector_acceptance_test/tests/test_core.py:507: The previous and actual discovered catalogs are identical.
============= 1 failed, 107 passed, 7 skipped in 261.29s (0:04:21) =============

@flash1293
Copy link
Contributor Author

/test connector=connectors/source-github

@flash1293
Copy link
Contributor Author

flash1293 commented Feb 8, 2023

/test connector=connectors/source-postgres

🕑 connectors/source-postgres https://github.com/airbytehq/airbyte/actions/runs/4128666806
❌ connectors/source-postgres https://github.com/airbytehq/airbyte/actions/runs/4128666806
🐛 https://gradle.com/s/z5ub6kf3fbkuk

Build Failed

Test summary info:

Could not find result summary

@flash1293 flash1293 temporarily deployed to more-secrets February 8, 2023 21:45 — with GitHub Actions Inactive
@flash1293 flash1293 temporarily deployed to more-secrets February 8, 2023 21:45 — with GitHub Actions Inactive
@github-actions
Copy link
Contributor

github-actions bot commented Feb 8, 2023

Airbyte Code Coverage

There is no coverage information present for the Files changed

Total Project Coverage 27.16% 🍏

@flash1293
Copy link
Contributor Author

flash1293 commented Feb 8, 2023

/test connector=connectors/source-github

🕑 connectors/source-github https://github.com/airbytehq/airbyte/actions/runs/4129298752
✅ connectors/source-github https://github.com/airbytehq/airbyte/actions/runs/4129298752
Python tests coverage:

Name                             Stmts   Miss  Cover
----------------------------------------------------
source_github/utils.py              14      0   100%
source_github/github_schema.py    8807      0   100%
source_github/__init__.py            2      0   100%
source_github/streams.py           855     91    89%
source_github/graphql.py           167     22    87%
source_github/source.py            106     25    76%
----------------------------------------------------
TOTAL                             9951    138    99%
	 Name                                                    Stmts   Miss  Cover   Missing
	 -------------------------------------------------------------------------------------
	 connector_acceptance_test/base.py                          12      4    67%   16-19
	 connector_acceptance_test/config.py                       141      5    96%   87, 93, 239, 243-244
	 connector_acceptance_test/conftest.py                     217    101    53%   37, 43-45, 50, 55, 78, 84, 90-92, 111, 116-118, 124-126, 132-133, 138-139, 144, 150, 159-168, 174-179, 194, 218, 249, 255, 263-271, 279-292, 300-313, 318-324, 331-342, 349-365
	 connector_acceptance_test/plugin.py                        69     25    64%   22-23, 31, 36, 120-140, 144-148
	 connector_acceptance_test/tests/test_core.py              476    117    75%   53, 58, 97-108, 113-120, 124-125, 129-130, 380, 400, 438, 476-493, 506-517, 521-526, 532, 565-570, 608-615, 658-660, 663, 728-736, 748-751, 756, 812-813, 819, 822, 858-868, 881-906
	 connector_acceptance_test/tests/test_incremental.py       160     14    91%   58-65, 70-83, 246
	 connector_acceptance_test/utils/asserts.py                 39      2    95%   62-63
	 connector_acceptance_test/utils/common.py                  94     10    89%   16-17, 32-38, 72, 75
	 connector_acceptance_test/utils/compare.py                 62     23    63%   21-51, 68, 97-99
	 connector_acceptance_test/utils/connector_runner.py       133     33    75%   24-27, 46-47, 50-54, 57-58, 73-75, 78-80, 83-85, 88-90, 93-95, 124-125, 159-161, 208
	 connector_acceptance_test/utils/json_schema_helper.py     114     13    89%   31-32, 39, 42, 66-69, 97, 121, 203-205
	 -------------------------------------------------------------------------------------
	 TOTAL                                                    1696    347    80%

Build Passed

Test summary info:

=========================== short test summary info ============================
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/connector_acceptance_test/tests/test_core.py:98: The previous and actual specifications are identical.
SKIPPED [2] ../usr/local/lib/python3.9/site-packages/connector_acceptance_test/tests/test_core.py:507: The previous and actual discovered catalogs are identical.
================== 44 passed, 3 skipped in 312.37s (0:05:12) ===================

@flash1293 flash1293 marked this pull request as ready for review February 9, 2023 15:00
@flash1293 flash1293 requested review from sherifnada and alafanechere and removed request for sherifnada February 9, 2023 15:01
@flash1293 flash1293 temporarily deployed to more-secrets February 10, 2023 17:51 — with GitHub Actions Inactive
@flash1293 flash1293 temporarily deployed to more-secrets February 10, 2023 17:51 — with GitHub Actions Inactive
Copy link
Contributor

@alafanechere alafanechere left a comment

Choose a reason for hiding this comment

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

It looks like a reasonable change to me but it's not very clear why it's solving the import error p problem for destinations.

@@ -19,7 +19,7 @@ class AirbyteConnectorAcceptanceTestPlugin implements Plugin<Project> {
'-w', "$targetMountDirectory",
'-e', "AIRBYTE_SAT_CONNECTOR_DIR=${project.projectDir.absolutePath}",
'airbyte/connector-acceptance-test:dev',
'-p', 'integration_tests.acceptance',
'--acceptance-test-config', targetMountDirectory,
Copy link
Contributor

Choose a reason for hiding this comment

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

are you sure this isn't a red herring? I don't follow why this fixes the issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For example with #22393 the acceptance tests run correctly when called this way but fail with “could not find module integration_tests.acceptance” with the old call.

I’m not sure why though, that’s why I pinged you on this.

Copy link
Contributor

@sherifnada sherifnada Feb 17, 2023

Choose a reason for hiding this comment

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

Ah I think I see the problem.

-p integration_tets.acceptance tells the running pytest process (CAT in this case) to look at a file integration_tests/acceptance.py to configure tests.

In this situation the working directory is always set to the connector's directory. Python connectors always have a integration_tests/acceptance.py file, so this works for them. Even the java connectors which implement CAT also have that directory with an acceptance.py file (eg see postgres).

That directory is important because it allows the user to configure setup/teardown actions e.g: create a database and tear it down.

I think the correct way to handle this would be to create an integration_tests/acceptance.py directory for the connector in question, or maybe conditionally add this flag depending on whether that directory exists.

I think the --acceptance-test-config arg is unnecessary. By default SAT looks for an acceptance-test-config.yaml in the working directory (which is always set to the connector dir) so I think we can remove this arg.

@flash1293 flash1293 temporarily deployed to more-secrets February 16, 2023 10:13 — with GitHub Actions Inactive
@flash1293 flash1293 temporarily deployed to more-secrets February 16, 2023 10:13 — with GitHub Actions Inactive
@@ -19,7 +19,7 @@ class AirbyteConnectorAcceptanceTestPlugin implements Plugin<Project> {
'-w', "$targetMountDirectory",
'-e', "AIRBYTE_SAT_CONNECTOR_DIR=${project.projectDir.absolutePath}",
'airbyte/connector-acceptance-test:dev',
'-p', 'integration_tests.acceptance',
'--acceptance-test-config', targetMountDirectory,
Copy link
Contributor

@sherifnada sherifnada Feb 17, 2023

Choose a reason for hiding this comment

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

Ah I think I see the problem.

-p integration_tets.acceptance tells the running pytest process (CAT in this case) to look at a file integration_tests/acceptance.py to configure tests.

In this situation the working directory is always set to the connector's directory. Python connectors always have a integration_tests/acceptance.py file, so this works for them. Even the java connectors which implement CAT also have that directory with an acceptance.py file (eg see postgres).

That directory is important because it allows the user to configure setup/teardown actions e.g: create a database and tear it down.

I think the correct way to handle this would be to create an integration_tests/acceptance.py directory for the connector in question, or maybe conditionally add this flag depending on whether that directory exists.

I think the --acceptance-test-config arg is unnecessary. By default SAT looks for an acceptance-test-config.yaml in the working directory (which is always set to the connector dir) so I think we can remove this arg.

@flash1293 flash1293 temporarily deployed to more-secrets February 17, 2023 10:25 — with GitHub Actions Inactive
@flash1293 flash1293 temporarily deployed to more-secrets February 17, 2023 10:25 — with GitHub Actions Inactive
Joe Reuter added 2 commits February 17, 2023 11:30
@flash1293 flash1293 temporarily deployed to more-secrets February 17, 2023 10:39 — with GitHub Actions Inactive
@flash1293 flash1293 temporarily deployed to more-secrets February 17, 2023 10:40 — with GitHub Actions Inactive
@flash1293
Copy link
Contributor Author

conditionally add this flag depending on whether that directory exists

I went with this approach for now, running a test here #22393 (comment) to see whether it works

@flash1293
Copy link
Contributor Author

@sherifnada OK, this seems to work. On the other PR where I configured the s3 destination to run acceptance tests I made the same changes as on this PR and the acceptance tests run correctly (showing the real problem with oneOf-usage): #22393 (comment)

Running tests on a source still works correctly: #22393 (comment)

To make sure the module is still picked up correctly when it's available, I broke the setup method here: 31d9c9b

and as expected the tests failed with this error message: #22393 (comment)

@flash1293 flash1293 requested a review from sherifnada February 17, 2023 13:57
@alafanechere
Copy link
Contributor

I think the correct way to handle this would be to create an integration_tests/acceptance.py directory for the connector in question, or maybe conditionally add this flag depending on whether that directory exists.

Oh yes you're right, this is what we had to do to make the acceptance run on java sources.

Copy link
Contributor

@sherifnada sherifnada left a comment

Choose a reason for hiding this comment

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

FYI @clnoll in case this overlaps with your changes

@flash1293 flash1293 merged commit 053d352 into master Feb 24, 2023
@flash1293 flash1293 deleted the flash1293/fix-connector-acceptance-test-plugin branch February 24, 2023 17:10
danielduckworth pushed a commit to danielduckworth/airbyte that referenced this pull request Mar 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants