Skip to content

[Fix][Zeta] Avoid port conflicts in HTTPS truststore test - #13028

Closed
nzw921rx wants to merge 1 commit into
apache:devfrom
nzw921rx:feature/https-truststore-port-isolation
Closed

nzw921rx wants to merge 1 commit into
apache:devfrom
nzw921rx:feature/https-truststore-port-isolation

Conversation

@nzw921rx

Copy link
Copy Markdown
Member

Purpose of this pull request

Fix the flaky RestApiHttpsForTruststoreTest startup failure observed in this CI run.

The fixed HTTPS port 18443 can fall inside Hazelcast's randomly allocated discovery range. Hazelcast then connects to the HTTPS listener, reports Unknown protocol, and eventually fails to start. Allocate both REST ports through the existing TestUtils allocator so they cannot overlap the Hazelcast range, and remove the redundant local port helper.

Does this PR introduce any user-facing change?

No. This change only updates the test fixture.

How was this patch tested?

  • JDK 17: Spotless and 12 tests across TestUtilsTest, RestApiHttpsTest, and RestApiHttpsForTruststoreTest passed:

    ./mvnw -o -nsu -pl seatunnel-engine/seatunnel-engine-server -Dmaven.gitcommitid.skip=true spotless:apply test -Dtest=RestApiHttpsForTruststoreTest,RestApiHttpsTest,TestUtilsTest -DfailIfNoTests=false
  • Repeated the four Truststore tests in three additional runs; all passed:

    ./mvnw -o -nsu -pl seatunnel-engine/seatunnel-engine-server -Dmaven.gitcommitid.skip=true surefire:test -Dtest=RestApiHttpsForTruststoreTest -DfailIfNoTests=false
  • Temporarily forced Hazelcast's range to 18376–18475: the original fixture reproduced the CI failure; the repaired fixture passed all four tests. Removed the temporary reproduction settings before final validation.

  • git diff --check passed. Maven verify was not run.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review of be6afda0d611833ac1781719a6165ea5c9744748 — no blocking source findings. Merge remains blocked by unfinished current-head CI and required approval.

Basic information: [Fix][Zeta] Avoid port conflicts in HTTPS truststore test; author nzw921rx; target dev; +7/-22 in one test file. Report time: 2026-10-28 02:38:48 EDT (UTC-0400). Local branch codex-review-13028-20261028, worktree /Volumes/disk8/tmp/seatunnel-review-13028-20261028.

What changes: the truststore fixture used a fixed TLS listener at 18443 while its base class allocated a random 100-port Hazelcast discovery range. For example, a range covering 18443 allowed Hazelcast to reach the TLS listener with its own protocol. Both REST ports now use the same TestUtils allocation registry as Hazelcast. This affects normal test setup; production startup is unchanged.

Key findings:

  • RestApiHttpsForTruststoreTest.java:49-51 allocates both ports through TestUtils. Java initializes the superclass instance first, so AbstractSeaTunnelServerTest.java:62 reserves the Hazelcast range before subclass REST allocation. Either allocation order is protected by the synchronized non-overlap registry in TestUtils.java:77-112.
  • All three TLS request URLs use the new httpsPort; the disabled HTTP check uses the separately allocated httpPort. All four original tests and their exact success/failure assertions are preserved. Removing findFreePortExcluding removes an uncoordinated allocator, not coverage.
  • The allocator checks bindability and records ranges within this JVM; it does not reserve sockets against unrelated processes. That existing external-process race remains a limitation and is not a new defect from this patch.

Code, compatibility and lifecycle: the fixture still builds Hazelcast configuration, loads HTTP/TLS configuration and certificates, starts SeaTunnel, and delegates cleanup to the unchanged base fixture. SeaTunnelServer.java creates JettyService when HTTPS is enabled; JettyService.enableHttps binds precisely the configured TLS port, which now matches every test URL. No production/API/SPI/configuration/default/checkpoint/serialization/connector-registration behavior changes. No new timer, thread pool, retry, queue, log-volume or resource-ownership changes. Windows remains disabled exactly as before. No migration is required.

