-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Run CATs with local CDK #23084
Run CATs with local CDK #23084
Conversation
Airbyte Code Coverage
|
ad65534
to
69478af
Compare
airbyte-integrations/bases/connector-acceptance-test/acceptance-test-docker.sh
Show resolved
Hide resolved
airbyte-integrations/bases/connector-acceptance-test/acceptance-test-docker.sh
Outdated
Show resolved
Hide resolved
# Clean up from previous test runs | ||
rm -rf $OUTPUT_DIR && mkdir $OUTPUT_DIR | ||
|
||
while getopts ":c:" opt; do |
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.
would be useful to give an example of how to run the script
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.
👍 added help text.
8af08bf
to
bfea1a1
Compare
bfea1a1
to
e9c9511
Compare
e9c9511
to
d9baa02
Compare
@@ -1,16 +1,8 @@ | |||
#!/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-) | |||
set -e |
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.
would it make sense to move this file to a top level (eg tools) and symlink it instead of copypasting the same file 250 times?
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.
good idea
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.
I have a slight hesitation with that - we'll have to update our documentation for creating a connector to tell people "create a symlink to <dir>/acceptance-test-docker.sh
, but make sure it's a relative symlink not an absolute one". WDYT about keeping the file but reducing it even further so it just sources acceptance-test-docker.sh
, and doesn't contain the readlink
logic? An alternative would be to have a script that sets up a connector directory with the boilerplate files & relative symlink pre-populated. But that might be a project for another PR as I'm sure there are some other files/directories we'd want to create as part of the script, but am not totally sure yet what they are.
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.
I don't feel too strongly about symlink vs removing even more cruft from the file, but we already have a script to generate connectors. We should update the template so it matches
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.
Thanks for pointing me to the template code! Turns out that the npm generate
package does not copy over symlinks, so instead I've opted to clean things up a bit by having the connectors' acceptance-test-docker.sh
just source the base acceptance-test-docker.sh
, reducing it to just one line. LMK what you think.
airbyte-integrations/connectors/source-greenhouse/_secrets/config.json
Outdated
Show resolved
Hide resolved
airbyte-integrations/connectors/source-greenhouse/_secrets/config_users_only.json
Outdated
Show resolved
Hide resolved
## Running the acceptance tests on multiple connectors: | ||
If you are contributing to the python CDK, you may want to validate your changes by running acceptance tests against multiple connectors. | ||
|
||
To do so, from the root of the `airbyte` repo, run `./airbyte-cdk/python/bin/run-cats-with-local-cdk.sh -c <connector1>,<connector2>,...` |
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.
I'm getting this error. Any idea what I'm doing wrong?
➜ airbyte git:(run-cats-with-local-cdk) ✗ ./airbyte-cdk/python/bin/run-cats-with-local-cdk.sh -c source-stripe,source-greenhouse
Running CATs for source-stripe source-greenhouse
source-greenhouse errors:
readlink: illegal option -- f
usage: readlink [-n] [file ...]
source-stripe errors:
readlink: illegal option -- f
usage: readlink [-n] [file ...]
Done.
edit: looks like readlink -f doesn't exist on macos :(
A potential suggestion might be to use raw readlink in a while loop.
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.
oh weird, that run fine for me
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.
I went ahead and switched this to Alex's suggestion, so we don't have to require a non-builtin readlink.
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.
I like that this is modularized in a way that enables the three use cases (testing a single connector, testing multiple connectors, only building the docker image). Nice work!
Left a few comments. Main request for change is that these scripts should be easily discoverable by the people who would benefit from them, so if we can sprinkle them in docs that would be great e.g:
- Add something in CDK README for a CDK dev
- Ideally we even add something in the connector README that says
... to run with a local version of the CDK use LOCAL_CDK=1
or something but it may be harder to finagle together the right sed command for that
But generally speaking these are all small comments. Overall it looks great.
airbyte-integrations/bases/connectors/build-connector-image-with-local-cdk.sh
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,75 @@ | |||
#!/usr/bin/env sh | |||
|
|||
USAGE="$(basename "$0") [-h] [-c connector1,connector2,...] -- Run connector acceptance tests (CATs) against the local CDK, if relevant.\n |
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.
which dir is this script expected to be run from? Should there be an assertion on that?
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 script can be run from anywhere in the airbyte
repo. Added an assertion.
@@ -35,6 +35,15 @@ _Note: this way 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_ | |||
|
|||
You can also use the following environment variables with the Gradle and Bash commands: |
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.
these instructions should probably also be in the CDK README? or it should point to these
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.
👍 updated.
## Running the acceptance tests on multiple connectors: | ||
If you are contributing to the python CDK, you may want to validate your changes by running acceptance tests against multiple connectors. | ||
|
||
To do so, from the root of the `airbyte` repo, run `./airbyte-cdk/python/bin/run-cats-with-local-cdk.sh -c <connector1>,<connector2>,...` |
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.
oh weird, that run fine for me
sed -iE 's,"airbyte-cdk[^"]*","airbyte-cdk @ file://localhost/airbyte-cdk",' setup.py | ||
|
||
# Build the connector image | ||
docker_build_quiet "$CONNECTOR_TAG" |
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.
I was a little thrown off that this built quietly. I am sort of used to seeing Docker build output in our current scripts otherwise I assumed something was going wrong. Any reason you wanted it quiet instead of normal verbosity?
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.
docker build
sends its output to stderr by default, so when this script is called from the run-cats-with-local-cdk.sh
wrapper, the build output gets printed out along with any other CAT errors. I think it makes sense to use -q
in that situation (lmk if you disagree), but now that the image-building happens in its own script, I agree that the build output should be visible. I've updated this script to only use -q if called from run-cats-with-local-cdk.sh
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.
that's fine, can we at least add a log message that says building docker image $NAME
or something? it would help the human at the keyboard know that things are moving along rather than stalled
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.
Yep, makes sense to me - added.
esac | ||
done | ||
|
||
if [ -z "$connectors" ]; then |
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.
if [ -z "$connectors" ]; then | |
if [ -z "$connectors" ]; then | |
echo "You did not specify any connectors using the -c flag which means this script will run for ALL connectors" | |
echo "You almost certainly did not mean to do this. Exit now would be my advice. But what do I know? I'm just a script." | |
echo "Hope you have 128 cores on this machine!" |
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.
How about I exit with an error, instead of defaulting to all? It feels like running all should work in theory since the tests are network-bound but Docker doesn't seem to want to handle the load.
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 could also just fail if $connectors is not defined
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.
exit with error makes more sense :P
@@ -0,0 +1,75 @@ | |||
#!/usr/bin/env sh |
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.
The CDK readme should contain something about this file, maybe replacing the existing guidance saying how to fiddle with gradle etc.
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.
👍 updated.
@@ -1,16 +1,8 @@ | |||
#!/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-) | |||
set -e |
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.
good idea
Co-authored-by: Alexandre Girard <alexandre@airbyte.io>
Co-authored-by: Sherif A. Nada <snadalive@gmail.com>
…acceptance-test-docker.sh
Affected Connector ReportThe latest commit has removed all connector-related changes. There are no more dependent connectors for this PR. |
f0678c2
to
8243697
Compare
8243697
to
47e6b2a
Compare
/test connector=connectors/source-gnews
Build FailedTest summary info:
|
/test connector=connectors/source-facebook-pages
Build FailedTest summary info:
|
/test connector=connectors/source-courier
Build FailedTest summary info:
|
/test connector=connectors/source-zoom
Build PassedTest summary info:
|
Scripts to * Run CATs against the local CDK for one connector * Run CATs against the local CDK for multiple connectors * Create a connecter image with the local CDK --------- Co-authored-by: Alexandre Girard <alexandre@airbyte.io> Co-authored-by: Sherif A. Nada <snadalive@gmail.com>
What
Allow us to run all or a subset of CATs against the local CDK.
How
airbyte-integrations/connectors/<CONNECTOR>/acceptance-test-docker.sh
to runairbyte-integrations/bases/connector-acceptance-test/acceptance-test-docker.sh
, which will use the local CDK if theLOCAL_CDK
environment variable is set. See the POC for information on how this is being done.acceptance-test-docker.sh
to fetch secrets if theFETCH_SECRETS
environment variable is set. This requires the user to have a Google Service Account and theGCP_GSM_CREDENTIALS
environment variable to be set, per the instructions here and here.-c
flag) against which to run the CATs with the local CDK. If no connectors are supplied, defaults to running CATs for all connectors that useairbyte-cdk
in theirsetup.py
.Recommended reading order
airbyte-cdk/python/bin/run-cats-with-local-cdk.sh
airbyte-integrations/bases/connector-acceptance-test/acceptance-test-docker.sh
airbyte-integrations/bases/connectors/build-connector-image-with-local-cdk.sh
airbyte-integrations/bases/connectors/utils.sh
<CONNECTOR>/acceptance-test-docker.sh
Closes 22091 and 22695.