-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
POC: Add setup and teardown hooks to CATs #40551
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
dcb89c1
to
a8ca12f
Compare
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.
Nice POC! I have two main questions:
- Will running commands inside the connector container provide enough system dependency / tools which might be required for the setup/teardown? If we move to rootless containers in a couple of week the users won't be
root
anymore and depedency installs viaapt-get
oryum
won't be possible. I originally suggested to use a Dockerfile for maximal flexibility in terms of the environment that can be use to run these setup/teardown - I don't fully get the requirement for markers here. I would suggest passing the
setup_teardown
fixture to the tests which need it. It will make it simpler to understand when / why the setup_teardown flow is called.
...grations/bases/connector-acceptance-test/connector_acceptance_test/utils/connector_runner.py
Outdated
Show resolved
Hide resolved
airbyte-integrations/bases/connector-acceptance-test/connector_acceptance_test/conftest.py
Outdated
Show resolved
Hide resolved
...grations/bases/connector-acceptance-test/connector_acceptance_test/utils/connector_runner.py
Outdated
Show resolved
Hide resolved
@@ -186,6 +207,25 @@ def docker_runner_fixture( | |||
) | |||
|
|||
|
|||
@pytest.fixture(autouse=True) |
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.
@pytest.fixture(autouse=True) | |
@pytest.fixture() |
If I'm not mistaken autouse
means the fixture code will always get executed, even if no test depend on it. I'm not sure this is what we want.
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.
Going to try scope="function"
instead, which may be more like what we want.
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.
@alafanechere rather than passing in the setup_and_teardown
fixture to each test where it might be needed, WDYT about having autouse=True
here? The advantage is that it centralizes the logic for whether to run setup/teardown to the acceptance-test-config.yml
. For any tests for which setup/teardown config isn't present, the fixture will be a noop, and we won't have to remember to mark or add the fixture to new tests.
Since DB sources is already going to have to add the setup config to the tests for which it's required in acceptance-test-config.yml
, this feels like the cleanest approach.
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.
🆗 . In any case we don't have to make it perfect right away and I don't have a better suggestion, let's ship it on figure out how well it's working for our use cases.
@pytest.mark.setup | ||
@pytest.mark.teardown |
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.
Does these marker mean that the setup and teardown logic will run for each test in the class or once per class instantiation?
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.
This marks each test in the class as having an option to do setup/teardown. When the setup_and_teardown
fixture is being called for each test, it uses the presence of the marker to decide whether to run setup/teardown.
@alafanechere to answer your questions:
This was definitely a concern if the script were to get very complicated at all. The latest commit addresses this - using a single setup/teardown Dockerfile that will be built by the CAT container.
The markers aren't strictly needed, we could definitely pass the fixture to the tests instead. I'll look into doing it that way before finalizing this PR. That said, the real way to tell whether the setup/teardown flow is happening will be by looking in the |
3b7a946
to
de36a49
Compare
de36a49
to
ddb755f
Compare
…tead of the connector
Thank you very much for this great work @clnoll ! |
What
This demonstrates how we can add setup & teardown hooks to each test for which it's needed, to enable DB sources to setup the database before running
read
tests.How
This approach shows how to configure
acceptance-test-config.yml
with setup & teardown scripts that will be run before/after each test for which they're needed. We use theConnectorRunner
to copy the scripts to the connector container and run them from there.Tests that will run these scripts are marked with
@pytest.mark.setup
and@pytest.mark.teardown
.