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

feat: Java callout server WIP #81

Open
wants to merge 56 commits into
base: main
Choose a base branch
from

Conversation

vitor-ciandt
Copy link
Contributor

Adding a java callout server SDK.

@vitor-ciandt vitor-ciandt requested review from a team as code owners May 14, 2024 21:09
Copy link
Contributor

@jstraceski jstraceski left a 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.

Copy link
Contributor

@jstraceski jstraceski left a 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.

@jstraceski jstraceski requested review from martijneken and removed request for martijneken July 10, 2024 12:46
@jstraceski jstraceski assigned jstraceski and unassigned jstraceski Jul 10, 2024
Comment on lines 40 to 46
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());

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.

Copy link
Contributor

@jstraceski jstraceski left a 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.

Comment on lines 73 to 81
if (add != null) {
headerBuilder.addAllSetHeaders(add);
}
if (remove != null) {
headerBuilder.addAllRemoveHeaders(remove);
}
if (clearRouteCache != null) {
responseBuilder.setClearRouteCache(clearRouteCache);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

return headersResponseBuilder;

Comment on lines 101 to 106
if (body != null) {
bodyBuilder.setBody(ByteString.copyFromUtf8(body));
}
if (clearBody != null) {
bodyBuilder.setClearBody(clearBody);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

@pweiber
Copy link
Contributor

pweiber commented Oct 14, 2024

@jstraceski Tried a different approach for the BasicCallout tests, let me know if that covers what we discussed

  • JWT UC added
  • Removed unused certs
  • Added back the health check

Copy link
Contributor

@jstraceski jstraceski left a 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.

Copy link
Contributor

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?

Copy link
Contributor

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

Copy link
Contributor

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?

Copy link
Contributor

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

@pweiber
Copy link
Contributor

pweiber commented Jan 8, 2025

@jstraceski I still can't mark as resolved the comments so let me know if the changes are fine

Copy link
Contributor

@jstraceski jstraceski left a 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);
Copy link
Contributor

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.

Copy link
Contributor

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

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.

5 participants