Tests and documentation: this is an existing engine component/integration fixture, not a new production hook or E2E feature. testRestApiHttp protects disabled HTTP, testRestApiHttps checks successful authenticated access and response content, and the two negative TLS tests retain their SSLHandshakeException contracts. Existing TestUtilsTest checks non-overlap. English/Chinese user documentation is unnecessary because only fixture addresses change. No assertions, timeouts or CI selection are weakened.

Change-location assessment: the root cause is independent allocation in this fixture; the current fixture fields and URL references are the best repair location. Reusing the existing allocator is both the smallest safe fix and the best project-level fix for this case. Changing production discovery/TLS behavior or extending the shared allocator would enlarge compatibility and regression risk without addressing an additional demonstrated requirement. The existing base-class allocator and TLS setup remain intact.

Actual verification:

  • git fetch upstream pull/13028/head:codex-review-13028-20261028, exact-ref git show, full git diff 91ba231cb4b524d42e22935d03f194d584cf2fd3...codex-review-13028-20261028, git diff --check: passed; complete one-file diff and affected fixture/allocator/Jetty chains inspected.
  • Certificate resources https/server_keystore.jks and https/client_truststore.jks exist at the reviewed head.
  • gh pr view 13028 --json headRefOid,mergeable,mergeStateStatus,reviewDecision,reviews,statusCheckRollup and REST review/comment reads: passed. No existing formal or inline reviews/comments were present at review time.
  • Compilation, unit tests, integration tests, E2E, Docker and services: not run, under the repository's CI-only runtime-validation rule. No build artifacts were reused; seatunnel-engine-ui was not built because no build was run. Contributor-reported local executions were not treated as independently verified results.

Completeness cross-check: all changed lines, allocation order and overlap boundaries, TLS URL propagation, teardown, exception paths, preserved assertions, resource paths, compatibility and current merge gates were examined. There is no unreviewed changed file. No evidenced introduced blocking or nonblocking source defect was found.

Merge gates at review time: MERGEABLE, mergeStateStatus=BLOCKED, reviewDecision=REVIEW_REQUIRED; PR signal succeeded, while Build is in progress. These signals do not yet establish that the relevant current-head tests passed. Conclusion: source review has no blocking findings, but do not merge until current-head CI and the repository's required independent approval are satisfied. This COMMENT does not change approval state.

Publication gate snapshot (2026-10-28 02:45:27 EDT (UTC-0400)): reviewed head be6afda0d611833ac1781719a6165ea5c9744748 remains current; mergeable=MERGEABLE, mergeStateStatus=BLOCKED, reviewDecision=REVIEW_REQUIRED. Exact-head checks: Signal pull request update COMPLETED/SUCCESS; Build IN_PROGRESS. This latest snapshot supersedes earlier gate observations above; it does not replace required runtime coverage or approval.

@nzw921rx
nzw921rx requested a review from davidzollo October 28, 2026 12:54
@DanielLeens

Copy link
Copy Markdown
Contributor

Thanks for the contribution. The CI fact cited in my previous conclusion has changed; this follow-up updates that gate on the unchanged reviewed head, without issuing another full source review.

Gate snapshot (2026-10-28T15:42:57+00:00), head be6afda0d611833ac1781719a6165ea5c9744748: Build is SUCCESS.

CI was previously the only remaining technical gate in my conclusion; CI is now passing, so that CI objection is withdrawn and my technical conclusion is clear to proceed. Daniel currently has READ permission. I have not changed the effective GitHub review state to APPROVED; a write-capable maintainer must perform the final approve/dismiss action required by branch protection.

Comparison recorded in this scan: base dev, diverged, ahead 1 / behind 8, no merge conflict. Branch drift is metadata here and is not an additional sync request.

@nzw921rx

Copy link
Copy Markdown
Member Author

#13030 merged!

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.

2 participants