You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "nzw921rx (via GitHub)" <gi...@apache.org> on 2026/06/13 13:45:06 UTC
[PR] [Fix][E2E] Use dynamic port allocation to avoid port conflict in test containers [seatunnel]
nzw921rx opened a new pull request, #11096:
URL: https://github.com/apache/seatunnel/pull/11096
## Purpose of this pull request
Fix flaky E2E tests caused by fixed Docker port bindings in Flink and SeaTunnel engine test containers.
## Problem
The E2E test framework containers (`AbstractTestFlinkContainer`, `Flink20Container`, `SeaTunnelContainer`) used **fixed host port bindings** (e.g., `8081:8081`, `5801:5801`, `8080:8080`) via `setPortBindings()`.
This caused **"port is already allocated"** errors leading to cascading test failures:
```
com.github.dockerjava.api.exception.InternalServerErrorException: Status 500:
{"message":"Bind for 0.0.0.0:8081 failed: port is already allocated"}
```
### Root Cause
When a test container fails (e.g., due to timeout or resource exhaustion) and doesn't release the fixed port properly, **all subsequent tests** attempting to bind the same port will fail immediately. This is a primary cause of flaky tests in CI that pass on re-run.
### Failure Scenario
1. Test A starts a Flink container bound to host port `8081`
2. Test A fails/hangs, the container doesn't cleanly release port `8081`
3. Tests B, C, D... all try to start Flink containers on the same fixed port `8081`
4. All fail with `port is already allocated` — cascading failures
## Solution
Replace fixed port bindings (`setPortBindings`) with dynamic port allocation (`withExposedPorts(port)`). Docker automatically assigns a random available host port for each container, eliminating port conflicts.
The test code already uses `getMappedPort(port)` to access containers from the host, so this change is fully backward-compatible.
## Changes
| File | Before | After |
|------|--------|-------|
| `AbstractTestFlinkContainer.java` | `.withExposedPorts()` + `setPortBindings("8081:8081")` | `.withExposedPorts(8081)` |
| `Flink20Container.java` | `.withExposedPorts()` + `setPortBindings("8081:8081")` | `.withExposedPorts(8081)` |
| `SeaTunnelContainer.java` (2 places) | `.withExposedPorts()` + `setPortBindings("5801:5801", "8080:8080")` | `.withExposedPorts(5801, 8080)` |
## Impact
- Flink E2E tests (all versions: 1.4, 1.8, 2.0) will no longer conflict on port 8081
- SeaTunnel engine E2E tests will no longer conflict on ports 5801/8080
- Multiple test containers can coexist on the same CI runner without port collisions
- Significantly reduces flaky test rate in CI
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][E2E] Use dynamic port allocation to avoid port conflict in test containers [seatunnel]
Posted by "nzw921rx (via GitHub)" <gi...@apache.org>.
nzw921rx closed pull request #11096: [Fix][E2E] Use dynamic port allocation to avoid port conflict in test containers
URL: https://github.com/apache/seatunnel/pull/11096
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][E2E] Use dynamic port allocation to avoid port conflict in test containers [seatunnel]
Posted by "nzw921rx (via GitHub)" <gi...@apache.org>.
nzw921rx commented on PR #11096:
URL: https://github.com/apache/seatunnel/pull/11096#issuecomment-4700468166
CI is largely failing, so closing this for now; we'll revisit after planning dynamic ports.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org