testcontainers-java icon indicating copy to clipboard operation
testcontainers-java copied to clipboard

fix: return mapped port from MariaDBContainer.getLivenessCheckPortNumbers

Open PreAgile opened this issue 8 months ago • 1 comments

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 avatar Mar 22 '26 12:03 PreAgile

Pushed the actual removal now — sorry for the earlier confusion. The override has been removed from both classes together with the now-unused imports.

PreAgile avatar Apr 24 '26 05:04 PreAgile