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

Add tests coverage for REST client reactive using HTTP2 #1637

Merged
merged 2 commits into from
Feb 13, 2024

Conversation

jedla97
Copy link
Member

@jedla97 jedla97 commented Feb 1, 2024

Summary

Adding test coverage for QUARKUS-658.

This cover basic scenarios which Quarkus users can use.

The http2ClientAsync and http2ClientSync which are removed is covered by new tests. In addition the class these test were using were also removed. The ones from http-advanced were removed completely as Quarkus doesn't plan to support the non-reactive client.

Please select the relevant options.

  • Bug fix (non-breaking change which fixes an issue)
  • Dependency update
  • Refactoring
  • Backport
  • New scenario (non-breaking change which adds functionality)
  • This change requires a documentation update
  • This change requires execution against OCP (use run tests phrase in comment)

Checklist:

  • Methods and classes used in PR scenarios are meaningful
  • Commits are well encapsulated and follow the best practices

@jedla97 jedla97 force-pushed the QUARKUS-658 branch 2 times, most recently from 37cc3d7 to ce004ca Compare February 1, 2024 11:02
@jedla97 jedla97 marked this pull request as ready for review February 1, 2024 11:03
@jedla97 jedla97 requested a review from jcarranzan February 1, 2024 11:04
@jedla97
Copy link
Member Author

jedla97 commented Feb 1, 2024

The HttpVersionAlpnWithConfigKeyIT.testAsyncResponseWithSingleClientOnSingleClient and HttpVersionAlpnWithConfigKeyIT.testSyncResponseWithSingleClientOnSingleClient are expected to fail because the quarkusio/quarkus#38514 but I PR for it is created and passing so it will be merged pretty soon.

Cookie test failing also on daily so it's not caused by this PR

@jcarranzan
Copy link
Contributor

The HttpVersionAlpnWithConfigKeyIT.testAsyncResponseWithSingleClientOnSingleClient and HttpVersionAlpnWithConfigKeyIT.testSyncResponseWithSingleClientOnSingleClient are expected to fail because the quarkusio/quarkus#38514 but I PR for it is created and passing so it will be merged pretty soon.

Cookie test failing also on daily so it's not caused by this PR

The issue is already closed so we can run again the tests

@jedla97
Copy link
Member Author

jedla97 commented Feb 2, 2024

The failing test are just cookies which will be fixed by #1639

Copy link
Contributor

@jcarranzan jcarranzan left a comment

Choose a reason for hiding this comment

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

Hi @jedla97, I've left some minor comments, but overall, the code looks good to me. Additionally, I was thinking that you might consider including a couple of tests that intentionally induce failures or check for the possibility of receiving a status code other than 200.
Thank you

@jedla97 jedla97 force-pushed the QUARKUS-658 branch 2 times, most recently from f13e12e to f84d112 Compare February 2, 2024 13:01
@jedla97
Copy link
Member Author

jedla97 commented Feb 2, 2024

Thanks for review @jcarranzan I update things which you have pointed out.

Additionally, I was thinking that you might consider including a couple of tests that intentionally induce failures or check for the possibility of receiving a status code other than 200.

In this I will try thing about negative scenario and if I have some idea I'll create standalone PR for it.
In case of checking for 200 status in tests.

It's there yous to check but not testing the client itself. The test calling endpoint where is the client created/injected and that endpoint calling another endpoint as rest client. So status in tests is there just to check that's response is as expected (client use/not use http2). If there will be some problem with client it should return 500.

@jedla97
Copy link
Member Author

jedla97 commented Feb 2, 2024

Just note why we can't use the rest client directly in test:

quarkusio/quarkus#25041

Tl;DR : At this moment quarkus rest client reactive is not meant to be used standalone.

@jedla97 jedla97 requested a review from jcarranzan February 5, 2024 13:15
Copy link
Contributor

@jcarranzan jcarranzan left a comment

Choose a reason for hiding this comment

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

Thank you for the tweaks, just only a comment about the MalformedURLException signature and I'll approve it.

Copy link
Member

@michalvavrik michalvavrik left a comment

Choose a reason for hiding this comment

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

I don't have time to review this right now (not that I was asked to :-D), but once this is approved please do not merge. There is a lot of changes (nothing against them!) and I'd like to check when I find a time. Thanks

