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

   Yes, I am contributing to Apache SeaTunnel. This change only adds end-to-end 
coverage to the Zeta engine E2E suite; no production code is modified and no 
user-facing behavior changes.
   
   ### What this adds
   
   `FinishedPipelineSlotReleaseIT` pins a scheduling/resource contract of the 
Zeta engine that no E2E observed before: **when one pipeline of a 
multi-pipeline batch job in a fixed-slot cluster finishes, its slots are 
returned to the pool and become usable immediately, while the job itself is 
still running its sibling pipeline.**
   
   The test uses one in-JVM Zeta node with `dynamic-slot: false`, `slot-num: 4` 
and `job-schedule-strategy: WAIT`, plus a test-only sink that counts rows per 
tag and can be parked before its first row:
   
   1. A holder job has two independent batch pipelines, two slots each (one 
source task + one sink task per pipeline), so it owns the whole pool. Its fast 
pipeline's writer is parked on a gate before its single row; its slow pipeline 
writes rows with a per-row sleep.
   2. A second job with one pipeline (two slots) is submitted while the holder 
owns all four slots. It must stay `PENDING`, and must not be admitted early.
   3. The gate is released. The fast pipeline reaches `FINISHED`, and its two 
slots must go back to the pool while the holder is still `RUNNING`: the waiting 
job must reach `FINISHED` and write its single row, the holder's slow pipeline 
must still be `RUNNING` and must still be producing rows, and the fast pipeline 
must have written exactly one row.
   4. A third job that needs the whole pool (source parallelism 3 + sink 
parallelism 1) is submitted while the holder's slow pipeline still owns two 
slots. It must stay `PENDING` for a continuous 8 s window (several `WAIT` 
scheduler passes), which proves the finish path released exactly the finished 
pipeline's two slots rather than the whole job's four.
   5. The holder is cancelled; the queued whole-pool job must then run to 
completion and write all nine rows, proving the remaining slots were returned 
as well.
   
   The assertions use the real client API (`getJobStatus`, `cancelJob`) plus 
the master's pipeline states; slot ownership is observed functionally through 
admission of the queued jobs, not through internal counters.
   
   ### Why this boundary has real regression risk
   
   `SubPlan#subPlanDone` is the only normal path that frees capacity before a 
job terminates: it calls `JobMaster#releasePipelineResource`, which returns the 
finished pipeline's `SlotProfile`s to the `ResourceManager` and removes only 
that pipeline's entry from `ownedSlotProfilesIMap`. A refactor that defers slot 
release to job cleanup, or that releases the job's complete slot map instead of 
the finished pipeline's map, is invisible in a single-pipeline job (the job 
ends immediately after that pipeline) and in every existing multi-pipeline test 
(they only observe failure/failover, where the whole job's resources are 
released or restored). The damage is only visible with a long-lived sibling 
pipeline: capacity is wasted for the remaining lifetime of the job, and the 
`WAIT` scheduler cannot admit work that fits into the released slots. The third 
job in the test additionally pins the other direction, an over-release: if the 
finished pipeline were released twice (or the whole job's slots
  were released), the whole-pool job would start while the slow sibling still 
owns slots, overcommitting the worker.
   
   ### Why existing coverage does not reach it
   
   - `SeaTunnelSlotIT` and the slot-accounting E2Es in this module only submit 
and cancel single-pipeline jobs.
   - `ClusterFaultToleranceIT` / `ClusterFaultToleranceTwoPipelineIT` exercise 
multi-pipeline jobs only through worker or master failure, where the whole 
job's resources are released or restored together.
   - `JobClientJobProxyIT#testNoDuplicatedReleaseSlot` only checks that no 
"wrong target release operation" is logged for a single-pipeline job.
   - `RejectStrategyCapacityBlockedJobIT` (open) covers `REJECT` against a 
holder job, not capacity released mid-life by a finished pipeline.
   
   No E2E observes the slots that become available when one pipeline of a 
still-running multi-pipeline job finishes.
   
   ### Implementation notes
   
   The test-only sink/factory/gate live under 
`org.apache.seatunnel.engine.e2e.pipelineslot`. The factory is registered with 
`@AutoService(Factory.class)` like the other test-tree sinks of this module, so 
the in-JVM cluster discovers it from the test classpath. Source and sink are 
only fixtures: FakeSource produces rows, the sink counts them and optionally 
holds/sleeps; no transform, SQL or connector semantics are exercised.
   
   ### How this was tested
   
   ```
   ./mvnw -o -pl 
seatunnel-engine/seatunnel-engine-server,seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base
 \
     -DskipUT=true -DskipIT=false -Dit.test=FinishedPipelineSlotReleaseIT 
-DfailIfNoTests=false verify
   ```
   
   Result: `Tests run: 1, Failures: 0, Errors: 0` on `origin/dev` `5cf050be3f`, 
with the test running against the reactor-built engine sources. Seven 
consecutive clean runs (four standalone, three with the engine reactor): 19.8 
s, 20.7 s, 21.0 s, 21.1 s, 20.9 s, 20.8 s, 21.1 s.
   
   ```
   ./mvnw -o -q -pl 
seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base spotless:apply  
 # then spotless:check exit 0
   ./mvnw -o -q -pl seatunnel-ci-tools -Dtest=ImportClassCheckTest 
-DfailIfNoTests=false test        # exit 0
   git diff --check                                                             
                     # exit 0
   ```
   
   Negative control: removing the `jobMaster.releasePipelineResource(this)` 
call from `SubPlan#subPlanDone` makes the test fail (`The holder job must still 
be RUNNING after its sibling pipeline finished ==> expected: <RUNNING> but was: 
<FINISHED>`): the waiting job could only start after the holder job ended, i.e. 
the slots were held for the whole job lifetime. The mutation was reverted and 
the final version passes on the pristine engine.
   
   ### Check list
   
   * [x] The change is test-only and does not touch connector or engine 
production code.
   * [ ] If any new Jar binary package adding in your PR, please add License 
Notice according [New License 
Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/developer/new-license.md)
   * [ ] If necessary, please update the documentation to describe the new 
feature.
   * [ ] If necessary, please update `incompatible-changes.md` to describe the 
incompatibility caused by this PR.
   


-- 
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