[FLINK-40098][test-utils] Add FailingCheckpointedSource for exactly-once source tests#28686
[FLINK-40098][test-utils] Add FailingCheckpointedSource for exactly-once source tests#28686MartijnVisser wants to merge 2 commits into
Conversation
…nce source tests Replaces the fail-once-and-recover semantics of the legacy SourceFunction-based FailingSource with a Source V2 utility Generated-by: Claude Code (Fable 5)
… Source V2 Replaces the legacy FailingSource with FailingCheckpointedSource, pinned to parallelism 1 like the implicitly non-parallel legacy source. KeyedEventTimeGenerator implements both generator interfaces until the remaining FailingSource consumers are migrated. Generated-by: Claude Code (Fable 5)
Efrat19
left a comment
There was a problem hiding this comment.
Thanks!
Generally LGTM % A little concern about the >500 lines here introduced to replace the 150-lines legacy FailingSource 😅 so most notes are focused on dead code for maintainability
| } | ||
|
|
||
| /** Determines whether and when the source fails. */ | ||
| public static final class FailurePolicy implements Serializable { |
There was a problem hiding this comment.
IMO FailurePolicy is a little bit of overengineering as we don't need FailingCheckpointedSource failure customization anywhere
and it also adds complexity bc a so called FailingCheckpointedSource doesn't guarantee failure.
I'd use FailingCheckpointedSource properties instead
| * Returns a copy of this source that stays idle after emitting all sequence numbers instead of | ||
| * finishing, for processing-time tests whose job is terminated externally. | ||
| */ | ||
| public FailingCheckpointedSource<T> withIdleAfterEmission() { |
| * Only for validating that a test detects exactly-once violations; never use in a test's normal | ||
| * path. | ||
| */ | ||
| public FailingCheckpointedSource<T> withSimulatedStateLossOnRecovery() { |
| @Nullable private ReaderOutput<T> delegate; | ||
|
|
||
| @Override | ||
| public void collect(T record) { |
| private final FailurePolicy failurePolicy; | ||
| private final TypeInformation<T> producedType; | ||
| private final boolean idleAfterEmission; | ||
| private final boolean simulateStateLossOnRecovery; |
There was a problem hiding this comment.
idleAfterEmission and simulateStateLossOnRecovery flags are never actually turned on and only complicate FailingCheckpointedSourceReader logic, I'd introduce them along with their usage (which is probably never bc the legacy FailingSource also didn't support them)
| * parallelism. | ||
| */ | ||
| @Experimental | ||
| public class SequenceSplit implements SourceSplit { |
There was a problem hiding this comment.
Nit: move into FailingCheckpointedSource?
| * from the checkpointed position after recovery. The subtask index assumes a fixed source | ||
| * parallelism. | ||
| */ | ||
| @Experimental |
There was a problem hiding this comment.
Make package-private instead of Experimental/public?
What is the purpose of the change
FLINK-32695 migrates test code off the deprecated
SourceFunctionAPI to Source V2 (FLIP-27). Roughly 15 checkpointing ITCases depend on a legacyFailingSourcepattern: a source with a checkpointed position that fails exactly once after a completed checkpoint and resumes from the restored position. No Source V2 test utility offered these semantics.This PR adds
FailingCheckpointedSourcetoflink-test-utils-connectorand migratesEventTimeAllWindowCheckpointingITCaseas the first consumer. The remaining consumers follow in separate PRs under the umbrella.Brief change log
FailingCheckpointedSource+SequenceSplit(a position-carrying split) toflink-test-utils-connector:SourceReaderContextexposes no attempt number).withSimulatedStateLossOnRecovery()exists purely so consuming tests can validate that they still detect exactly-once violations. Rescaling is unsupported (documented).EventTimeAllWindowCheckpointingITCaseoffFailingSource.KeyedEventTimeGenerator(in the not-yet-migratedEventTimeWindowCheckpointingITCase) temporarily implements both generator interfaces so it can be shared; that file is touched only for this reason.Verifying this change
FailingCheckpointedSourceTestcover the failure protocol, arming threshold, abort re-arm, restore-without-refailing, enumerator assignment/regression paths, and the serializer.EventTimeAllWindowCheckpointingITCasepasses 4/4.withSimulatedStateLossOnRecovery()temporarily wired in,testTumblingTimeWindowfails on duplicated window sums (e.g.[Window start: 1300 end: 1400] expected: 134950), proving the migrated test still detects exactly-once violations. Reverted afterwards.Notes for reviewers
@Experimentalflink-core's test-jar is added as a test-scope dependency offlink-test-utils-connector(forMockSplitEnumeratorContext).Does this pull request potentially affect one of the following parts:
@Public(Evolving): no (new classes are@Experimental, test-scoped)Documentation
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Fable 5