Skip to content

Fix potentially flaky S3TransferManagerListenerTests #2801

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

Merged
merged 2 commits into from
Oct 28, 2021

Conversation

Bennett-Lynch
Copy link
Contributor

As they were previously written, these tests were subject to fail due to
the following reasons:

  1. The execution order of multiple CompletableFuture#whenComplete(..)
    calls is non-deterministic (unless the result of each one is chained
    together, in sequence)
  2. Therefore it was possible that the CompletableFuture associated
    with a transfer may be completed before or after
    TransferListener#transferComplete(..) was invoked
  3. While this is not problematic from a public API perspective, our
    tests assumed that the future completion meant all listeners had been
    exercised, which may not always be true

This change fixes the tests to instead await for the expected
interactions to occur, rather than await for the associated future to be
completed.

An alternative approach would be to sequence the multiple completion
stages together, guaranteeing that listeners are invoked before the
future is completed, but this may delay the completion of the future in
the event of longer-running listener implementations. It seems
preferable to favor immediate completion of the future.

License

  • I confirm that this pull request can be released under the Apache 2 license

As they were previously written, these tests were subject to fail due to
the following reasons:

1. The execution order of multiple `CompletableFuture#whenComplete(..)`
calls is non-deterministic (unless the result of each one is chained
together, in sequence)
2. Therefore it was possible that the `CompletableFuture` associated
with a transfer may be completed before or after
`TransferListener#transferComplete(..)` was invoked
3. While this is not problematic from a public API perspective, our
tests assumed that the future completion meant all listeners had been
exercised, which may not always be true

This change fixes the tests to instead await for the expected
interactions to occur, rather than await for the associated future to be
completed.

An alternative approach would be to sequence the multiple completion
stages together, guaranteeing that listeners are invoked before the
future is completed, but this may delay the completion of the future in
the event of longer-running listener implementations. It seems
preferable to favor immediate completion of the future.
@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug C 1 Bug
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 4 Code Smells

61.8% 61.8% Coverage
0.0% 0.0% Duplication

As they were previously written, these tests were subject to fail due to
the following reasons:

1. The execution order of multiple `CompletableFuture#whenComplete(..)`
calls is non-deterministic (unless the result of each one is chained
together, in sequence)
2. Therefore it was possible that the `CompletableFuture` associated
with a transfer may be completed before or after
`TransferListener#transferComplete(..)` was invoked
3. While this is not problematic from a public API perspective, our
tests assumed that the future completion meant all listeners had been
exercised, which may not always be true

This change fixes the tests to instead await for the expected
interactions to occur, rather than await for the associated future to be
completed.

An alternative approach would be to sequence the multiple completion
stages together, guaranteeing that listeners are invoked before the
future is completed, but this may delay the completion of the future in
the event of longer-running listener implementations. It seems
preferable to favor immediate completion of the future.
@Bennett-Lynch Bennett-Lynch merged commit b47d247 into aws:master Oct 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants