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

chore: Shutdown and awaitTermination for showcase clients #1669

Merged
merged 21 commits into from Jun 6, 2023

Conversation

lqiu96
Copy link
Contributor

@lqiu96 lqiu96 commented May 9, 2023

Seeing error messages regarding orphaned channels and not cleaning up the queues for gRPC.
Error:

io.grpc.internal.ManagedChannelOrphanWrapper$ManagedChannelReference cleanQueue
SEVERE: *~*~*~ Previous channel ManagedChannelImpl{logId=23, target=localhost:7469} was not shutdown properly!!! ~*~*~*
    Make sure to call shutdown()/shutdownNow() and wait until awaitTermination() returns true.

Few changes in this PR:

  1. Create a single client to be used for each file (no longer for each test case).
  2. Run the tests sequentially to not overwhelm the showcase server
  3. await for the client to terminate (wait 10 seconds)

Fixes: #1680

@lqiu96 lqiu96 requested a review from blakeli0 May 9, 2023 14:11
@lqiu96 lqiu96 requested a review from a team as a code owner May 9, 2023 14:11
@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label May 9, 2023
@lqiu96 lqiu96 marked this pull request as draft May 9, 2023 14:36
@lqiu96 lqiu96 added the owlbot:run Add this label to trigger the Owlbot post processor. label May 9, 2023
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label May 9, 2023
@lqiu96
Copy link
Contributor Author

lqiu96 commented May 9, 2023

httpjsonClient.awaitTermination() does nothing as of now.

@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels May 9, 2023
@lqiu96 lqiu96 marked this pull request as ready for review May 9, 2023 21:52
@lqiu96 lqiu96 added the owlbot:run Add this label to trigger the Owlbot post processor. label May 9, 2023
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label May 9, 2023
grpcClient.awaitTermination(TestClientInitializer.AWAIT_TERMINATION_SECONDS, TimeUnit.SECONDS);

httpjsonClient.close();
httpjsonClient.awaitTermination(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This method is not implemented yet #1663

Copy link
Collaborator

@blakeli0 blakeli0 left a comment

Choose a reason for hiding this comment

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

Do we know why the deadline PR caused flakyness? The deadline PR should only affect http/json stuff in theory.

@lqiu96
Copy link
Contributor Author

lqiu96 commented May 9, 2023

Do we know why the deadline PR caused flakyness? The deadline PR should only affect http/json stuff in theory.

I believe it's just the addition of a bunch of tests added for the deadline PR. These tests run in parallel and the showcase server was never built for performance or for handling being spammed with retries. I added a bit of wait for the tests and have the tests run sequentially to try and help with the CI jobs.

Comment on lines 50 to 51
private static final ExecutorService DEFAULT_EXECUTOR =
InstantiatingExecutorProvider.newBuilder().build().getExecutor();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Static DEFAULT_EXECUTOR error'd out on the unit tests. Same executor was being used and it was shutdown after the first test.

Comment on lines -91 to -94
<configuration>
<forkCount>1C</forkCount>
<reuseForks>true</reuseForks>
</configuration>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Run the tests sequentially for now to see if it helps with the CI jobs.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we revert this change with the fix?

@lqiu96
Copy link
Contributor Author

lqiu96 commented May 12, 2023

I'll try to break this PR into two PRs (one for awaitTermination() implementation and another into showcase fixes). I tried to group them together since the new PR might fail the due to the flaky CI jobs.

@lqiu96
Copy link
Contributor Author

lqiu96 commented May 12, 2023

Separate PR created here: #1677

@lqiu96 lqiu96 added the owlbot:run Add this label to trigger the Owlbot post processor. label Jun 2, 2023
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jun 2, 2023
@sonarcloud
Copy link

sonarcloud bot commented Jun 5, 2023

[gapic-generator-java-root] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@sonarcloud
Copy link

sonarcloud bot commented Jun 5, 2023

[java_showcase_integration_tests] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@sonarcloud
Copy link

sonarcloud bot commented Jun 5, 2023

[java_showcase_unit_tests] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@blakeli0
Copy link
Collaborator

blakeli0 commented Jun 5, 2023

Few changes in this PR:

  1. Create a single client to be used for each file (no longer for each test case).
  2. Run the tests sequentially to not overwhelm the showcase server
  3. await for the client to terminate (wait 10 seconds)

1 and 3 sounds good to me, with both 1 and 3 in, I think we may not need 2 anymore.

@lqiu96
Copy link
Contributor Author

lqiu96 commented Jun 5, 2023

Few changes in this PR:

  1. Create a single client to be used for each file (no longer for each test case).
  2. Run the tests sequentially to not overwhelm the showcase server
  3. await for the client to terminate (wait 10 seconds)

1 and 3 sounds good to me, with both 1 and 3 in, I think we may not need 2 anymore.

I kept 2 in to help the server with any flakes (especially for the deadline tests that spam the server). The overall runtime increases from 45 seconds to ~2 minutes which I don't think is too bad. @blakeli0 Would you be fine with keeping this in for a few weeks to try and observe some CI stability. If this helps mitigate the issues, I can change it to be parallel again?

@blakeli0
Copy link
Collaborator

blakeli0 commented Jun 5, 2023

Few changes in this PR:

  1. Create a single client to be used for each file (no longer for each test case).
  2. Run the tests sequentially to not overwhelm the showcase server
  3. await for the client to terminate (wait 10 seconds)

1 and 3 sounds good to me, with both 1 and 3 in, I think we may not need 2 anymore.

I kept 2 in to help the server with any flakes (especially for the deadline tests that spam the server). The overall runtime increases from 45 seconds to ~2 minutes which I don't think is too bad. @blakeli0 Would you be fine with keeping this in for a few weeks to try and observe some CI stability. If this helps mitigate the issues, I can change it to be parallel again?

SGTM, with more showcase tests being added, we should revisit this soon though. CC: @burkedavison in case there is any concerns.

Copy link
Collaborator

@blakeli0 blakeli0 left a comment

Choose a reason for hiding this comment

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

LGTM if we can get a green light from Burke on changing the test to sequential.

@lqiu96 lqiu96 requested a review from burkedavison June 5, 2023 20:55
@burkedavison
Copy link
Contributor

SGTM. Could we create a "reminder" issue to revisit the parallel / sequential decision in a few weeks?

@lqiu96
Copy link
Contributor Author

lqiu96 commented Jun 6, 2023

SGTM. Could we create a "reminder" issue to revisit the parallel / sequential decision in a few weeks?

Yep. I will revisit this July 6th.

@lqiu96 lqiu96 merged commit e78b267 into main Jun 6, 2023
18 checks passed
@lqiu96 lqiu96 deleted the main-shutdown_showcase_tests branch June 6, 2023 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: l Pull request size is large.
Projects
None yet
3 participants