-
Notifications
You must be signed in to change notification settings - Fork 3k
unit test should always verify mock invocation #5317
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
Conversation
aws/src/test/java/org/apache/iceberg/aws/s3/TestS3OutputStream.java
Outdated
Show resolved
Hide resolved
aws/src/test/java/org/apache/iceberg/aws/s3/TestS3OutputStream.java
Outdated
Show resolved
Hide resolved
|
Updated with recommendations, Thanks @RussellSpitzer |
aws/src/test/java/org/apache/iceberg/aws/s3/TestS3OutputStream.java
Outdated
Show resolved
Hide resolved
RussellSpitzer
left a comment
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 there are a few formatting issues remaining but other than that this is good to go. We need to revert all the changes which aren't directly related to the patch. I think the byte [] to byte[] is correct but we should separate that out into another patch. Since we are about to do a big programmatic style application soon it is probably best to just leave it as is for now.
Reverted formatting which was not part of the PR. Thanks! |
RussellSpitzer
left a comment
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 for the test improvement!
|
@RussellSpitzer @abmo-x, we have started seeing test failures in affected tests (I am not sure if they were there before). Could you help investigate? |
@aokolnychyi looks like the expected tmp staging file that gets created disappeared, this failure occurs before the mock gets invoked. Wondering what could be different in the test environment, the test works fine when ran locally both from cli and IDE. Do we run unit tests as part of the PR checks before its merged? wanted to check if this test passed in that build. |
|
Looks like it fails sporadically. I'll look into it tomorrow unless @RussellSpitzer gets to it first. |
|
Haven't taken a look yet but @abmo-x we do run the tests as you will see if you click the "details" on the merge note above. All tests passed at that time. |
|
It's possible this exception was occurring before and the test ignored it as the test was catching all exceptions before this change. Now we are explicitly checking for the exception to be of certain type with certain msg. Not sure if there is some race condition going on which causes file to be deleted on exit or some parallel test which is cleaning up the tmp dir |
|
Yeah it's failing for me too. https://github.com/apache/iceberg/runs/7571542364?check_suite_focus=true I'm also taking a look into it |
|
+1, I also observed this, have a possible RC, presently in case of any failure of completable future in iceberg/aws/src/main/java/org/apache/iceberg/aws/s3/S3OutputStream.java Lines 377 to 389 in 3d00780
Now when another completable future starts to read file for creating a request iceberg/aws/src/main/java/org/apache/iceberg/aws/s3/S3OutputStream.java Lines 323 to 328 in 3d00780
FileNotFound, and we expecting our injected runtime failure
here is a gist for repro consistently & complete stack trace : https://gist.github.com/singhpk234/4257ea980017db5704857c3c7cc2fd0b I think this PR of mine can fix this flakyness as well : #5366 |

current implementation only verifies mock invocation on an exception in catch block. This is flaky as the test won't verify if there are no failures, but we want to make sure the calls are made in the test.