From 5239bfbd7dadd916e02e0a6f90b6b15e2aa3edaa Mon Sep 17 00:00:00 2001 From: Gwenneg Lepage Date: Fri, 28 Jan 2022 17:13:51 +0100 Subject: [PATCH] Downgrade Quarkus to 2.3.1.Final --- .rhcicd/clowdapp-engine.yaml | 2 ++ .../DailyEmailAggregationJobTest.java | 4 +-- .../notifications/TestLifecycleManager.java | 2 +- backend/pom.xml | 27 +++++++++++++++++++ .../cloud/notifications/NotificationsApp.java | 7 ++--- .../src/main/resources/application.properties | 18 ++++++------- .../notifications/TestLifecycleManager.java | 6 ++--- .../events/EventConsumerTest.java | 2 +- .../events/FromCamelHistoryFillerTest.java | 2 +- .../notifications/events/LifecycleITest.java | 2 +- .../camel/CamelTypeProcessorTest.java | 4 +-- .../EmailSubscriptionTypeProcessorTest.java | 2 +- .../routers/AuthenticationTest.java | 15 ++++++++--- .../src/main/resources/application.properties | 10 +++---- pom.xml | 2 +- 15 files changed, 71 insertions(+), 34 deletions(-) diff --git a/.rhcicd/clowdapp-engine.yaml b/.rhcicd/clowdapp-engine.yaml index 514f12626e..b5c6080384 100644 --- a/.rhcicd/clowdapp-engine.yaml +++ b/.rhcicd/clowdapp-engine.yaml @@ -111,6 +111,8 @@ objects: value: ${PROCESSOR_EMAIL_NO_REPLY} - name: QUARKUS_REST_CLIENT_RBAC_S2S_READ_TIMEOUT value: ${RBAC_S2S_READ_TIMEOUT} + - name: RBAC_S2S_MP_REST_READTIMEOUT + value: ${RBAC_S2S_READ_TIMEOUT} - name: RBAC_SERVICE_TO_SERVICE_APPLICATION value: ${RBAC_SERVICE_TO_SERVICE_APP} - name: RBAC_SERVICE_TO_SERVICE_SECRET_MAP diff --git a/aggregator/src/test/java/com/redhat/cloud/notifications/DailyEmailAggregationJobTest.java b/aggregator/src/test/java/com/redhat/cloud/notifications/DailyEmailAggregationJobTest.java index 10f8691c6a..20178d5fb2 100644 --- a/aggregator/src/test/java/com/redhat/cloud/notifications/DailyEmailAggregationJobTest.java +++ b/aggregator/src/test/java/com/redhat/cloud/notifications/DailyEmailAggregationJobTest.java @@ -7,8 +7,8 @@ import io.quarkus.test.TestTransaction; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; -import io.smallrye.reactive.messaging.providers.connectors.InMemoryConnector; -import io.smallrye.reactive.messaging.providers.connectors.InMemorySink; +import io.smallrye.reactive.messaging.connectors.InMemoryConnector; +import io.smallrye.reactive.messaging.connectors.InMemorySink; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/aggregator/src/test/java/com/redhat/cloud/notifications/TestLifecycleManager.java b/aggregator/src/test/java/com/redhat/cloud/notifications/TestLifecycleManager.java index ac6f19a62c..c03c05361a 100644 --- a/aggregator/src/test/java/com/redhat/cloud/notifications/TestLifecycleManager.java +++ b/aggregator/src/test/java/com/redhat/cloud/notifications/TestLifecycleManager.java @@ -1,7 +1,7 @@ package com.redhat.cloud.notifications; import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; -import io.smallrye.reactive.messaging.providers.connectors.InMemoryConnector; +import io.smallrye.reactive.messaging.connectors.InMemoryConnector; import org.testcontainers.containers.PostgreSQLContainer; import java.sql.SQLException; diff --git a/backend/pom.xml b/backend/pom.xml index 287b9fcaa3..29e3256b7e 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -249,6 +249,33 @@ true + + + org.apache.maven.plugins + maven-resources-plugin + 3.0.2 + + + generate-sources + + copy-resources + + + ${basedir}/target/classes/templates + + + ../engine/src/main/resources/templates + + + + + + diff --git a/backend/src/main/java/com/redhat/cloud/notifications/NotificationsApp.java b/backend/src/main/java/com/redhat/cloud/notifications/NotificationsApp.java index a48ad5b39b..5fefeb6cdd 100644 --- a/backend/src/main/java/com/redhat/cloud/notifications/NotificationsApp.java +++ b/backend/src/main/java/com/redhat/cloud/notifications/NotificationsApp.java @@ -25,14 +25,15 @@ public class NotificationsApp { // we do need a event as parameter here, otherwise the init method won't get called. void init(@Observes StartupEvent ev) { - disableRestClientContextualErrors(); + // TODO Uncomment when Quarkus is bumped to 2.6.4.Final or newer. + //disableRestClientContextualErrors(); initAccessLogFilter(); LOG.info(readGitProperties()); - logExternalServiceUrl("quarkus.rest-client.rbac-authentication.url"); - logExternalServiceUrl("quarkus.rest-client.rbac-s2s.url"); + logExternalServiceUrl("rbac-authentication/mp-rest/url"); + logExternalServiceUrl("rbac-s2s/mp-rest/url"); } private void disableRestClientContextualErrors() { diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index 4194f0fc3a..68c6ad7dde 100644 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -75,16 +75,16 @@ quarkus.log.category."com.redhat.cloud.notifications".level=INFO rbac.enabled=true # RBAC configuration used during user authentication. It is used when a public REST API is called. -#quarkus.rest-client.rbac-authentication.url=http://ci.foo.redhat.com:1337 -quarkus.rest-client.rbac-authentication.url=${clowder.endpoints.rbac-service:https://ci.cloud.redhat.com} -quarkus.rest-client.rbac-authentication.connect-timeout=2000 -quarkus.rest-client.rbac-authentication.read-timeout=2000 +#rbac-authentication/mp-rest/url=http://ci.foo.redhat.com:1337 +rbac-authentication/mp-rest/url=${clowder.endpoints.rbac-service:https://ci.cloud.redhat.com} +rbac-authentication/mp-rest/connectTimeout=2000 +rbac-authentication/mp-rest/readTimeout=2000 # RBAC configuration used to retrieve email recipients. It is used when an email notification is sent. -#quarkus.rest-client.rbac-s2s.url=http://ci.foo.redhat.com:1337 -quarkus.rest-client.rbac-s2s.url=${clowder.endpoints.rbac-service:https://ci.cloud.redhat.com} -quarkus.rest-client.rbac-s2s.connect-timeout=2000 -quarkus.rest-client.rbac-s2s.read-timeout=120000 +#rbac-s2s/mp-rest/url=http://ci.foo.redhat.com:1337 +rbac-s2s/mp-rest/url=${clowder.endpoints.rbac-service:https://ci.cloud.redhat.com} +rbac-s2s/mp-rest/connectTimeout=2000 +rbac-s2s/mp-rest/readTimeout=120000 # Duration rbac entries are kept in cache quarkus.cache.caffeine.rbac-cache.expire-after-write=PT120s @@ -131,4 +131,4 @@ quarkus.log.category."com.redhat.cloud.notifications.health.KafkaConsumedTotalCh # Should messages about failed injections be delivered as new events (and thus emails to admins) reinject.enabled=false -quarkus.rest-client.template-engine.url=${clowder.endpoints.notifications-backend-service:http://localhost:${quarkus.http.port}} +template-engine/mp-rest/url=${clowder.endpoints.notifications-backend-service:http://localhost:${quarkus.http.port}} diff --git a/backend/src/test/java/com/redhat/cloud/notifications/TestLifecycleManager.java b/backend/src/test/java/com/redhat/cloud/notifications/TestLifecycleManager.java index 49e6d20b2a..f581d05d0a 100644 --- a/backend/src/test/java/com/redhat/cloud/notifications/TestLifecycleManager.java +++ b/backend/src/test/java/com/redhat/cloud/notifications/TestLifecycleManager.java @@ -1,7 +1,7 @@ package com.redhat.cloud.notifications; import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; -import io.smallrye.reactive.messaging.providers.connectors.InMemoryConnector; +import io.smallrye.reactive.messaging.connectors.InMemoryConnector; import org.postgresql.ds.PGSimpleDataSource; import org.testcontainers.containers.MockServerContainer; import org.testcontainers.containers.PostgreSQLContainer; @@ -120,7 +120,7 @@ void setupMockEngine(Map props) { configurator = new MockServerClientConfig(mockEngineServer.getContainerIpAddress(), mockEngineServer.getServerPort()); - props.put("quarkus.rest-client.rbac-authentication.url", mockServerUrl); - props.put("quarkus.rest-client.rbac-s2s.url", mockServerUrl); + props.put("rbac-authentication/mp-rest/url", mockServerUrl); + props.put("rbac-s2s/mp-rest/url", mockServerUrl); } } diff --git a/backend/src/test/java/com/redhat/cloud/notifications/events/EventConsumerTest.java b/backend/src/test/java/com/redhat/cloud/notifications/events/EventConsumerTest.java index bcfa96a768..dd6b2f2d5f 100644 --- a/backend/src/test/java/com/redhat/cloud/notifications/events/EventConsumerTest.java +++ b/backend/src/test/java/com/redhat/cloud/notifications/events/EventConsumerTest.java @@ -14,8 +14,8 @@ import io.quarkus.test.junit.mockito.InjectMock; import io.quarkus.test.junit.mockito.InjectSpy; import io.smallrye.mutiny.Uni; +import io.smallrye.reactive.messaging.connectors.InMemoryConnector; import io.smallrye.reactive.messaging.kafka.api.OutgoingKafkaRecordMetadata; -import io.smallrye.reactive.messaging.providers.connectors.InMemoryConnector; import org.apache.kafka.common.header.internals.RecordHeaders; import org.eclipse.microprofile.reactive.messaging.Message; import org.junit.jupiter.api.AfterEach; diff --git a/backend/src/test/java/com/redhat/cloud/notifications/events/FromCamelHistoryFillerTest.java b/backend/src/test/java/com/redhat/cloud/notifications/events/FromCamelHistoryFillerTest.java index fdff7f9df3..80251e494b 100644 --- a/backend/src/test/java/com/redhat/cloud/notifications/events/FromCamelHistoryFillerTest.java +++ b/backend/src/test/java/com/redhat/cloud/notifications/events/FromCamelHistoryFillerTest.java @@ -7,7 +7,7 @@ import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.mockito.InjectMock; -import io.smallrye.reactive.messaging.providers.connectors.InMemoryConnector; +import io.smallrye.reactive.messaging.connectors.InMemoryConnector; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/backend/src/test/java/com/redhat/cloud/notifications/events/LifecycleITest.java b/backend/src/test/java/com/redhat/cloud/notifications/events/LifecycleITest.java index b7ddf75d84..8ca5e0a8c0 100644 --- a/backend/src/test/java/com/redhat/cloud/notifications/events/LifecycleITest.java +++ b/backend/src/test/java/com/redhat/cloud/notifications/events/LifecycleITest.java @@ -34,7 +34,7 @@ import io.quarkus.test.junit.mockito.InjectSpy; import io.restassured.http.Header; import io.smallrye.mutiny.Uni; -import io.smallrye.reactive.messaging.providers.connectors.InMemoryConnector; +import io.smallrye.reactive.messaging.connectors.InMemoryConnector; import io.vertx.core.json.JsonArray; import io.vertx.core.json.JsonObject; import org.junit.jupiter.api.Test; diff --git a/backend/src/test/java/com/redhat/cloud/notifications/processors/camel/CamelTypeProcessorTest.java b/backend/src/test/java/com/redhat/cloud/notifications/processors/camel/CamelTypeProcessorTest.java index 7b5a0af7b3..baacc9ddec 100644 --- a/backend/src/test/java/com/redhat/cloud/notifications/processors/camel/CamelTypeProcessorTest.java +++ b/backend/src/test/java/com/redhat/cloud/notifications/processors/camel/CamelTypeProcessorTest.java @@ -14,9 +14,9 @@ import io.quarkus.test.junit.QuarkusTest; import io.smallrye.reactive.messaging.TracingMetadata; import io.smallrye.reactive.messaging.ce.CloudEventMetadata; +import io.smallrye.reactive.messaging.connectors.InMemoryConnector; +import io.smallrye.reactive.messaging.connectors.InMemorySink; import io.smallrye.reactive.messaging.kafka.api.KafkaMessageMetadata; -import io.smallrye.reactive.messaging.providers.connectors.InMemoryConnector; -import io.smallrye.reactive.messaging.providers.connectors.InMemorySink; import io.vertx.core.json.JsonObject; import org.apache.kafka.common.header.Headers; import org.eclipse.microprofile.reactive.messaging.Message; diff --git a/backend/src/test/java/com/redhat/cloud/notifications/processors/email/EmailSubscriptionTypeProcessorTest.java b/backend/src/test/java/com/redhat/cloud/notifications/processors/email/EmailSubscriptionTypeProcessorTest.java index 0f65e3d176..2c065ce117 100644 --- a/backend/src/test/java/com/redhat/cloud/notifications/processors/email/EmailSubscriptionTypeProcessorTest.java +++ b/backend/src/test/java/com/redhat/cloud/notifications/processors/email/EmailSubscriptionTypeProcessorTest.java @@ -14,7 +14,7 @@ import io.quarkus.test.junit.mockito.InjectMock; import io.smallrye.mutiny.Multi; import io.smallrye.mutiny.helpers.test.AssertSubscriber; -import io.smallrye.reactive.messaging.providers.connectors.InMemoryConnector; +import io.smallrye.reactive.messaging.connectors.InMemoryConnector; import org.junit.jupiter.api.Test; import javax.enterprise.inject.Any; diff --git a/backend/src/test/java/com/redhat/cloud/notifications/routers/AuthenticationTest.java b/backend/src/test/java/com/redhat/cloud/notifications/routers/AuthenticationTest.java index 4d7ec5546f..5123586dfb 100644 --- a/backend/src/test/java/com/redhat/cloud/notifications/routers/AuthenticationTest.java +++ b/backend/src/test/java/com/redhat/cloud/notifications/routers/AuthenticationTest.java @@ -7,6 +7,7 @@ import com.redhat.cloud.notifications.TestLifecycleManager; import io.quarkus.cache.Cache; import io.quarkus.cache.CacheName; +import io.quarkus.cache.runtime.caffeine.CaffeineCache; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; import io.restassured.RestAssured; @@ -45,7 +46,7 @@ void testEndpointRoles() { .then() .statusCode(401); - cache.invalidateAll().await().indefinitely(); + clearRbacCache(); // Fetch endpoint without any Rbac details - errors cause 401 given() @@ -55,7 +56,7 @@ void testEndpointRoles() { .then() .statusCode(401); - cache.invalidateAll().await().indefinitely(); + clearRbacCache(); // Fetch endpoint with no access - Rbac succeed returns 403 mockServerConfig.addMockRbacAccess(identityHeaderValue, MockServerClientConfig.RbacAccess.NO_ACCESS); @@ -67,7 +68,7 @@ void testEndpointRoles() { .then() .statusCode(403); - cache.invalidateAll().await().indefinitely(); + clearRbacCache(); // Test bogus x-rh-identity header that fails Base64 decoding given() @@ -76,4 +77,12 @@ void testEndpointRoles() { .then() .statusCode(401); } + + private void clearRbacCache() { + /* + * TODO Replace with real programmatic API call when it will be available. For now we have to rely on this "hack". + * See https://github.com/quarkusio/quarkus/pull/8631 + */ + ((CaffeineCache) cache).invalidateAll(); + } } diff --git a/engine/src/main/resources/application.properties b/engine/src/main/resources/application.properties index e3b8ce21e2..4d522c6532 100644 --- a/engine/src/main/resources/application.properties +++ b/engine/src/main/resources/application.properties @@ -64,10 +64,10 @@ quarkus.log.category."com.redhat.cloud.notifications".level=INFO %test.quarkus.http.access-log.category=info # RBAC configuration used to retrieve email recipients. It is used when an email notification is sent. -#quarkus.rest-client.rbac-s2s.url=http://ci.foo.redhat.com:1337 -quarkus.rest-client.rbac-s2s.url=${clowder.endpoints.rbac-service:https://ci.cloud.redhat.com} -quarkus.rest-client.rbac-s2s.connect-timeout=2000 -quarkus.rest-client.rbac-s2s.read-timeout=120000 +#rbac-s2s/mp-rest/url=http://ci.foo.redhat.com:1337 +rbac-s2s/mp-rest/url=${clowder.endpoints.rbac-service:https://ci.cloud.redhat.com} +rbac-s2s/mp-rest/connectTimeout=2000 +rbac-s2s/mp-rest/readTimeout=120000 # Duration rbac entries are kept in cache quarkus.cache.caffeine.rbac-cache.expire-after-write=PT120s @@ -113,5 +113,3 @@ quarkus.log.category."com.redhat.cloud.notifications.health.KafkaConsumedTotalCh # Should messages about failed injections be delivered as new events (and thus emails to admins) reinject.enabled=false - -quarkus.rest-client.template-engine.url=${clowder.endpoints.notifications-backend-service:http://localhost:${quarkus.http.port}} diff --git a/pom.xml b/pom.xml index 6f2461c538..c2a5764aaa 100644 --- a/pom.xml +++ b/pom.xml @@ -54,7 +54,7 @@ quarkus-bom io.quarkus - 2.6.3.Final + 2.3.1.Final