Flink 1.15 - Fix flaky test that has implicit order dependency in TestFlinkTableSource#4697
Conversation
…stFlinkTableSource
|
cc @rdblue @openinx @stevenzwu @hililiwei @yittg this test is flaky (and technically always has been - but previously Flink was returning the records in a defined ordering). |
| Assert.assertEquals("Should have 1 record", 1, result.size()); | ||
| Assertions.assertThat(result) | ||
| .containsAnyElementsOf(expectedList) | ||
| .size().isEqualTo(1); |
There was a problem hiding this comment.
For people who cherry-pick, I'm not sure if this reordering is the best way to go about this.
I needed to use expectedList, so I just moved the test to be below the test that declares all 3 expected records of that table. Given that there are already multiple tests in this single test function, I think it should be fine.
There was a problem hiding this comment.
Not sure why we need the .size().isEqualTo(1); here when we checked that result.size() == 1 immediately before
RussellSpitzer
left a comment
There was a problem hiding this comment.
I think the check on result size is redundant, but other than that looks good.
Agreed. I left it in to make the changes as minimal as possible. I can remove it though. |
|
Thanks @kbendick for the patch! |
Some tests in Flink's
TestFlinkTableSourcehave been found to be order dependent.As the order of results on read is not defined (without an order by clause), most of the tests were fixed in c726b22
However, there is one test that has a
LIMIT 1that then asserts on the row, which could be any of 3 possible rows.As Flink happened to be returning the records in a stable manner prior to Flink 1.15, this test was passing. But in PR #4693, this test was discovered to occasionally fail, as
SELECT * .... LIMIT 1on a table with 3 results has no guarantee of which record will be returned.Failed execution output:
I've updated the test to assert that there is only one record, and that it is one of the 3 records in the table (which is assured by the previous query, which issues
SELECT * .. LIMIT 4with no filter and gets 3 records back).