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

test: Drop duplicate Spring tests using non-H2 Gradle tasks #1947

Merged
merged 2 commits into from
Dec 19, 2023

Conversation

bog-walk
Copy link
Member

Currently, both spring-transaction and exposed-spring-boot-starter modules are set up to not be database-specific, but to only test how Exposed generally integrates with Spring.
This means that all unit tests use an embedded H2 database and that these test classes do not extend DatabaseTestsBase() .

In spite of this, all Spring tests are run by every Gradle test task, resulting in multiple H2 duplicate tests when task test or TC build is run.

Duplicates can be confirmed by:

  • Log Transaction.db.vendor or Transaction.db.dialect in any test while running a non-H2 test task:
    • Output will always be "H2" or "H2Dialect"
  • Execute any H2-incompatible SQL in a test:
    • e.g. exec("SELECT version();") should work when included in any test run with testPostgres, but instead this is thrown: org.h2.jdbc.JdbcSQLSyntaxErrorException: Function "VERSION" not found

Excluding tests in the Spring packages confirmed locally and on TC build.
The total number of tests is still somehow 10071 but the only tasks with tests is testH2 and build time dropped from 37-40 minutes to 32-35 minutes.
Example before:
springtx_before_small

Example after:
springtx_after_small

Currently, both spring-transaction and exposed-spring-boot-starter modules are
set up to not be database-specific, but to only test how Exposed integrates with
Spring. This means that these test classes do not extend DatabaseTestsBase() and
all unit tests use an embedded H2 database.

In spite of this, all Spring tests are run by every Gradle test task, resulting
in multiple H2 duplicate tests when task test or TC build is run.

This excludes tests in the Spring package from all tasks except testH2.
Fix spring boot module odd package name in exclude.
@bog-walk bog-walk requested a review from e5l December 17, 2023 23:11
Comment on lines +65 to +72
if (db.ignoresSpringTests) {
filter {
// exclude all test classes in (spring-transaction, exposed-spring-boot-starter) modules
exclude("org/jetbrains/exposed/spring/*", "org/jetbrains/exposed/jdbc-template/*")
isFailOnNoMatchingTests = false
}
}

Copy link
Member Author

Choose a reason for hiding this comment

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

If there is a better gradle way to do this exclusion, please let me know.

Copy link
Member

Choose a reason for hiding this comment

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

that's a right one

@bog-walk bog-walk merged commit bda376f into main Dec 19, 2023
3 checks passed
@bog-walk bog-walk deleted the bog-walk/drop-duplicate-spring-tests branch December 19, 2023 14:08
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.

2 participants