Migrated MariaDB, MySQL, PostgreSQL tests to use testcontainers to simplify local setup - #2011
Migrated MariaDB, MySQL, PostgreSQL tests to use testcontainers to simplify local setup #2011koperagen wants to merge 9 commits into
Conversation
| st.setTime(16, java.sql.Time(System.currentTimeMillis())) | ||
| st.setTimestamp(14, SqlTimestamp(System.currentTimeMillis())) | ||
| st.setTimestamp(15, SqlTimestamp(System.currentTimeMillis())) | ||
| st.setTime(16, SqlTime(System.currentTimeMillis())) |
There was a problem hiding this comment.
Automatic refactorings break such fully qualified links :( I recovered it as import alias, should survive file moves etc
There was a problem hiding this comment.
🟡 Not ready to approve
It currently introduces a dependency-resolution issue in the version catalog and a Kotlin compilation error from an unused import.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
This PR migrates the JDBC integration tests for MariaDB/MySQL/PostgreSQL to Testcontainers so contributors can run them locally with Docker, while keeping CI’s default test task free of Docker-dependent tests.
Changes:
- Added Testcontainers dependencies to the version catalog and
dataframe-jdbctest configuration. - Updated MariaDB/MySQL/PostgreSQL test suites to start/stop containers in
@BeforeClass/@AfterClassrather than relying on localhost DBs. - Added a dedicated
testcontainersTestGradle task and excluded the Testcontainers package from the defaulttesttask.
File summaries
| File | Description |
|---|---|
| gradle/libs.versions.toml | Adds Testcontainers version + catalog entries for DB modules. |
| dataframe-jdbc/build.gradle.kts | Adds Testcontainers test deps; excludes Docker tests from test and introduces testcontainersTest. |
| dataframe-jdbc/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/testcontainers/postgresTest.kt | Switches Postgres tests to a managed PostgreSQLContainer. |
| dataframe-jdbc/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/testcontainers/postgresConnectionUrlTest.kt | Reworks Postgres URL parsing tests to run against a container. |
| dataframe-jdbc/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/testcontainers/mysqlTest.kt | Switches MySQL tests to a managed MySQLContainer. |
| dataframe-jdbc/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/testcontainers/mariadbTest.kt | Switches MariaDB tests to a managed MariaDBContainer. |
| dataframe-jdbc/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/testcontainers/images.kt | Centralizes Docker image tags used by the Testcontainers tests. |
Review details
Comments suppressed due to low confidence (2)
dataframe-jdbc/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/testcontainers/mysqlTest.kt:20
- Unused import
org.junit.Ignorewill fail Kotlin compilation (unused imports are errors). The@Ignoreannotation was removed, so this import should be removed too.
dataframe-jdbc/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/testcontainers/postgresTest.kt:30 - Unused import
org.junit.Ignorewill fail Kotlin compilation (unused imports are errors). The@Ignoreannotation was removed, so this import should be removed too.
- Files reviewed: 7/7 changed files
- Comments generated: 1
- Review effort level: Low
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
| testcontainers-postgresql = { group = "org.testcontainers", name = "testcontainers-postgresql", version.ref = "testcontainers" } | ||
| testcontainers-mysql = { group = "org.testcontainers", name = "testcontainers-mysql", version.ref = "testcontainers" } | ||
| testcontainers-mariadb = { group = "org.testcontainers", name = "testcontainers-mariadb", version.ref = "testcontainers" } |
|
https://gh.io/copilot-coding-agent-docs will this work on Windows or on Team City? |
|
Did you test it with it already on TC? See https://www.jetbrains.com/help/teamcity/2026.1/gradle.html?TeamCity%20Documentation#Container+Settings and https://www.jetbrains.com/help/teamcity/2026.1/container-wrapper.html?TeamCity%20Documentation (locally, they seem to run well, btw!) |
| package org.jetbrains.kotlinx.dataframe.io.testcontainers | ||
|
|
||
| // Available image tags: https://hub.docker.com/_/mariadb/tags | ||
| const val MARIADB_IMAGE = "mariadb:12.3.2" |
There was a problem hiding this comment.
I feel like these should be configurable higher up, like in Gradle with BuildConfig. If we need to bump them, it will be difficult to find them so deeply nested
There was a problem hiding this comment.
I think the question here is how often we expect to update them. It's not really a dependency exposed to our users, only a test database instance we'll use to make sure our changes to JDBC module do not break anything on isolated environment. I picked all very fresh versions that are expected to be supported for 5 years.
If we're interested, i can add renovatebot with custom rule to watch over these versions right here in images.kt. That's the only common practice i could find regarding where image versions should be stored. I believe other just keep it in sync with their production database, which is not applicable to us
There was a problem hiding this comment.
Shouldn't they be updated along with the library versions of the databases?
There was a problem hiding this comment.
Ah no, they're different, it seems. Still, it's a test dependency from an external source, which makes it little different than other testImplementation dependencies. It can be taken offline, updated, etc. so hiding it in a source file is probably not the best way to go
There was a problem hiding this comment.
I don't think so, i'd expect a very thorough backward compatibility
https://jdbc.postgresql.org/download/
This is the current version of the driver. Unless you have unusual requirements (running old applications or JVMs), this is the driver you should be using. It supports PostgreSQL 8.4 or newer and requires Java 6 or newer. It contains support for SSL and the javax.sql package.
https://mariadb.com/docs/connectors/mariadb-connector-j/about-mariadb-connector-j
MariaDB Connector/J is compatible with all MariaDB and MySQL server versions.
MariaDB Connector/J releases older than 1.2.0 may be compatible with server versions older than MySQL 5.5, but those MariaDB Connector/J releases aren't supported anymore.
https://dev.mysql.com/doc/connector-j/en/connector-j-versions.html
MySQL Server versions: Connector/J 26.7 supports MySQL 8.0 and up. ( first released 19 April 2018)
There was a problem hiding this comment.
So we go in other direction and need to update only if we want to test new feature that is supported only in most recent database
There was a problem hiding this comment.
Tbh i don't really mind moving it to buildconfid altogether. Mostly wanted to clarify my impression that updating those is not the same as updating usual dependencies, we probably shouldn't do it frequently even if it ends up in the version catalog
There was a problem hiding this comment.
I understand :) It's comparable to us sticking to an older JUnit version since it covers all we need in our tests. Even though we don't bump it often, it will be bumped at some point, so it's nice to know where the single source-of-truth regarding versions exists in the project
bad copilot : ( why did it have to commit things to my branch and break CI. Besised, i'd do abstract test class and have LocalMariaDb tests + DockerMariaDb tests instead |
On TeamCity eventually yes, need to configure teamcity to run on agents that have docker daemon |
89fcba0 to
7af1db1
Compare
|
Great job! Will test it next week on both MacOS and WIndows, locally and not, and it will be shipped! |
Tests still will not be run on CI for now. But it'll be now possible to run MariaDB, MySQL, PostgreSQL in one click, providing you have docker installed on PC. It's the only prerequisite.
Let's start with those and migrate imbd, mssql example after
For reference. Looks like their JUnit4 examples are a bit outdated and nowadays modern "container" classes do not implement "testrule" class, so we use manual lifecycle management instead
https://java.testcontainers.org/modules/databases/mysql/
https://java.testcontainers.org/modules/databases/mariadb/
https://java.testcontainers.org/modules/databases/postgres/