Skip to content

fix: return mapped port from MariaDBContainer.getLivenessCheckPortNumbers#11577

Open
PreAgile wants to merge 2 commits intotestcontainers:mainfrom
PreAgile:fix/mariadb-liveness-port-10359
Open

fix: return mapped port from MariaDBContainer.getLivenessCheckPortNumbers#11577
PreAgile wants to merge 2 commits intotestcontainers:mainfrom
PreAgile:fix/mariadb-liveness-port-10359

Conversation

@PreAgile
Copy link
Contributor

Summary

Fix MariaDBContainer.getLivenessCheckPortNumbers() to return the mapped external port instead of the hardcoded internal port.

Problem

getLivenessCheckPortNumbers() returns Sets.newHashSet(3306) (the internal container port) instead of the mapped external port. This causes HostPortWaitStrategy and other liveness checks to potentially inspect the wrong port for readiness.

Root Cause

This bug was originally fixed for other containers in PR #5734 but MariaDB was missed. The new MariaDBContainer class (PR #11083) then copied the same buggy implementation.

Fix

Delegate to super.getLivenessCheckPortNumbers() which correctly maps internal ports to external mapped ports via getMappedPort().

Applied to both:

  • org.testcontainers.mariadb.MariaDBContainer (current)
  • org.testcontainers.containers.MariaDBContainer (deprecated)

Test

Added test verifying getLivenessCheckPortNumbers() returns the mapped port, following the same pattern used in MySQLContainerTest, PostgreSQLContainerTest, and MSSQLServerContainerTest.

Fixes #10359

@PreAgile PreAgile requested a review from a team as a code owner March 22, 2026 12:42
PreAgile added a commit to PreAgile/testcontainers-java that referenced this pull request Mar 22, 2026
…ssion

- Added PR testcontainers#11577 to active PRs tracking
- Updated testcontainers#10359 status from "무주공산" to "PR 제출 완료"
- Updated priority list to reflect all 3 PRs now in review
- Softened liveness check impact description per review feedback
- Added deprecated class test coverage rationale
@PreAgile PreAgile force-pushed the fix/mariadb-liveness-port-10359 branch from 8c09ded to d5e9301 Compare March 22, 2026 12:47
…bers

MariaDBContainer.getLivenessCheckPortNumbers() returned the hardcoded
internal port (3306) instead of the mapped external port. This was
originally fixed for other containers in a prior PR but MariaDB was
missed. The new MariaDBContainer class then copied the same buggy
implementation.

Delegate to super.getLivenessCheckPortNumbers() which correctly maps
internal ports to external mapped ports via getMappedPort().

Applied to both:
- org.testcontainers.mariadb.MariaDBContainer (current)
- org.testcontainers.containers.MariaDBContainer (deprecated)
@PreAgile PreAgile force-pushed the fix/mariadb-liveness-port-10359 branch from d5e9301 to 8fa3ee5 Compare March 22, 2026 12:52
@Override
public Set<Integer> getLivenessCheckPortNumbers() {
return Sets.newHashSet(MARIADB_PORT);
return super.getLivenessCheckPortNumbers();
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 see any reason why this override method should exist in the fist place when it's doing exactly the same as it's super counterpart.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point!
You're right — since super.getLivenessCheckPortNumbers() already handles the port mapping correctly,
there's no reason to keep this override.
I've removed the method entirely from both classes instead of delegating to super.
Thanks for catching this!

…iaDBContainer

The override was simply delegating to super, which is redundant.
Removing the method entirely lets the parent class handle port mapping correctly.
Also removed the associated test helper since it's no longer needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: [MariaDB] getLivenessCheckPortNumbers incorrectly implemented

2 participants