Skip to content

[test] Try to Fix flaky tests with AI assistance#4444

Open
leonardBang wants to merge 26 commits into
apache:masterfrom
leonardBang:fix_flaky_tests
Open

[test] Try to Fix flaky tests with AI assistance#4444
leonardBang wants to merge 26 commits into
apache:masterfrom
leonardBang:fix_flaky_tests

Conversation

@leonardBang

Copy link
Copy Markdown
Contributor

Try to Fix flaky tests with AI assistance

@leonardBang

Copy link
Copy Markdown
Contributor Author

Stable enough for now, will organize commits and push later, would you like to take a look? @yuxiqian @lvyanquan

image

@leonardBang

Copy link
Copy Markdown
Contributor Author

latest CI passed again

@yuxiqian yuxiqian left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the great work, it's definitely an improvement on the status quo.

Just reviewed changes in MongoDB and Pipeline E2e and left some comments here.

void testWildcardSchemaTransform(boolean batchMode) throws Exception {
String startupMode = batchMode ? "snapshot" : "initial";
String runtimeMode = batchMode ? "BATCH" : "STREAMING";
int testParallelism = 1;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this case doesn't work in multiple parallelism mode?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will add parameterized test

waitUntilAnySpecificEvent(
"CreateTableEvent{tableId=DEBEZIUM.CUSTOMERS, schema=columns={`ID` BIGINT NOT NULL,`NAME` VARCHAR(255) NOT NULL,`ADDRESS` VARCHAR(1024),`PHONE_NUMBER` VARCHAR(512)}, primaryKeys=ID, options=()}",
"CreateTableEvent{tableId=DEBEZIUM.CUSTOMERS, schema=columns={`ID` DECIMAL(38, 0) NOT NULL,`NAME` VARCHAR(255) NOT NULL,`ADDRESS` VARCHAR(1024),`PHONE_NUMBER` VARCHAR(512)}, primaryKeys=ID, options=()}");
waitUntilCustomerInsert("DEBEZIUM.CUSTOMERS", 101, "user_1");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write these assertions in order?

Comment on lines +511 to +515
assertEqualsInAnyOrderWithAllowedDuplicateUpdatePair(
fetchedDataList,
TestValuesTableFactory.getRawResultsAsStrings("sink"),
collection0UpdateBefore,
collection0UpdateAfter);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion is really cryptic. IIUC it is basically asserting this:

assertThat(TestValuesTableFactory.getRawResultsAsStrings("sink"))
        .satisfiesAnyOf(
                actual -> assertThat(actual)
                        .containsExactlyInAnyOrderElementsOf(expected),
                actual -> assertThat(actual)
                        .containsExactlyInAnyOrderElementsOf(expectedWithRetryDuplicate));

waitUntilSpecificEvent(
"DataChangeEvent{tableId=DEBEZIUM.PRODUCTS, before=[107, rocks, box of assorted rocks, 5.3], after=[107, rocks, box of assorted rocks, 5.1], op=UPDATE, meta=()}");
waitUntilSpecificEvent(
"CreateTableEvent{tableId=DEBEZIUM.CUSTOMERS_1, schema=columns={`ID` BIGINT NOT NULL,`NAME` VARCHAR(255) NOT NULL,`ADDRESS` VARCHAR(1024),`PHONE_NUMBER` VARCHAR(512)}, primaryKeys=ID, options=()}");

@yuxiqian yuxiqian Jun 25, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original test case looks suspicious. Why DEBEZIUM.CUSTOMERS's primary key ID INT NOT NULL maps to a BIGINT and its value has changed from digits (ranges from 100 to 2000) to 171,798,691,841 or 0x2800000001?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. The 171798691841/842 values are not valid fixture IDs and should not be accepted as an alternative rendering of the customer primary key. That would make the assertion too loose and could hide a real data correctness issue.

I updated the test to assert the actual fixture IDs for the current pipeline e2e path, which uses the Oracle incremental snapshot source. The assertion now only keeps the BIGINT / DECIMAL(38, 0) schema alternative, because that is a schema type-rendering difference for Oracle INT / NUMBER, not a data value difference. If we need to cover legacy source behavior separately, we should add a source-specific assertion/test for that path instead of accepting different ID values in this incremental snapshot test.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it's a legit bug instead of some "alternative rendering" and should have been resolved in #4424. Better revert changes in this test case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch, rebase current PR

@leonardBang leonardBang force-pushed the fix_flaky_tests branch 4 times, most recently from 0fbc2c9 to 89a35ee Compare July 2, 2026 11:34
leonardBang and others added 6 commits July 3, 2026 22:41
leonardBang and others added 17 commits July 3, 2026 22:41
Restore Hudi schema-evolution coverage, keep Mongo snapshot assertions exact, and wait for stream handoff in p=1 cases so the flake fixes do not weaken what these tests prove. Also fail fast when checkpoint triggering targets a missing job instead of treating that as a startup transient.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The Iceberg pipeline E2E job in this matrix is not a streaming job, so forcing a checkpoint there fails before it proves anything about sink convergence. Drop the checkpoint trigger and keep the test's data assertions as the synchronization signal.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
leonardBang and others added 3 commits July 4, 2026 11:24
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants