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

   Yes — I am contributing this change to **Apache SeaTunnel**, and I confirm 
it follows the project's contribution conventions (English 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 does
   
   Adds `CheckpointHistoryWindowIT#testHistoryWindowIsBoundedPerPipeline`, an 
end-to-end guard for the bounded per-pipeline checkpoint history window that 
the Zeta checkpoint monitor keeps 
(`seatunnel.engine.checkpoint.monitor-history-size`).
   
   The fixture is a single in-JVM Zeta node (`dynamic-slot: false`, `slot-num: 
12`, `ScheduleStrategy.WAIT`) configured with `monitor-history-size = 2`, 
running one real STREAMING job with two pipelines (two `FakeSource -> Console` 
pairs, `checkpoint.interval = 300`, `checkpoint.timeout = 60000`). The test 
requires that:
   
   1. Both pipelines complete more checkpoints than the window (at least four 
each), and every sample taken while the job keeps checkpointing observes 
**exactly** two history entries, never more — so the eviction path really runs 
instead of the window merely being filled once.
   2. The two retained entries are the two newest completed checkpoints of that 
pipeline, newest first, both `CHECKPOINT_TYPE` / `COMPLETED`, carrying the 
right job id and pipeline id.
   3. `latestCompleted` still points at the newest checkpoint even though older 
entries were evicted, and the cumulative completed counter stays larger than 
the window: eviction trims the display history only, not the job totals.
   4. The `inProgress` counter and list return to zero/empty at an idle 
checkpoint boundary; the history query filters (`pipelineId`, `status`, 
`limit`) read the same bounded window and return the newest entry first; a 
healthy run records no failed checkpoints.
   5. The window is **per pipeline**, not one shared bucket: the job-wide 
history and the aggregate `CheckpointMonitorService#getRetainedHistoryCount()` 
are both `2 * window`.
   6. The job stays `RUNNING` while the window rolls, and still cancels cleanly 
to `CANCELED`.
   
   Only `FakeSource` and the existing `Console` sink are used as fixtures; no 
transform, SQL, connector or format behavior is exercised.
   
   ### Why this boundary has real regression risk
   
   The history window is the only bound on the checkpoint overview entry, and 
the documentation warns that every checkpoint event rewrites that whole entry, 
so an unbounded history multiplies master CPU, network, backup traffic and heap 
with the **checkpoint count** rather than with the number of jobs. Three 
independent pieces must agree for the bound to hold:
   
   1. the master passes the configured `monitor-history-size` into 
`CheckpointMonitorService` once at startup,
   2. `PipelineCheckpointOverview#addHistory` evicts from the old end and keeps 
counters/latest pointers outside the window,
   3. the aggregate listener-maintained counters count retained history entries 
rather than jobs.
   
   Each failure mode is silent: checkpoints keep completing and the job keeps 
running, while the overview map grows without bound; or an operator sees one 
pipeline's checkpoints evict another pipeline's history because the window was 
shared; or the telemetry retained-history gauge reports a job count for a job 
that retains many entries. Only an assertion that rolls a live window 
end-to-end can catch it.
   
   ### Why the existing coverage does not reach it
   
   - `PipelineCheckpointOverviewTest` calls `addHistory` directly on a 
fabricated overview with a hand-picked window, so it cannot catch the startup 
configuration plumbing or a live scheduler that writes more entries than the 
window.
   - `RestApiIT#testCheckpointOverviewAndHistoryApi` fabricates entries through 
the monitor service and asserts the REST response shape.
   - The client-protocol history coverage (`CheckpointHistoryClientIT`, PR 
#13507) asserts ordering and filters on a live job using the default window of 
32, which the job never fills, and never inspects eviction or the aggregate 
count.
   - No existing test configures a small `monitor-history-size`, lets a real 
job roll the window on more than one pipeline, and then checks the retained 
entries plus the aggregate retained-history count.
   
   ### Negative control
   
   Setting the node to `monitor-history-size = window + 2` (4) while the test 
still asserts the window of 2 makes the test fail at the first sampled pipeline 
with `expected: <2> but was: <4>` and history `[4/COMPLETED, 3/COMPLETED, 
2/COMPLETED, 1/COMPLETED]`. This shows the assertion tracks the configured 
bound and a live, growing history rather than a hard-coded constant.
   
   ### Does this PR introduce any user-facing change?
   
   No. It only adds E2E regression coverage; engine behavior, configuration 
defaults and public APIs are untouched.
   
   ### How was this patch tested?
   
   ```bash
   JAVA_HOME=/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home \
     ./mvnw -o -q -pl 
seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base spotless:check
   
   JAVA_HOME=/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home \
     ./mvnw -o -pl 
seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base \
     -DskipUT=true -DskipIT=false -Dit.test=CheckpointHistoryWindowIT 
-DfailIfNoTests=false verify
   ```
   
   `spotless:check` passes, and `CheckpointHistoryWindowIT` passes in 7.9 s per 
run over three consecutive runs (plus the negative control above, which fails 
as expected).
   


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