Copy link
Member

@michalvavrik michalvavrik left a comment

Choose a reason for hiding this comment

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

This looks fine. @jcarranzan please have a look next week, review and merge. If you need more time, can you maybe create dedicated ticket for yourself in JIRA, please? Let's move on. Thx

import io.smallrye.mutiny.Uni;

@ApplicationScoped
@Path("/httpVersion")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@Path("/httpVersion")
@Path("/http-version")

That's usual convention, or are you testing whether it works with case sensitive path? If so, let's document.

@QuarkusScenario
public class HttpVersionAlpnWithConfigKeyIT {

String SUCCESSFUL_RESPONSE_STRING = "Hello " + NAME;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
String SUCCESSFUL_RESPONSE_STRING = "Hello " + NAME;
private static final String SUCCESSFUL_RESPONSE_STRING = "Hello " + NAME;

.build(HttpVersionClient.class);

Response response = httpVersionClient.getClientHttpVersionAsync(NAME).await()
.atMost(Duration.ofSeconds(TIMEOUT_SECONDS));
Copy link
Member

Choose a reason for hiding this comment

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

I think blocking here is just laziness, there is no point to it. Asynchronous test should be processed in a reactive manner and return stuff asynchronously from resource as well. Please feel free to prove me wrong. Thanks


/**
* Create HttpVersionClient and make REST client asynchronous request to `httpVersion/asynchronous endpoint`
* Response from the client is checked if http 2 was used
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Response from the client is checked if http 2 was used
* Response from the client is checked if HTTP/2 was used

please check other comments as well. As you have already decided to write nice Java doc.

@GET
@Path("synchronous")
public Response sayHello(@QueryParam("name") String name) {
return Response.ok("Hello " + name).build();
Copy link
Member

Choose a reason for hiding this comment

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

Hello is fine, you can keep it if you want as it tests query param. It would be nice to have incoming request protocol in response. This way, you can check that REST client is telling you a true about used HTTP version. I propose to inject RoutingContext, then io.vertx.ext.web.RoutingContext#request -> io.vertx.core.http.HttpServerRequest#version should always return HTTP_2.

@michalvavrik
Copy link
Member

@jedla97 let's add info about HTTP/2 for REST client into root project README

@jedla97
Copy link
Member Author

jedla97 commented Feb 13, 2024

@jcarranzan I update all the comments mentioned by @michalvavrik so can you have quick look. Also add mention of these test to the README.

@jcarranzan
Copy link
Contributor

Changes LGTM, and tests are correct as well. However I noticed the test classes seem to contain repetitive tests, and perhaps using inheritance could consolidate tests into a single class. Nonetheless, I respect the current approach, it's simply a different way of approaching the tests.
On the other hand, try to resolve the comments from Michal, still I can see some unresolved threads, thank you.

@jcarranzan
Copy link
Contributor

Changes LGTM, and tests are correct as well. However I noticed the test classes seem to contain repetitive tests, and perhaps using inheritance could consolidate tests into a single class. Nonetheless, I respect the current approach, it's simply a different way of approaching the tests.
On the other hand, try to resolve the comments from Michal, still I can see some unresolved threads, thank you.

@jedla97
Copy link
Member Author

jedla97 commented Feb 13, 2024

Thanks for review

However I noticed the test classes seem to contain repetitive tests, and perhaps using inheritance could consolidate tests into a single class

When writing the test I was thinking about it, but if we want one class as base for multiple tests there would be subset of 2 tests for all 4 tests classes.
When we would have 2 base classes the subset of test would be 4 (all https tests). So in the result we shouldn't have 4 classes but 6.

In my POV it's not that useful in this scenario.

On the other hand, try to resolve the comments from Michal, still I can see some unresolved threads, thank you.

I update the solution but sum it in one comment as I was resolve all the comment on code side (not GitHub side)

@jcarranzan jcarranzan merged commit 8abc157 into quarkus-qe:main Feb 13, 2024
7 checks passed
@fedinskiy fedinskiy mentioned this pull request Feb 16, 2024
9 tasks
@jedla97 jedla97 deleted the QUARKUS-658 branch December 10, 2024 12:17
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