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

java CDK, source-postgres: parallelize tests #32314

Merged
merged 7 commits into from
Nov 8, 2023

Conversation

postamar
Copy link
Contributor

@postamar postamar commented Nov 8, 2023

This PR parallelizes the tests and integration tests for source-postgres using junit's parallelism instead of gradle's. This allows us to start singleton test containers which are shared by all tests. Changing the parallelism forces the removal of the @SystemStub annotation which isn't supported in this case; I get around setting env vars by using and extending FeatureFlags.

The changes to the source-postgres tests are superficial in nature. A lot of the diff consists of lines whose indentation levels were changed. The parts of this PR deserving more scrutiny are in airbyte-cdk/**. Note that CI is failing but that's because of this annoying dockerhub rate limit again; airbyte-ci connectors --name=source-postgres test completes successfully in 7 minutes on my laptop.

Fixes #31818.

@postamar postamar requested a review from a team as a code owner November 8, 2023 18:47
Copy link

vercel bot commented Nov 8, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
airbyte-docs ⬜️ Ignored (Inspect) Visit Preview Nov 8, 2023 10:01pm

@octavia-squidington-iii octavia-squidington-iii added area/connectors Connector related issues CDK Connector Development Kit labels Nov 8, 2023
Copy link
Contributor

github-actions bot commented Nov 8, 2023

Before Merging a Connector Pull Request

Wow! What a great pull request you have here! 🎉

To merge this PR, ensure the following has been done/considered for each connector added or updated:

  • PR name follows PR naming conventions
  • Breaking changes are considered. If a Breaking Change is being introduced, ensure an Airbyte engineer has created a Breaking Change Plan.
  • Connector version has been incremented in the Dockerfile and metadata.yaml according to our Semantic Versioning for Connectors guidelines
  • You've updated the connector's metadata.yaml file any other relevant changes, including a breakingChanges entry for major version bumps. See metadata.yaml docs
  • Secrets in the connector's spec are annotated with airbyte_secret
  • All documentation files are up to date. (README.md, bootstrap.md, docs.md, etc...)
  • Changelog updated in docs/integrations/<source or destination>/<name>.md with an entry for the new version. See changelog example
  • Migration guide updated in docs/integrations/<source or destination>/<name>-migrations.md with an entry for the new version, if the version is a breaking change. See migration guide example
  • If set, you've ensured the icon is present in the platform-internal repo. (Docs)

If the checklist is complete, but the CI check is failing,

  1. Check for hidden checklists in your PR description

  2. Toggle the github label checklist-action-run on/off to re-run the checklist CI.

Copy link
Contributor

github-actions bot commented Nov 8, 2023

Coverage report for source-postgres

File Coverage [88.9%] 🍏
PostgresSource.java 88.9% 🍏
Total Project Coverage 71.99% 🍏

@postamar postamar removed the request for review from a team November 8, 2023 19:16
@@ -48,7 +48,7 @@ public static Connection createConnection(final JsonNode jdbcConfig) throws SQLE
validateReplicationConnection(connection);
return connection;
} catch (final PSQLException exception) {
if (exception.getMessage().equals("FATAL: must be superuser or replication role to start walsender")) {
if ("42501".equals(exception.getSQLState())) { // insufficient_privilege
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The existing logic doesn't work for postgres 16. In any case we shouldn't have business logic depending on textual messages, as far as postgres is concerned the sql state values are the proper API to use.

"chmod 0600 ~/.postgresql/postgresql.crt ~/.postgresql/postgresql.key",
"cp ca.crt root/.postgresql/ca.crt",
"chown postgres:postgres ~/.postgresql/ca.crt",
"psql -U test -c \"SELECT pg_reload_conf();\"",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These all came straight out of PostgresUtils::getCertificate.

@@ -9,7 +9,7 @@ plugins {
airbyteJavaConnector {
cdkVersionRequired = '0.4.1'
features = ['db-sources']
useLocalCdk = false
useLocalCdk = true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reminder to undo this and bump the required CDK version after publishing it.

@@ -0,0 +1 @@
testExecutionConcurrency=-1
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This triggers the junit test execution concurrency (instead of the default gradle concurrency). What this means is that the tests run in different threads rather than different processes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we tell also gradle to not do concurrency?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed we do, some connectors have testExecutionConcurrency=1 which effectively disables concurrency.

@rodireich
Copy link
Contributor

Question: do tests still pass with gradle … test?
Is it going to be faster with gradle?

@postamar
Copy link
Contributor Author

postamar commented Nov 8, 2023

Question: do tests still pass with gradle … test?
Is it going to be faster with gradle?

yes, and yes

} catch (final IOException e) {
throw new UncheckedIOException(e);
}
this.tmpDir.toFile().deleteOnExit();
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it will delete a directory that's not empty but I might be wrong

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you're right.

protected String getServerImageName() {
return "debezium/postgres:13-alpine";
protected static String getServerImageName() {
return "debezium/postgres:12-bullseye";
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd leave maybe some on 13 in case there's a difference between 12 and 13.

@postamar
Copy link
Contributor Author

postamar commented Nov 8, 2023

Thanks for the review!

@postamar
Copy link
Contributor Author

postamar commented Nov 8, 2023

/publish-java-cdk

🕑 https://github.com/airbytehq/airbyte/actions/runs/6804374573
✅ Successfully published Java CDK version=0.4.6!

@postamar postamar enabled auto-merge (squash) November 8, 2023 22:01
@postamar
Copy link
Contributor Author

postamar commented Nov 8, 2023

/approve-and-merge reason="test-only change"

@octavia-approvington
Copy link
Contributor

A crack team of mammals has made a decision.
imagine a seal of approval

@octavia-approvington octavia-approvington merged commit 5013f95 into master Nov 8, 2023
16 of 18 checks passed
@octavia-approvington octavia-approvington deleted the postamar/source-postgres-test-refactor branch November 8, 2023 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/connectors Connector related issues CDK Connector Development Kit connectors/source/postgres
Projects
None yet
Development

Successfully merging this pull request may close these issues.

java CDK, source-postgres: refactor tests to spin up less testcontainers
5 participants