Skip to content

Commit

Permalink
Add timeout config to CircuitBreakerTimeoutTest
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Rouse <[email protected]>
  • Loading branch information
Azquelt committed May 15, 2020
1 parent 4353520 commit 6747d87
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (c) 2018 Contributors to the Eclipse Foundation
* Copyright (c) 2018-2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand All @@ -22,6 +22,7 @@
import javax.inject.Inject;

import org.eclipse.microprofile.fault.tolerance.tck.circuitbreaker.clientserver.CircuitBreakerClientWithTimeout;
import org.eclipse.microprofile.fault.tolerance.tck.config.ConfigAnnotationAsset;
import org.eclipse.microprofile.fault.tolerance.tck.util.Exceptions;
import org.eclipse.microprofile.fault.tolerance.tck.util.Packages;
import org.jboss.arquillian.container.test.api.Deployment;
Expand All @@ -41,11 +42,15 @@ public class CircuitBreakerTimeoutTest extends Arquillian {

@Deployment
public static WebArchive deploy() {
ConfigAnnotationAsset config = new ConfigAnnotationAsset()
.autoscaleMethod(CircuitBreakerClientWithTimeout.class, "serviceWithTimeout")
.autoscaleMethod(CircuitBreakerClientWithTimeout.class, "serviceWithTimeoutWithoutFailOn");

JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "ftCircuitBreakerTimeout.jar")
.addClasses(CircuitBreakerClientWithTimeout.class)
.addPackage(Packages.UTILS)
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
.as(JavaArchive.class);
.addAsManifestResource(config, "microprofile-config.properties");

WebArchive war = ShrinkWrap.create(WebArchive.class, "ftCircuitBreakerTimeout.war")
.addAsLibrary(testJar);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (c) 2018 Contributors to the Eclipse Foundation
* Copyright (c) 2018-2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand All @@ -23,6 +23,7 @@

import javax.enterprise.context.RequestScoped;

import org.eclipse.microprofile.fault.tolerance.tck.util.TCKConfig;
import org.eclipse.microprofile.faulttolerance.CircuitBreaker;
import org.eclipse.microprofile.faulttolerance.Timeout;
import org.eclipse.microprofile.faulttolerance.exceptions.BulkheadException;
Expand All @@ -38,10 +39,10 @@ public class CircuitBreakerClientWithTimeout {
* @return should always throw TimeoutException, unless CircuitBreaker prevents execution
*/
@CircuitBreaker(successThreshold = 2, requestVolumeThreshold = 2, failureRatio = 0.75, delay = 50000)
@Timeout(500)
@Timeout(500) // Adjusted by config
public String serviceWithTimeout() {
try {
Thread.sleep(1000);
Thread.sleep(TCKConfig.getConfig().getTimeoutInMillis(1000));
fail("Thread not interrupted by timeout");
}
catch (InterruptedException e) {
Expand All @@ -60,10 +61,10 @@ public String serviceWithTimeout() {
* @return should always throw TimeoutException
*/
@CircuitBreaker(successThreshold = 2, requestVolumeThreshold = 2, failureRatio = 0.75, delay = 50000, failOn = BulkheadException.class)
@Timeout(500)
@Timeout(500) // Adjusted by config
public String serviceWithTimeoutWithoutFailOn() {
try {
Thread.sleep(1000);
Thread.sleep(TCKConfig.getConfig().getTimeoutInMillis(1000));
fail("Thread not interrupted by timeout");
}
catch (InterruptedException e) {
Expand Down

0 comments on commit 6747d87

Please sign in to comment.