-
Notifications
You must be signed in to change notification settings - Fork 18
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
feat: Java callout server WIP #81
base: main
Are you sure you want to change the base?
Conversation
callouts/java/service-callout/src/main/java/service/HealthCheckServer.java
Outdated
Show resolved
Hide resolved
callouts/java/service-callout/src/main/java/service/ServiceCallout.java
Outdated
Show resolved
Hide resolved
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.
Good work so far, examples look promising. It's starting to come together.
callouts/java/service-callout/src/main/java/example/add_body/AddBody.java
Outdated
Show resolved
Hide resolved
callouts/java/service-callout/src/main/java/example/add_body/AddBody.java
Outdated
Show resolved
Hide resolved
callouts/java/service-callout/src/main/java/example/add_header/AddHeader.java
Outdated
Show resolved
Hide resolved
callouts/java/service-callout/src/main/java/service/HealthCheckServer.java
Outdated
Show resolved
Hide resolved
callouts/java/service-callout/src/main/java/service/ServiceCallout.java
Outdated
Show resolved
Hide resolved
callouts/java/service-callout/src/main/java/service/ServiceCallout.java
Outdated
Show resolved
Hide resolved
callouts/java/service-callout/src/main/java/service/ServiceCallout.java
Outdated
Show resolved
Hide resolved
callouts/java/service-callout/src/main/java/service/ServiceCallout.java
Outdated
Show resolved
Hide resolved
callouts/java/service-callout/src/main/java/service/ServiceCalloutTools.java
Outdated
Show resolved
Hide resolved
callouts/java/service-callout/src/main/java/service/ServiceCalloutTools.java
Outdated
Show resolved
Hide resolved
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 left a few comments outlining what I see as where we may need to go with following standard java practices. I need to get some confirmation on some of the changes I suggested but this is what we may need to do.
callouts/java/service-callout/src/main/java/service/ServiceCallout.java
Outdated
Show resolved
Hide resolved
callouts/java/service-callout/src/main/java/service/ServiceCallout.java
Outdated
Show resolved
Hide resolved
callouts/java/service-callout/src/main/java/service/ServiceCalloutTools.java
Outdated
Show resolved
Hide resolved
callouts/java/service-callout/src/main/java/service/ServiceCallout.java
Outdated
Show resolved
Hide resolved
callouts/java/service-callout/src/test/java/example/BasicCalloutServerTest.java
Outdated
Show resolved
Hide resolved
assertTrue(headersResponse.getResponse().getHeaderMutation().getSetHeadersList().stream() | ||
.anyMatch(header -> header.getHeader().getKey().equals("request-header") | ||
&& header.getHeader().getValue().equals("added-request"))); | ||
assertTrue(headersResponse.getResponse().getHeaderMutation().getSetHeadersList().stream() | ||
.anyMatch(header -> header.getHeader().getKey().equals("c") | ||
&& header.getHeader().getValue().equals("d"))); | ||
assertTrue(headersResponse.getResponse().getClearRouteCache()); |
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.
[nit] If you would like to assert on protos check out ProtoTruth: usage. It allows comparing actual proto with expected, ignoring fields etc.
callouts/java/service-callout/src/main/java/example/AddHeader.java
Outdated
Show resolved
Hide resolved
callouts/java/service-callout/src/main/java/service/ServiceCallout.java
Outdated
Show resolved
Hide resolved
callouts/java/service-callout/src/main/java/service/ServiceCallout.java
Outdated
Show resolved
Hide resolved
callouts/java/service-callout/src/main/java/service/ServiceCallout.java
Outdated
Show resolved
Hide resolved
callouts/java/service-callout/src/main/java/example/Redirect.java
Outdated
Show resolved
Hide resolved
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.
Assorted fixes, let me know if anything doesn't make sense.
callouts/java/service-callout/src/main/java/service/ServiceCallout.java
Outdated
Show resolved
Hide resolved
callouts/java/service-callout/src/main/java/service/ServiceCalloutTools.java
Outdated
Show resolved
Hide resolved
callouts/java/service-callout/src/main/java/service/ServiceCalloutTools.java
Outdated
Show resolved
Hide resolved
callouts/java/service-callout/src/main/java/service/ServiceCalloutTools.java
Outdated
Show resolved
Hide resolved
if (add != null) { | ||
headerBuilder.addAllSetHeaders(add); | ||
} | ||
if (remove != null) { | ||
headerBuilder.addAllRemoveHeaders(remove); | ||
} | ||
if (clearRouteCache != null) { | ||
responseBuilder.setClearRouteCache(clearRouteCache); | ||
} |
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.
return headersResponseBuilder;
callouts/java/service-callout/src/main/java/service/ServiceCalloutTools.java
Outdated
Show resolved
Hide resolved
if (body != null) { | ||
bodyBuilder.setBody(ByteString.copyFromUtf8(body)); | ||
} | ||
if (clearBody != null) { | ||
bodyBuilder.setClearBody(clearBody); | ||
} |
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.
We can do something similar to https://github.com/GoogleCloudPlatform/service-extensions/blob/main/callouts/python/extproc/service/callout_tools.py#L149-L161.
callouts/java/service-callout/src/main/java/service/ServiceCalloutTools.java
Outdated
Show resolved
Hide resolved
callouts/java/service-callout/src/main/java/service/ServiceCalloutTools.java
Outdated
Show resolved
Hide resolved
callouts/java/service-callout/src/main/java/service/ServiceCalloutTools.java
Outdated
Show resolved
Hide resolved
…the basic callout test
# Conflicts: # callouts/java/service-callout/src/main/java/service/ServiceCallout.java
@jstraceski Tried a different approach for the BasicCallout tests, let me know if that covers what we discussed
|
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.
Apologies for the hiatus, awesome work! mainly just some default configuration asks and a few test changes.
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.
Is this testing change intended for this pr?
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.
Yes, this change is intended for this PR.
What I did here is to split the docs part so we can address the javadoc generation, in this case we will have separated workflows:
- Java
- Python
- GO (which is not included here)
- Common doc files
The initial workflow was made to erase all the files inside the gh-pages folder and publish again, so with the current setup once we make a change into python or java sdk we are going to lose one or the other, splitting the workflows like this is going to fix this problem.
I made an example run with all of them running in the link below in another branch, you can check how it will look like:
They are named "Testing all 3 workflow"
https://github.com/pweiber/service-extensions-samples/actions
And you can check the results here in my gh-pages branch:
https://github.com/pweiber/service-extensions-samples/tree/gh-pages
If you want to do more tests let me know
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.
The format of the tests looks generally good but for the most recent tests I see the output:
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.272 sec
Running example.JwtAuthTest
[main] INFO example.JwtAuth - Header: Authorization = <ByteString@167279d1 size=19 contents="***">
[main] ERROR example.JwtAuth - JWT processing error: JWT strings must contain exactly 2 period characters. Found: 0
It looks like an error is being encountered but is not counted?
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.
That's expected since we are testing an invalid scenario (testHandleRequestHeaders_InvalidToken) it shows that output, I believe we are fine in this case
callouts/java/service-callout/src/main/java/service/ServiceCallout.java
Outdated
Show resolved
Hide resolved
callouts/java/service-callout/src/main/java/service/ServiceCallout.java
Outdated
Show resolved
Hide resolved
callouts/java/service-callout/src/main/java/service/ServiceCallout.java
Outdated
Show resolved
Hide resolved
callouts/java/service-callout/src/main/java/service/ServiceCallout.java
Outdated
Show resolved
Hide resolved
callouts/java/service-callout/src/main/java/service/ServiceCallout.java
Outdated
Show resolved
Hide resolved
callouts/java/service-callout/src/test/java/example/RedirectTest.java
Outdated
Show resolved
Hide resolved
Signed-off-by: pweiber <[email protected]>
Signed-off-by: pweiber <[email protected]>
Signed-off-by: pweiber <[email protected]>
@jstraceski I still can't mark as resolved the comments so let me know if the changes are fine |
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.
Just one more change then I think we should be good to merge.
this.healthCheckIp = Optional.ofNullable(builder.healthCheckIp).orElse("0.0.0.0"); | ||
this.healthCheckPort = Optional.ofNullable(builder.healthCheckPort).orElse(80); | ||
this.healthCheckPath = Optional.ofNullable(builder.healthCheckPath).orElse("/"); | ||
this.combinedHealthCheck = Optional.ofNullable(builder.combinedHealthCheck).orElse(true); |
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.
This should be .orElse(false);
the health check server should be on by default. Apologies if I wasn't clear before.
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.
Done, should be good now
Signed-off-by: pweiber <[email protected]>
Adding a java callout server SDK.