testcontainers / testcontainers/testcontainers-java

Unexpected behavior for database containers launched via JDBC URL scheme

Open
#2,544 11 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stale
Dominant language
Java
Stars
8.7k
Forks
1.9k
Avg merge
2d 17h
Merged PRs (30d)
9

Description

Version: 1.13.0
Spring Boot: yes
Container: mariadb:10.4

According to Database containers launched via JDBC URL scheme's note:
We will use /// (host-less URIs) from now on to emphasis the unimportance of the host:port pair.
From Testcontainers' perspective, jdbc:mysql:5.7.22://localhost:3306/databasename and jdbc:mysql:5.7.22:///databasename is the same URI.

This URL jdbc:tc:mariadb:10.4:///users?TC_INITSCRIPT=sql/init.sql should behave as jdbc:tc:mariadb:10.4://localhost:33306/users?TC_INITSCRIPT=sql/init.sql

The result for the first is URL is:
Waiting for database connection to become available at jdbc:mariadb://localhost:32795/test using query 'SELECT 1'

This results in failed TC_INITSCRIPT due to permissions.

For the second is:
Waiting for database connection to become available at jdbc:mariadb://localhost:32797/users using query 'SELECT 1'

This might be missing from #566 and #617.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the two JDBC URLs from the issue with mariadb:10.4 and sql/init.sql, then trace the JDBC URL parsing and database initialization entry points for hostless and hostful forms. Done means both URL forms behave equivalently and TC_INITSCRIPT completes without the reported permissions failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, java, mariadb
Domain
databases, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.