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

Create Config Database test base class #19640

Merged
merged 1 commit into from
Nov 28, 2022

Conversation

cgardens
Copy link
Contributor

@cgardens cgardens commented Nov 21, 2022

What

  • As a prerequisite to getting rid of the DatabaseConfigPersistence I realized that over time the BaseDatabaseConfigPersistenceTest had been misused. This was making it so that test run much slower (because the full database migration was being run between each test) and that it was much harder to write test classes for checking our database queries because lots of boilerplate was being needlessly copied and pasted because people didn't understand how to use the base class.

How

  • Replaced BaseDatabaseConfigPersistenceTest with BaseConfigDatabaseTest. This is a much more opinionated abstraction that I think will be harder to misuse. The javadocs in the class explain it in detail, so I will not repeat it here.
  • The rest of the changes in this PR are moving existing test classes to use the new abstraction.
  • This new abstraction will get used heavily in the next PR that removes DatabaseConfigPersistence which relies on us splitting out our tests more clearly. Decided to separate out this change for clarity.

Results

Time to run airbyte-config:config-persistence:test before this change:
Screen Shot 2022-11-20 at 4 55 01 PM

Time to run airbyte-config:config-persistence:test after this change:
Screen Shot 2022-11-20 at 4 50 52 PM

A neat 55% speed increase!! 😄

Recommended reading order

  1. BaseConfigDatabaseTest.java
  2. the rest

🚨 User Impact 🚨

  • This PR does NOT touch any production code. It is just touching tests and test abstraction. It will not have any effect on production behavior.

class DatabaseConfigPersistenceTest extends BaseConfigDatabaseTest {

public static final String DEFAULT_PROTOCOL_VERSION = "0.2.0";
protected static final StandardSourceDefinition SOURCE_GITHUB = new StandardSourceDefinition()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

all of this noise is copied from BaseDatabaseConfigPersistenceTest. It will all get removed in the next PR which gets rid of DatabaseConfigPersistence entirely.

statePersistence = new StatePersistence(database);
}

private void setupTestData() throws JsonValidationException, IOException {
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 diff looks bigger than it is. this is just pulled up from lower down in the class.

@cgardens cgardens temporarily deployed to more-secrets November 21, 2022 01:45 Inactive
@cgardens cgardens temporarily deployed to more-secrets November 21, 2022 01:45 Inactive
Copy link
Contributor

@jdpgrailsdev jdpgrailsdev left a comment

Choose a reason for hiding this comment

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

:shipit:

@cgardens cgardens merged commit 1d16a01 into master Nov 28, 2022
@cgardens cgardens deleted the cgardens/base-config-database-test branch November 28, 2022 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants