zhangshenghang opened a new pull request, #13767:
URL: https://github.com/apache/seatunnel/pull/13767

   Yes — I am contributing this change to Apache SeaTunnel, and I confirm it 
follows the project's
   contribution conventions (English PR title/description, one focused change, 
formatting and E2E
   validated locally). This is a test-only change: no production code, 
configuration default, REST/API
   or data format is modified.
   
   ## What this PR adds
   
   Adds `WorkerStartupBeforeMasterIT`, an E2E regression guard for the 
separated-cluster startup order
   in which a **worker (Hazelcast lite member) is launched before any master 
exists**.
   
   ## The contract
   
   The fixture is a real two-member in-JVM cluster with pinned ports and an 
explicit master address,
   exactly like a separated deployment:
   
   - the worker is started first on a fixed port; its `tcp-ip` member list 
points at the fixed address
     the master will occupy later, and that address is provably unbound at that 
moment;
   - the test waits one join retry interval, so the worker's first join attempt 
fails and the master
     address goes through the temporary blacklist before the master starts;
   - the master is then started on that exact address.
   
   The contract asserted end to end:
   
   1. the pre-started worker joins the cluster formed later by the master 
instead of shutting down
      after `hazelcast.max.join.seconds`; the cluster has both members;
   2. the worker never claimed mastership: exactly one member is non-lite and 
it is the node started
      second, while the worker stays a lite member;
   3. the master's `ResourceManager` registers the worker as a schedule target 
in fixed-slot mode;
   4. a job submitted afterwards is placed **on that worker**: the resource 
manager accounts for
      exactly its two fixed slots (split enumerator plus the fused source/sink 
task group), every slot
      points at the worker address, and the job stays `RUNNING` with the same 
two slot identities for
      a stability window;
   5. cancelling the job releases every slot on the worker, and the cluster 
still keeps both members;
      the worker is still registered.
   
   ## Why this is a boundary with real regression risk
   
   A lite member can never assume the master role, so its join loop differs 
from a normal member's:
   when the only candidate is unreachable or temporarily blacklisted it has to 
clear the temporary
   blacklist and keep retrying instead of claiming mastership. That is the 
regression fixed by
   #12755. Before that fix, a worker that missed its master once could never 
retry the address: it
   eventually shut down, or stayed out of the cluster while the master ran 
alone.
   
   None of that is visible from the job side. The master looks healthy, 
submissions succeed, the REST
   API answers, and jobs simply wait forever because no worker is ever 
registered. The failure appears
   only at process startup (Kubernetes pods, systemd units and rolling restarts 
can all start a worker
   before the first master), so every test that starts the master first is 
blind to it.
   
   ## Why the existing coverage does not reach it
   
   - `LiteNodeDropOutTcpIpJoinerTest` / `LiteNodeDropOutDiscoveryJoinerTest` 
(shipped with #12755)
     fabricate the joiner state in a unit test. They never start a real master, 
form a real cluster,
     register a resource-manager worker or schedule a job.
   - `WorkerTagClusterTest`, `TagFilterLateWorkerPlacementIT` and every 
split-cluster failover IT create
     the master first and only then the worker, so the worker-first join loop 
is never exercised.
   - `ClusterIT` uses the container-based suite and also starts the master side 
first.
   - No existing E2E asserts that a pre-started worker is registered as a 
schedule target and receives
     a job's slots, which is the observable engine symptom of the regression.
   
   ## Fixture and determinism
   
   - `WorkerStartupBeforeMasterIT` — real in-JVM master and worker, fixed 
ports, `dynamic-slot: false`,
     `slot-num: 5`, `ScheduleStrategy.WAIT`.
   - `worker-before-master/stream_fake_to_console_worker_bootstrap.conf` — one 
STREAMING
     `FakeSource -> Console` pipeline at parallelism 1 with 
`checkpoint.interval = 1000`. Both are plain
     test fixtures; no Transform, SQL semantics, connector or format behavior 
is exercised.
   
   The worker runs on its own daemon thread because Hazelcast blocks the 
creating thread until the
   member joins. The test waits until the worker's member socket accepts 
connections and asserts the
   master address is still unbound, then waits one join retry interval before 
launching the master, so
   "worker before master" is an observed fact and the failed attempt plus 
temporary blacklist are
   genuinely exercised rather than raced.
   
   ## Evidence
   
   - Green on `origin/dev` `1e7e29a75b` with the pristine `engine-server` jar 
(sha256
     `e3687ea6c3c4ebc9caffa94e8ad57c5d7dc5df90dcfa93ed219d91ce1339137a`): three 
consecutive targeted
     runs, `14.5 s`, `15.0 s` and `15.8 s`.
   - Negative control: making 
`LiteNodeDropOutTcpIpJoiner#retryTemporaryBlacklistedAddresses` return
     `false` without clearing the temporary blacklist makes the test fail after 
`123 s` with
     `All candidate master addresses are permanently blacklisted: 
[[localhost]:10072]; this lite member
     cannot retry them.` and `The worker started before the master did not join 
within 120s`. Mutation
     reverted, pristine jar reinstalled (same sha256), green runs repeated.
   - `spotless:check` exit 0, `ImportClassCheckTest` exit 0, `git diff --check` 
exit 0.
   - Run command:
     `mvn -o -pl 
seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base verify 
-DskipUT=true -DskipIT=false -Dit.test=WorkerStartupBeforeMasterIT 
-DfailIfNoTests=false`
   
   ## Does this PR introduce any user-facing change?
   
   No. Test-only change: one E2E class plus its fixture, no production or 
configuration change.
   
   ## Scope
   
   No issue is filed because the contract already holds on `dev` after #12755 
and the negative control
   shows the test fails when the temporary-blacklist retry is removed.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to