Fixed Failig unit tests
This commit is contained in:
parent
f7995e42ae
commit
c3fcdc3f45
|
@ -62,11 +62,11 @@
|
||||||
<artifactId>hystrix-metrics-event-stream</artifactId>
|
<artifactId>hystrix-metrics-event-stream</artifactId>
|
||||||
<version>${hystrix-metrics-event-stream.version}</version>
|
<version>${hystrix-metrics-event-stream.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<!--<dependency>
|
||||||
<groupId>com.netflix.hystrix</groupId>
|
<groupId>com.netflix.hystrix</groupId>
|
||||||
<artifactId>hystrix-dashboard</artifactId>
|
<artifactId>hystrix-dashboard</artifactId>
|
||||||
<version>${hystrix-dashboard.version}</version>
|
<version>${hystrix-dashboard.version}</version>
|
||||||
</dependency>
|
</dependency>-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.netflix.rxjava</groupId>
|
<groupId>com.netflix.rxjava</groupId>
|
||||||
<artifactId>rxjava-core</artifactId>
|
<artifactId>rxjava-core</artifactId>
|
||||||
|
|
|
@ -15,21 +15,6 @@ import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
public class HystrixTimeoutTest {
|
public class HystrixTimeoutTest {
|
||||||
|
|
||||||
private HystrixCommand.Setter config;
|
|
||||||
private HystrixCommandProperties.Setter commandProperties;
|
|
||||||
|
|
||||||
|
|
||||||
@Rule
|
|
||||||
public final ExpectedException exception = ExpectedException.none();
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setup() {
|
|
||||||
commandProperties = HystrixCommandProperties.Setter();
|
|
||||||
config = HystrixCommand
|
|
||||||
.Setter
|
|
||||||
.withGroupKey(HystrixCommandGroupKey.Factory.asKey("RemoteServiceGroup1"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenInputBobAndDefaultSettings_whenExecuted_thenReturnHelloBob(){
|
public void givenInputBobAndDefaultSettings_whenExecuted_thenReturnHelloBob(){
|
||||||
assertThat(new CommandHelloWorld("Bob").execute(), equalTo("Hello Bob!"));
|
assertThat(new CommandHelloWorld("Bob").execute(), equalTo("Hello Bob!"));
|
||||||
|
@ -38,24 +23,29 @@ public class HystrixTimeoutTest {
|
||||||
@Test
|
@Test
|
||||||
public void givenSvcTimeoutOf100AndDefaultSettings_whenExecuted_thenReturnSuccess()
|
public void givenSvcTimeoutOf100AndDefaultSettings_whenExecuted_thenReturnSuccess()
|
||||||
throws InterruptedException {
|
throws InterruptedException {
|
||||||
|
|
||||||
HystrixCommand.Setter config = HystrixCommand
|
HystrixCommand.Setter config = HystrixCommand
|
||||||
.Setter
|
.Setter
|
||||||
.withGroupKey(HystrixCommandGroupKey.Factory.asKey("RemoteServiceGroup1"));
|
.withGroupKey(HystrixCommandGroupKey.Factory.asKey("RemoteServiceGroup2"));
|
||||||
|
|
||||||
assertThat(new RemoteServiceTestCommand(config, new RemoteServiceTestSimulator(100)).execute(),
|
assertThat(new RemoteServiceTestCommand(config, new RemoteServiceTestSimulator(100)).execute(),
|
||||||
equalTo("Success"));
|
equalTo("Success"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = HystrixRuntimeException.class)
|
||||||
public void givenSvcTimeoutOf10000AndDefaultSettings__whenExecuted_thenExpectHRE() throws InterruptedException {
|
public void givenSvcTimeoutOf10000AndDefaultSettings__whenExecuted_thenExpectHRE() throws InterruptedException {
|
||||||
exception.expect(HystrixRuntimeException.class);
|
HystrixCommand.Setter config = HystrixCommand
|
||||||
|
.Setter
|
||||||
|
.withGroupKey(HystrixCommandGroupKey.Factory.asKey("RemoteServiceGroupTest3"));
|
||||||
new RemoteServiceTestCommand(config, new RemoteServiceTestSimulator(10_000)).execute();
|
new RemoteServiceTestCommand(config, new RemoteServiceTestSimulator(10_000)).execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenSvcTimeoutOf5000AndExecTimeoutOf10000__whenExecuted_thenReturnSuccess()
|
public void givenSvcTimeoutOf5000AndExecTimeoutOf10000__whenExecuted_thenReturnSuccess()
|
||||||
throws InterruptedException {
|
throws InterruptedException {
|
||||||
|
|
||||||
|
HystrixCommand.Setter config = HystrixCommand
|
||||||
|
.Setter
|
||||||
|
.withGroupKey(HystrixCommandGroupKey.Factory.asKey("RemoteServiceGroupTest4"));
|
||||||
|
HystrixCommandProperties.Setter commandProperties = HystrixCommandProperties.Setter();
|
||||||
commandProperties.withExecutionTimeoutInMilliseconds(10_000);
|
commandProperties.withExecutionTimeoutInMilliseconds(10_000);
|
||||||
config.andCommandPropertiesDefaults(commandProperties);
|
config.andCommandPropertiesDefaults(commandProperties);
|
||||||
|
|
||||||
|
@ -63,10 +53,13 @@ public class HystrixTimeoutTest {
|
||||||
equalTo("Success"));
|
equalTo("Success"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = HystrixRuntimeException.class)
|
||||||
public void givenSvcTimeoutOf15000AndExecTimeoutOf5000__whenExecuted_thenExpectHRE()
|
public void givenSvcTimeoutOf15000AndExecTimeoutOf5000__whenExecuted_thenExpectHRE()
|
||||||
throws InterruptedException {
|
throws InterruptedException {
|
||||||
exception.expect(HystrixRuntimeException.class);
|
HystrixCommand.Setter config = HystrixCommand
|
||||||
|
.Setter
|
||||||
|
.withGroupKey(HystrixCommandGroupKey.Factory.asKey("RemoteServiceGroupTest5"));
|
||||||
|
HystrixCommandProperties.Setter commandProperties = HystrixCommandProperties.Setter();
|
||||||
commandProperties.withExecutionTimeoutInMilliseconds(5_000);
|
commandProperties.withExecutionTimeoutInMilliseconds(5_000);
|
||||||
config.andCommandPropertiesDefaults(commandProperties);
|
config.andCommandPropertiesDefaults(commandProperties);
|
||||||
new RemoteServiceTestCommand(config, new RemoteServiceTestSimulator(15_000)).execute();
|
new RemoteServiceTestCommand(config, new RemoteServiceTestSimulator(15_000)).execute();
|
||||||
|
@ -75,6 +68,11 @@ public class HystrixTimeoutTest {
|
||||||
@Test
|
@Test
|
||||||
public void givenSvcTimeoutOf500AndExecTimeoutOf10000AndThreadPool__whenExecuted_thenReturnSuccess()
|
public void givenSvcTimeoutOf500AndExecTimeoutOf10000AndThreadPool__whenExecuted_thenReturnSuccess()
|
||||||
throws InterruptedException {
|
throws InterruptedException {
|
||||||
|
|
||||||
|
HystrixCommand.Setter config = HystrixCommand
|
||||||
|
.Setter
|
||||||
|
.withGroupKey(HystrixCommandGroupKey.Factory.asKey("RemoteServiceGroupThreadPool"));
|
||||||
|
HystrixCommandProperties.Setter commandProperties = HystrixCommandProperties.Setter();
|
||||||
commandProperties.withExecutionTimeoutInMilliseconds(10_000);
|
commandProperties.withExecutionTimeoutInMilliseconds(10_000);
|
||||||
config.andCommandPropertiesDefaults(commandProperties);
|
config.andCommandPropertiesDefaults(commandProperties);
|
||||||
config.andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter()
|
config.andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter()
|
||||||
|
@ -90,6 +88,10 @@ public class HystrixTimeoutTest {
|
||||||
public void givenCircuitBreakerSetup__whenRemoteSvcCmdExecuted_thenReturnSuccess()
|
public void givenCircuitBreakerSetup__whenRemoteSvcCmdExecuted_thenReturnSuccess()
|
||||||
throws InterruptedException {
|
throws InterruptedException {
|
||||||
|
|
||||||
|
HystrixCommand.Setter config = HystrixCommand
|
||||||
|
.Setter
|
||||||
|
.withGroupKey(HystrixCommandGroupKey.Factory.asKey("RemoteServiceGroupCircuitBreakerTest"));
|
||||||
|
HystrixCommandProperties.Setter commandProperties = HystrixCommandProperties.Setter();
|
||||||
commandProperties.withExecutionTimeoutInMilliseconds(1000);
|
commandProperties.withExecutionTimeoutInMilliseconds(1000);
|
||||||
|
|
||||||
commandProperties.withCircuitBreakerSleepWindowInMilliseconds(4000);
|
commandProperties.withCircuitBreakerSleepWindowInMilliseconds(4000);
|
||||||
|
@ -105,8 +107,9 @@ public class HystrixTimeoutTest {
|
||||||
.withCoreSize(1)
|
.withCoreSize(1)
|
||||||
.withQueueSizeRejectionThreshold(1));
|
.withQueueSizeRejectionThreshold(1));
|
||||||
|
|
||||||
assertThat(this.invokeRemoteService(10000), equalTo(null));
|
assertThat(this.invokeRemoteService(config, 10_000), equalTo(null));
|
||||||
assertThat(this.invokeRemoteService(10000), equalTo(null));
|
assertThat(this.invokeRemoteService(config, 10_000), equalTo(null));
|
||||||
|
assertThat(this.invokeRemoteService(config, 10_000), equalTo(null));
|
||||||
Thread.sleep(5000);
|
Thread.sleep(5000);
|
||||||
|
|
||||||
assertThat(new RemoteServiceTestCommand(config, new RemoteServiceTestSimulator(500)).execute(),
|
assertThat(new RemoteServiceTestCommand(config, new RemoteServiceTestSimulator(500)).execute(),
|
||||||
|
@ -117,7 +120,7 @@ public class HystrixTimeoutTest {
|
||||||
equalTo("Success"));
|
equalTo("Success"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String invokeRemoteService(long timeout) throws InterruptedException {
|
public String invokeRemoteService(HystrixCommand.Setter config, int timeout) throws InterruptedException {
|
||||||
String response = null;
|
String response = null;
|
||||||
try {
|
try {
|
||||||
response = new RemoteServiceTestCommand(config,
|
response = new RemoteServiceTestCommand(config,
|
||||||
|
|
Loading…
Reference in New Issue