Skip to content

Commit

Permalink
Merge pull request #1637 from jedla97/QUARKUS-658
Browse files Browse the repository at this point in the history
Add tests coverage for REST client reactive using HTTP2
  • Loading branch information
jcarranzan authored Feb 13, 2024
2 parents a4de972 + de3936d commit 8abc157
Show file tree
Hide file tree
Showing 24 changed files with 554 additions and 312 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,12 @@ This module will setup a very minimal configuration (only `quarkus-resteasy`) an
Reactive equivalent of the http/rest-client module.
Exclusions: XML test. Reason: https://quarkus.io/blog/resteasy-reactive/#what-jax-rs-features-are-missing

Additionally, it's include endpoints to check usage of HTTP/2 using REST client over the http and https.
HTTP/2 REST client tests check sync and async response by:
- Two endpoint used by client
- Eight endpoints used for validation of client request


### `http/rest-client-reactive-vanilla`
Verifies Rest Client usage, while no request are going only internally on the server.
This module requires to not have any resteasy dependency, for an issue to be reproducible.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@ HealthClientService/mp-rest/url=http://localhost:${quarkus.http.port}
HealthClientService/mp-rest/scope=jakarta.inject.Singleton
# FollowRedirect not supported QUARKUS-781
# HealthClientService/mp-rest/followRedirects=true
HttpVersionClientService/mp-rest/url=https://localhost:${quarkus.http.ssl-port}
HttpVersionClientService/mp-rest/scope=jakarta.inject.Singleton
HttpVersionClientService/mp-rest/hostnameVerifier=io.quarkus.restclient.NoopHostnameVerifier
HttpVersionClientService/mp-rest/trustStore=classpath:/META-INF/resources/server.truststore
HttpVersionClientService/mp-rest/trustStorePassword=password
HttpVersionClientServiceAsync/mp-rest/url=https://localhost:${quarkus.http.ssl-port}
HttpVersionClientServiceAsync/mp-rest/scope=jakarta.inject.Singleton
HttpVersionClientServiceAsync/mp-rest/hostnameVerifier=io.quarkus.restclient.NoopHostnameVerifier
HttpVersionClientServiceAsync/mp-rest/trustStore=classpath:/META-INF/resources/server.truststore
HttpVersionClientServiceAsync/mp-rest/trustStorePassword=password
# gRPC
quarkus.grpc.clients.hello.host=localhost
quarkus.grpc.clients.hello.port=${quarkus.http.port}
Expand All @@ -43,8 +33,6 @@ quarkus.keycloak.policy-enforcer.paths.swagger-ui.path=/api/swagger-ui/*
quarkus.keycloak.policy-enforcer.paths.swagger-ui.enforcement-mode=DISABLED
quarkus.keycloak.policy-enforcer.paths.health.path=/api/health/*
quarkus.keycloak.policy-enforcer.paths.health.enforcement-mode=DISABLED
quarkus.keycloak.policy-enforcer.paths.version.path=/api/httpVersion/*
quarkus.keycloak.policy-enforcer.paths.version.enforcement-mode=DISABLED
# Application endpoints
quarkus.keycloak.policy-enforcer.paths.99-bottles-of-beer.path=/api/99-bottles-of-beer/*
quarkus.keycloak.policy-enforcer.paths.99-bottles-of-beer.enforcement-mode=DISABLED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@

import org.apache.http.HttpStatus;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
Expand All @@ -74,9 +73,6 @@
import io.quarkus.test.bootstrap.RestService;
import io.quarkus.test.scenarios.annotations.DisabledOnNative;
import io.quarkus.test.scenarios.annotations.EnabledOnQuarkusVersion;
import io.quarkus.ts.http.advanced.reactive.clients.HttpVersionClientService;
import io.quarkus.ts.http.advanced.reactive.clients.HttpVersionClientServiceAsync;
import io.quarkus.ts.http.advanced.reactive.clients.RestClientServiceBuilder;
import io.restassured.http.Header;
import io.restassured.response.ValidatableResponse;
import io.smallrye.mutiny.Uni;
Expand All @@ -96,7 +92,6 @@ public abstract class BaseHttpAdvancedReactiveIT {
private static final int RETRY = 3;
private static final String PASSWORD = "password";
private static final String KEY_STORE_PATH = "META-INF/resources/server.keystore";
private static final int ASSERT_TIMEOUT_SECONDS = 10;
private static final String UTF_8_CHARSET = ";charset=UTF-8";
private static final String CONTENT = "content";

Expand Down Expand Up @@ -235,33 +230,6 @@ public void http2Server() throws InterruptedException, URISyntaxException {
assertThat(done.getCount(), equalTo(0L));
}

@Test
@DisplayName("Http/2 Client Sync test")
@Disabled("blocked by: https://issues.redhat.com/browse/QUARKUS-658")
public void http2ClientSync() throws Exception {
HttpVersionClientService versionHttpClient = new RestClientServiceBuilder<HttpVersionClientService>(
getAppEndpoint()).withHostVerified(true).withPassword(PASSWORD).withKeyStorePath(KEY_STORE_PATH)
.build(HttpVersionClientService.class);

Response resp = versionHttpClient.getClientHttpVersion();
assertEquals(SC_OK, resp.getStatus());
assertEquals(HttpVersion.HTTP_2.name(), resp.getHeaderString(HttpClientVersionResource.HTTP_VERSION));
}

@Test
@DisplayName("Http/2 Client Async test")
@Disabled("blocked by: https://issues.redhat.com/browse/QUARKUS-658")
public void http2ClientAsync() throws Exception {
HttpVersionClientServiceAsync clientServiceAsync = new RestClientServiceBuilder<HttpVersionClientServiceAsync>(
getAppEndpoint()).withHostVerified(true).withPassword(PASSWORD).withKeyStorePath(KEY_STORE_PATH)
.build(HttpVersionClientServiceAsync.class);

Response resp = clientServiceAsync.getClientHttpVersion().await().atMost(Duration.ofSeconds(ASSERT_TIMEOUT_SECONDS));

assertEquals(SC_OK, resp.getStatus());
assertEquals(HttpVersion.HTTP_2.name(), resp.getHeaderString(HttpClientVersionResource.HTTP_VERSION));
}

@Test
@DisplayName("Non-application endpoint move to /q/")
@EnabledOnQuarkusVersion(version = "1\\..*", reason = "Redirection is no longer supported in 2.x")
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

12 changes: 0 additions & 12 deletions http/http-advanced/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@ HealthClientService/mp-rest/url=http://localhost:${quarkus.http.port}
HealthClientService/mp-rest/scope=jakarta.inject.Singleton
# FollowRedirect not supported QUARKUS-781
# HealthClientService/mp-rest/followRedirects=true
HttpVersionClientService/mp-rest/url=https://localhost:${quarkus.http.ssl-port}
HttpVersionClientService/mp-rest/scope=jakarta.inject.Singleton
HttpVersionClientService/mp-rest/hostnameVerifier=io.quarkus.restclient.NoopHostnameVerifier
HttpVersionClientService/mp-rest/trustStore=classpath:/META-INF/resources/server.truststore
HttpVersionClientService/mp-rest/trustStorePassword=password
HttpVersionClientServiceAsync/mp-rest/url=https://localhost:${quarkus.http.ssl-port}
HttpVersionClientServiceAsync/mp-rest/scope=jakarta.inject.Singleton
HttpVersionClientServiceAsync/mp-rest/hostnameVerifier=io.quarkus.restclient.NoopHostnameVerifier
HttpVersionClientServiceAsync/mp-rest/trustStore=classpath:/META-INF/resources/server.truststore
HttpVersionClientServiceAsync/mp-rest/trustStorePassword=password
# gRPC
quarkus.grpc.clients.hello.host=localhost
quarkus.grpc.clients.hello.port=${quarkus.http.port}
Expand All @@ -40,8 +30,6 @@ quarkus.keycloak.policy-enforcer.paths.swagger-ui.path=/api/swagger-ui/*
quarkus.keycloak.policy-enforcer.paths.swagger-ui.enforcement-mode=DISABLED
quarkus.keycloak.policy-enforcer.paths.health.path=/api/health/*
quarkus.keycloak.policy-enforcer.paths.health.enforcement-mode=DISABLED
quarkus.keycloak.policy-enforcer.paths.version.path=/api/httpVersion/*
quarkus.keycloak.policy-enforcer.paths.version.enforcement-mode=DISABLED
# Application endpoints
quarkus.keycloak.policy-enforcer.paths.hello.path=/api/hello/*
quarkus.keycloak.policy-enforcer.paths.hello.enforcement-mode=DISABLED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import org.apache.http.HttpStatus;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
Expand All @@ -41,9 +40,6 @@
import io.quarkus.test.scenarios.OpenShiftScenario;
import io.quarkus.test.scenarios.QuarkusScenario;
import io.quarkus.test.scenarios.annotations.EnabledOnQuarkusVersion;
import io.quarkus.ts.http.advanced.clients.HttpVersionClientService;
import io.quarkus.ts.http.advanced.clients.HttpVersionClientServiceAsync;
import io.quarkus.ts.http.advanced.clients.RestClientServiceBuilder;
import io.smallrye.mutiny.Uni;
import io.vertx.core.http.HttpVersion;
import io.vertx.core.json.JsonObject;
Expand All @@ -60,7 +56,6 @@ public abstract class BaseHttpAdvancedIT {
private static final int RETRY = 3;
private static final String PASSWORD = "password";
private static final String KEY_STORE_PATH = "META-INF/resources/server.keystore";
private static final int ASSERT_TIMEOUT_SECONDS = 10;
private static final String SSE_ERROR_MESSAGE = "java.lang.ClassNotFoundException: Provider for jakarta.ws.rs.sse.SseEventSource.Builder cannot be found";

protected abstract RestService getApp();
Expand Down Expand Up @@ -151,33 +146,6 @@ public void http2Server() throws InterruptedException, URISyntaxException {
assertThat(done.getCount(), equalTo(0L));
}

@Test
@DisplayName("Http/2 Client Sync test")
@Disabled("blocked by: https://issues.redhat.com/browse/QUARKUS-658")
public void http2ClientSync() throws Exception {
HttpVersionClientService versionHttpClient = new RestClientServiceBuilder<HttpVersionClientService>(
getAppEndpoint()).withHostVerified(true).withPassword(PASSWORD).withKeyStorePath(KEY_STORE_PATH)
.build(HttpVersionClientService.class);

Response resp = versionHttpClient.getClientHttpVersion();
assertEquals(HttpStatus.SC_OK, resp.getStatus());
assertEquals(HttpVersion.HTTP_2.name(), resp.getHeaderString(HttpClientVersionResource.HTTP_VERSION));
}

@Test
@DisplayName("Http/2 Client Async test")
@Disabled("blocked by: https://issues.redhat.com/browse/QUARKUS-658")
public void http2ClientAsync() throws Exception {
HttpVersionClientServiceAsync clientServiceAsync = new RestClientServiceBuilder<HttpVersionClientServiceAsync>(
getAppEndpoint()).withHostVerified(true).withPassword(PASSWORD).withKeyStorePath(KEY_STORE_PATH)
.build(HttpVersionClientServiceAsync.class);

Response resp = clientServiceAsync.getClientHttpVersion().await().atMost(Duration.ofSeconds(ASSERT_TIMEOUT_SECONDS));

assertEquals(HttpStatus.SC_OK, resp.getStatus());
assertEquals(HttpVersion.HTTP_2.name(), resp.getHeaderString(HttpClientVersionResource.HTTP_VERSION));
}

@Test
@DisplayName("Non-application endpoint move to /q/")
@EnabledOnQuarkusVersion(version = "1\\..*", reason = "Redirection is no longer supported in 2.x")
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 8abc157

Please sign in to comment.