-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flink - Fix flakey, order-dependent FlinkTableSource tests for Flink 1.14 #4635
Flink - Fix flakey, order-dependent FlinkTableSource tests for Flink 1.14 #4635
Conversation
a819468
to
57fde35
Compare
This is one of those cases where AssertJ could help with convenience checks like
|
Yeah adding a convenience function makes sense. |
Actually, it seems we do have the |
57fde35
to
5ab66c7
Compare
5ab66c7
to
8dc8866
Compare
Added a utility function In the interest of keeping the diff minimal, I didn't remove existing assertions on the size of the result (although that is checked by I also didn't update any of the results with only one element. If we want to do that, we can use Let me know if removing the (redundant) size checks is a good idea. I think so because in the case of a failure, we'll see the incorrect records instead of just the incorrect size but I opted to be conservative and change less code. |
Assert.assertEquals("Should produce the expected records", expectedList, resultExceed); | ||
assertSameElements(expectedList, resultExceed); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about keeping this description by Assertions.assertThat(...).as(...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For AssertJ, the assertion message is already pretty good. I updated one test so it would fail and here's the output I got. I think it's pretty clean / self explanatory.
java.lang.AssertionError:
Expecting:
[+I[1, iceberg, 10.0], +I[2, b, 20.0]]
to contain exactly in any order:
[+I[1, iceberg, 10.0]]
but the following elements were unexpected:
[+I[2, b, 20.0]]
With .as
before the containsExactlyInAnyOrderElementsOf
, here's the output. I don't personally think it provides much value.
java.lang.AssertionError: [should contain the same elements]
Expecting:
[+I[1, iceberg, 10.0], +I[2, b, 20.0]]
to contain exactly in any order:
[+I[1, iceberg, 10.0]]
but the following elements were unexpected:
[+I[2, b, 20.0]]
But I'm happy to add it if you think it does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should make the assertSameElements open(can be optional) for description.
For the case you mentioned, i think it didn't provide much value because the statement itself, not for all other descriptions.
WDYT @kbendick ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you mean add a description argument like assertSameElements(String errorMessage, List<Row> exepected, List<Row> actual)
?
I'm happy to add that as well as keep the original signature. I can't think of a place in the current file that it would be useful as they're all the same scenarios, but I'm happy to add it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added that signature in addition to the current one should anybody want to use it @yittg.
I can see how it would provide some benefit in some situations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @kbendick
When upgrading our Flink code for the upcoming Flink 1.15 release in #4553, it was discovered that there is a failing test: #4553 (comment)
Looking closer, the expected and actual results are the same, just in a different order.
Because we are not testing the ordering of records returned from the source here, using list comparison doesn't make sense and we can just use set comparison (with an initial size check) for any query that returns more than 1 record.
I have updated all queries in this test to use set comparison semantics as list comparison is inherently flakey.
I will port this over to Flink 1.15 in #4553 as that's where tests are failing (though we don't have any guarantee that they will pass at present in 1.14 and it's simply implementation specific that they do).
cc @openinx @yittg