Skip to content
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

fix: ensure proper cleanup of publisher in tests #310

Merged
merged 37 commits into from Aug 24, 2020

Conversation

hannahrogers-google
Copy link
Contributor

@hannahrogers-google hannahrogers-google commented Aug 7, 2020

Our PublisherImplTest is taking over 5 minutes to run because we are not properly shutting down the publisher/testChannel. This PR ensures everything is shutdown properly, and decreases the test time to 10 seconds. Additional details provided in #309.

Fixes #309 ☕️

Adding delivery attempt count to PubsubMessages as a message attribute,
and creating helper function to allow users to get the count without
knowing implementation details.
@google-cla google-cla bot added the cla: yes label Aug 7, 2020
@hannahrogers-google hannahrogers-google added kokoro:force-run and removed cla: yes labels Aug 7, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run label Aug 7, 2020
@google-cla google-cla bot added the cla: yes label Aug 7, 2020
@codecov
Copy link

@codecov codecov bot commented Aug 7, 2020

Codecov Report

Merging #310 into master will decrease coverage by 0.06%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #310      +/-   ##
============================================
- Coverage     79.28%   79.21%   -0.07%     
+ Complexity      319      318       -1     
============================================
  Files            21       21              
  Lines          2892     2892              
  Branches        155      155              
============================================
- Hits           2293     2291       -2     
- Misses          535      536       +1     
- Partials         64       65       +1     
Impacted Files Coverage Δ Complexity Δ
...ain/java/com/google/cloud/pubsub/v1/Publisher.java 87.50% <0.00%> (-0.50%) 45.00% <0.00%> (-1.00%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dda3079...35c2c6e. Read the comment docs.

@hannahrogers-google hannahrogers-google added the kokoro:force-run label Aug 7, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run label Aug 7, 2020

private void shutdownTestPublisher(Publisher publisher) throws InterruptedException {
publisher.shutdown();
fakeExecutor.advanceTime(Duration.ofSeconds(10));
Copy link
Member

@hongalex hongalex Aug 19, 2020

Choose a reason for hiding this comment

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

How was 10 seconds chosen? Specifically, how long does this test need to execute on average?

Copy link
Contributor Author

@hannahrogers-google hannahrogers-google Aug 20, 2020

Choose a reason for hiding this comment

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

The gax layer implements a Watchdog (https://github.com/googleapis/gax-java/blob/master/gax/src/main/java/com/google/api/gax/rpc/Watchdog.java) that periodically garbage collects idle streams. The check is scheduled at a fixed rate every 10 seconds. So, I chose 10 seconds to ensure that the watchdog check completes, otherwise we have to wait the full timeout.

@product-auto-label product-auto-label bot added the api: pubsub label Aug 21, 2020
@hannahrogers-google hannahrogers-google merged commit b2b2f86 into googleapis:master Aug 24, 2020
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub cla: yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants