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: change to generation script in manipulating googleapis/WORKSPACE. #3120

Merged
merged 5 commits into from
Aug 14, 2024

Conversation

zhumin8
Copy link
Contributor

@zhumin8 zhumin8 commented Aug 14, 2024

Need this adjustment due to changes in googleapis/WORKSPACE change here.

To fix:
Spring Auto Generation is failing: https://github.com/GoogleCloudPlatform/spring-cloud-gcp/actions/runs/10376314314

[INFO] Scanning for projects...
Error: ] Some problems were encountered while processing the POMs:
Error:  Child module /home/runner/work/spring-cloud-gcp/spring-cloud-gcp/spring-cloud-previews/google-cloud-workstations-spring-starter of /home/runner/work/spring-cloud-gcp/spring-cloud-gcp/spring-cloud-previews/pom.xml does not exist @ 
Error:  Child module /home/runner/work/spring-cloud-gcp/spring-cloud-gcp/spring-cloud-previews/google-cloud-workflows-spring-starter of /home/runner/work/spring-cloud-gcp/spring-cloud-gcp/spring-cloud-previews/pom.xml does not exist @ 
Error:  Child module /home/runner/work/spring-cloud-gcp/spring-cloud-gcp/spring-cloud-previews/google-cloud-workflow-executions-spring-starter of /home/runner/work/spring-cloud-gcp/spring-cloud-gcp/spring-cloud-previews/pom.xml does not exist @ 
...

Root cause is due to location change of maven_install target in WORKSPACE, the substitution is done with sed command targeting after a previous line. This is not the right place to have this maven_install target anymore because it needs to come after these lines.

Generation process tested successfully in local.

Also added in this pr:

@zhumin8 zhumin8 requested a review from a team as a code owner August 14, 2024 14:17
@zhumin8 zhumin8 requested a review from lqiu96 August 14, 2024 14:18
@@ -91,7 +91,7 @@ function modify_workspace_file(){
# delete existing maven_install rules
buildozer 'delete' ${path_to_workspace}:%maven_install
# add custom maven_install rules
perl -pi -e "s{(^_gapic_generator_java_version[^\n]*)}{\$1\n$(cat ${path_to_modification_string})}" ${path_to_workspace}
perl -pi -e "s{(^api_dependencies()[^\n]*)}{\$1\n$(cat ${path_to_modification_string})}" ${path_to_workspace}
Copy link
Contributor

Choose a reason for hiding this comment

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

qq, is this adding the bazel rule to the lines after api_dependencies()?

@lqiu96
Copy link
Contributor

lqiu96 commented Aug 14, 2024

I think the changes make sense and LGTM. I think @blakeli0 should give the final approval since he may have more context regarding the original WORKSPACE changes.

@lqiu96 lqiu96 requested a review from blakeli0 August 14, 2024 14:40
@zhumin8
Copy link
Contributor Author

zhumin8 commented Aug 14, 2024

Build error was fixed. but observing showcase unit test failures.

Error:  com.google.showcase.v1beta1.spring.EchoAutoConfigurationTests.testCustomTransportChannelProviderUsedWhenProvided -- Time elapsed: 0.042 s <<< ERROR!
java.lang.IllegalStateException: Unstarted application context 

... ...
Caused by: java.lang.NullPointerException: Cannot invoke "com.google.api.gax.rpc.ApiCallContext.withStreamWaitTimeoutDuration(java.time.Duration)" because the return value of "com.google.api.gax.rpc.ApiCallContext.withStreamIdleTimeoutDuration(java.time.Duration)" is null

More investigation needed, but at first glance, this error message referencing time.Duration looks suspicious, and may need spring generator changes to fix.

Update: it is the testing mocks that's affected. Will add a fix soon.

@@ -196,8 +196,8 @@ void testCustomTransportChannelProviderUsedWhenProvided() throws IOException {
// TransportChannelProvider bean
when(mockApiCallContext.withCredentials(any())).thenReturn(mockApiCallContext);
when(mockApiCallContext.withTransportChannel(any())).thenReturn(mockApiCallContext);
when(mockApiCallContext.withStreamWaitTimeout(any())).thenReturn(mockApiCallContext);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there going to be errors if we don't mock the behaviors of ApiCallContext? I guess somewhere in the client initialization logic these lines are called?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, removing will cause errors (the same ones we observe in the ci before this fix).
However, for the purpose of this test, instead of creating the mockTransportChannelProvider, I think it is also okay to create a real channelProvider and test it is actually used. The benefit is we free ourselves from implementation detail changes in the future.

E.g.

      InstantiatingGrpcChannelProvider channelProvider = InstantiatingGrpcChannelProvider
              .newBuilder()
              .setEndpoint("localhost:7469")
              .setMaxInboundMessageSize(Integer.MAX_VALUE)
              .build();


InstantiatingGrpcChannelProvider channelProvider =
InstantiatingGrpcChannelProvider.newBuilder()
.setEndpoint("localhost:7469")
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these two fields required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nope. I can remove that

InstantiatingGrpcChannelProvider.newBuilder()
.setEndpoint("localhost:7469")
.setMaxInboundMessageSize(Integer.MAX_VALUE)
.build();
contextRunner
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To @lqiu96 's concerns about resource closing from offline discussion:
Yes, createChannel() is actually called in this test. But Spring's ApplicationContextRunner (contextRunner in this test) is actually responsible of managing and closing all beans and data sources it manages.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, gotcha. Thanks for checking!

Copy link

@lqiu96
Copy link
Contributor

lqiu96 commented Aug 14, 2024

Thanks @zhumin8 and @blakeli0. I'm going to merge this in as this was a blocker for the Spring release. I'll merge and kick off the autogen

@lqiu96 lqiu96 merged commit 48e0681 into main Aug 14, 2024
73 of 77 checks passed
@lqiu96 lqiu96 deleted the fix-codegen branch August 14, 2024 21:30
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.

3 participants