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

Split MicroProfile integration tests into separate modules #6092

Merged
merged 1 commit into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion integration-test-groups/foundation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
<module>controlbus</module>
<module>core</module>
<module>core-annotations</module>
<module>core-fault-tolerance</module>
<module>core-languages</module>
<module>core-thread-pools</module>
<module>customized-log-component</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
<relativePath>../../poms/build-parent-it/pom.xml</relativePath>
</parent>

<artifactId>camel-quarkus-integration-test-microprofile</artifactId>
<name>Camel Quarkus :: Integration Tests :: MicroProfile</name>
<description>Integration tests for Camel Quarkus MicroProfile extensions</description>
<artifactId>camel-quarkus-integration-test-microprofile-fault-tolerance</artifactId>
<name>Camel Quarkus :: Integration Tests :: MicroProfile Fault Tolerance</name>
<description>Integration tests for Camel Quarkus MicroProfile Fault Tolerance extension</description>

<dependencies>
<dependency>
Expand All @@ -39,18 +39,10 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-direct</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-log</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-microprofile-fault-tolerance</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-microprofile-health</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-mock</artifactId>
Expand All @@ -59,6 +51,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>

<!-- test dependencies -->
<dependency>
Expand All @@ -71,11 +67,6 @@
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
Expand Down Expand Up @@ -141,19 +132,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-log-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-microprofile-fault-tolerance-deployment</artifactId>
Expand All @@ -167,19 +145,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-microprofile-health-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-mock-deployment</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import jakarta.inject.Inject;
import jakarta.inject.Named;
import org.apache.camel.builder.RouteBuilder;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.eclipse.microprofile.faulttolerance.exceptions.TimeoutException;

@ApplicationScoped
Expand All @@ -35,6 +36,9 @@ public class MicroProfileFaultToleranceRoutes extends RouteBuilder {
@Inject
GreetingBean greetingBean;

@ConfigProperty(name = "load.config.test.route", defaultValue = "false")
boolean loadConfigTestRoute;

@Override
public void configure() throws Exception {
from("direct:faultToleranceWithBulkhead")
Expand Down Expand Up @@ -125,6 +129,13 @@ public void configure() throws Exception {
.doCatch(TimeoutException.class)
.setBody().constant(FALLBACK_RESULT)
.end();

if (loadConfigTestRoute) {
// This route exists only to test camel.faulttolerance configuration parsing
from("direct:customConfig").circuitBreaker().id("ftp").process(exchange -> {
exchange.getMessage().setBody(RESULT);
}).onFallback().setBody().constant(FALLBACK_RESULT).end();
}
}

@Named("myThreadPool")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.quarkus.core.faulttolerance.it;
package org.apache.camel.quarkus.component.microprofile.it.faulttolerance;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

import io.smallrye.faulttolerance.core.FaultToleranceStrategy;
import io.smallrye.faulttolerance.core.InvocationContext;
import io.smallrye.faulttolerance.core.circuit.breaker.CircuitBreaker;
import io.smallrye.faulttolerance.core.stopwatch.SystemStopwatch;
import io.smallrye.faulttolerance.core.timer.ThreadTimer;
Expand All @@ -30,17 +29,13 @@
import jakarta.enterprise.inject.Disposes;
import jakarta.inject.Named;

public class CoreFaultToleranceProducers {
@ApplicationScoped
public class MicroprofileFaultToleranceProducers {

@ApplicationScoped
@Named("customCircuitBreaker")
CircuitBreaker<Integer> produceCustomCircuitBreaker(ThreadTimer threadTimer) {
FaultToleranceStrategy<Integer> delegate = new FaultToleranceStrategy<Integer>() {
@Override
public Integer apply(InvocationContext<Integer> ctx) {
return null;
}
};
FaultToleranceStrategy<Integer> delegate = ctx -> null;
return new CircuitBreaker<>(delegate, "description", ExceptionDecision.ALWAYS_FAILURE, 10, 40, 0.1,
2, SystemStopwatch.INSTANCE, threadTimer) {
@Override
Expand Down Expand Up @@ -68,7 +63,8 @@ ExecutorService threadTimerExecutor() {
return Executors.newSingleThreadExecutor();
}

void disposeThreadTimerExecutor(@Disposes @Named("threadTimerExecutor") ExecutorService threadTimerExecutor,
void disposeThreadTimerExecutor(
@Disposes @Named("threadTimerExecutor") ExecutorService threadTimerExecutor,
ThreadTimer timer) {
try {
timer.shutdown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,23 @@
*/
package org.apache.camel.quarkus.component.microprofile.it.faulttolerance;

import java.util.concurrent.ExecutorService;

import io.smallrye.faulttolerance.core.circuit.breaker.CircuitBreaker;
import jakarta.inject.Inject;
import jakarta.inject.Named;
import jakarta.json.Json;
import jakarta.json.JsonObject;
import jakarta.json.JsonObjectBuilder;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import org.apache.camel.CamelContext;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.component.microprofile.faulttolerance.FaultToleranceProcessor;
import org.apache.camel.component.mock.MockEndpoint;

@Path("/microprofile-fault-tolerance")
Expand All @@ -35,6 +44,12 @@ public class MicroprofileFaultToleranceResource {
@Inject
CamelContext context;

@Named("customCircuitBreaker")
CircuitBreaker<Integer> customCircuitBreaker;

@Named("customBulkheadExecutorService")
ExecutorService customBulkheadExecutorService;

@Path("/route/{route}")
@POST
@Produces(MediaType.TEXT_PLAIN)
Expand Down Expand Up @@ -71,4 +86,27 @@ public void inheritErrorHandler() throws Exception {
end.assertIsSatisfied(5000);
dead.assertIsSatisfied(5000);
}

@Path("/configuration")
@GET
@Produces(MediaType.APPLICATION_JSON)
public JsonObject faultToleranceConfigurations() {
FaultToleranceProcessor processor = context.getProcessor("ftp", FaultToleranceProcessor.class);
JsonObjectBuilder objectBuilder = Json.createObjectBuilder();
objectBuilder.add("isCustomCircuitBreakerRef", processor.getCircuitBreaker() == customCircuitBreaker);
objectBuilder.add("delay", processor.getDelay());
objectBuilder.add("successThreshold", processor.getSuccessThreshold());
objectBuilder.add("requestVolumeThreshold", processor.getRequestVolumeThreshold());
objectBuilder.add("failureRatio", (int) (processor.getFailureRate() * 100));
objectBuilder.add("timeoutEnabled", processor.isTimeoutEnabled());
objectBuilder.add("timeoutDuration", processor.getTimeoutDuration());
objectBuilder.add("timeoutPoolSize", processor.getTimeoutPoolSize());
objectBuilder.add("bulkheadEnabled", processor.isBulkheadEnabled());
objectBuilder.add("bulkheadMaxConcurrentCalls", processor.getBulkheadMaxConcurrentCalls());
objectBuilder.add("bulkheadWaitingTaskQueue", processor.getBulkheadWaitingTaskQueue());
objectBuilder.add("isCustomBulkheadExecutorServiceRef",
processor.getExecutorService() == customBulkheadExecutorService);

return objectBuilder.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.quarkus.core.faulttolerance.it;
package org.apache.camel.quarkus.component.microprofile.it.faulttolerance;

import io.quarkus.test.junit.QuarkusIntegrationTest;

@QuarkusIntegrationTest
public class CoreFaultToleranceIT extends CoreFaultToleranceTest {
class MicroProfileFaultToleranceConfigurationIT extends MicroProfileFaultToleranceConfigurationTest {
}
Loading
Loading