Skip to content

Commit 077f638

Browse files
leonardBangclaude
andcommitted
[test][pipeline-e2e] Improve split wait matching and Iceberg checkpoint stability
Use substring-based split readiness waits so parallel pipeline tests stop blocking on exact log lines that never appear. Trigger a final checkpoint before the MySqlToIceberg end-to-end validation so the last incremental batch is committed before asserting full table contents. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 97ef460 commit 077f638

5 files changed

Lines changed: 32 additions & 10 deletions

File tree

flink-cdc-e2e-tests/flink-cdc-pipeline-e2e-tests/src/test/java/org/apache/flink/cdc/pipeline/tests/MySqlToIcebergE2eITCase.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717

1818
package org.apache.flink.cdc.pipeline.tests;
1919

20+
import org.apache.flink.api.common.JobID;
2021
import org.apache.flink.cdc.common.test.utils.TestUtils;
2122
import org.apache.flink.cdc.connectors.mysql.testutils.UniqueDatabase;
2223
import org.apache.flink.cdc.pipeline.tests.utils.PipelineTestEnvironment;
2324
import org.apache.flink.cdc.pipeline.tests.utils.TarballFetcher;
25+
import org.apache.flink.core.execution.CheckpointType;
2426

2527
import org.apache.hadoop.conf.Configuration;
2628
import org.apache.iceberg.CatalogUtil;
@@ -168,7 +170,9 @@ public void testSyncWholeDatabase() throws Exception {
168170
Path icebergCdcConnector = TestUtils.getResource("iceberg-cdc-pipeline-connector.jar");
169171
Path hadoopJar = TestUtils.getResource("flink-shade-hadoop.jar");
170172
Path mysqlDriverJar = TestUtils.getResource("mysql-driver.jar");
171-
submitPipelineJob(pipelineJob, mysqlCdcJar, icebergCdcConnector, mysqlDriverJar, hadoopJar);
173+
JobID jobId =
174+
submitPipelineJob(
175+
pipelineJob, mysqlCdcJar, icebergCdcConnector, mysqlDriverJar, hadoopJar);
172176
waitUntilJobRunning(Duration.ofSeconds(60));
173177
LOG.info("Pipeline job is running");
174178
validateSinkResult(
@@ -254,6 +258,7 @@ public void testSyncWholeDatabase() throws Exception {
254258
"112, Twelve, Lily, 2.14, null, null"));
255259

256260
recordsInIncrementalPhase = createChangesAndValidate(stat);
261+
getRestClusterClient().triggerCheckpoint(jobId, CheckpointType.CONFIGURED).get();
257262
} catch (SQLException e) {
258263
LOG.error("Update table for CDC failed.", e);
259264
throw e;

flink-cdc-e2e-tests/flink-cdc-pipeline-e2e-tests/src/test/java/org/apache/flink/cdc/pipeline/tests/SqlServerE2eITCase.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,8 @@ private void waitUntilStreamSplitReady(JobID jobId, int parallelism) throws Exce
212212
getRestClusterClient().triggerCheckpoint(jobId, CheckpointType.CONFIGURED).get();
213213
waitUntilSpecificEvent(
214214
jobManagerConsumer, "Snapshot split assigner is turn into finished status.");
215-
waitUntilSpecificEvent(
216-
jobManagerConsumer, "Assign split StreamSplit{splitId='stream-split'");
217-
waitUntilSpecificEvent(
218-
taskManagerConsumer,
219-
"Adding split(s) to reader: [StreamSplit{splitId='stream-split'");
215+
waitUntilLogContains(jobManagerConsumer, "Assign split StreamSplit{splitId='stream-split'");
216+
waitUntilLogContains(jobManagerConsumer, "for the stream split assignment.");
220217
}
221218

222219
private void waitUntilJobRunningFromClusterCli(JobID jobId, Duration timeout) throws Exception {

flink-cdc-e2e-tests/flink-cdc-pipeline-e2e-tests/src/test/java/org/apache/flink/cdc/pipeline/tests/TransformE2eITCase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,10 +1241,10 @@ private void waitUntilStreamSplitReady(JobID jobId, int parallelism) throws Exce
12411241
getRestClusterClient().triggerCheckpoint(jobId, CheckpointType.CONFIGURED).get();
12421242
waitUntilSpecificEvent(
12431243
jobManagerConsumer, "Snapshot split assigner is turn into finished status.");
1244-
waitUntilSpecificEvent(
1244+
waitUntilLogContains(
12451245
jobManagerConsumer,
12461246
"The enumerator assigns split MySqlBinlogSplit{splitId='binlog-split'");
1247-
waitUntilSpecificEvent(jobManagerConsumer, "for the binlog split assignment.");
1247+
waitUntilLogContains(jobManagerConsumer, "for the binlog split assignment.");
12481248
}
12491249

12501250
private void validateEventsWithPattern(String... patterns) throws Exception {

flink-cdc-e2e-tests/flink-cdc-pipeline-e2e-tests/src/test/java/org/apache/flink/cdc/pipeline/tests/UdfE2eITCase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,9 @@ private void waitUntilStreamSplitReady(JobID jobId, int parallelism) throws Exce
281281
getRestClusterClient().triggerCheckpoint(jobId, CheckpointType.CONFIGURED).get();
282282
waitUntilSpecificEvent(
283283
jobManagerConsumer, "Snapshot split assigner is turn into finished status.");
284-
waitUntilSpecificEvent(
284+
waitUntilLogContains(
285285
jobManagerConsumer,
286286
"The enumerator assigns split MySqlBinlogSplit{splitId='binlog-split'");
287-
waitUntilSpecificEvent(jobManagerConsumer, "for the binlog split assignment.");
287+
waitUntilLogContains(jobManagerConsumer, "for the binlog split assignment.");
288288
}
289289
}

flink-cdc-e2e-tests/flink-cdc-pipeline-e2e-tests/src/test/java/org/apache/flink/cdc/pipeline/tests/utils/PipelineTestEnvironment.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,4 +510,24 @@ protected void waitUntilSpecificEvent(ToStringConsumer consumer, String event)
510510
+ consumer.toUtf8String());
511511
}
512512
}
513+
514+
protected void waitUntilLogContains(ToStringConsumer consumer, String fragment)
515+
throws Exception {
516+
boolean result = false;
517+
long endTimeout = System.currentTimeMillis() + EVENT_WAITING_TIMEOUT.toMillis();
518+
while (System.currentTimeMillis() < endTimeout) {
519+
if (consumer.toUtf8String().contains(fragment)) {
520+
result = true;
521+
break;
522+
}
523+
Thread.sleep(1000);
524+
}
525+
if (!result) {
526+
throw new TimeoutException(
527+
"failed to get log fragment: "
528+
+ fragment
529+
+ " from stdout: "
530+
+ consumer.toUtf8String());
531+
}
532+
}
513533
}

0 commit comments

Comments
 (0)