Search in sources :

Example 11 with HystrixInvokableInfo

use of com.netflix.hystrix.HystrixInvokableInfo in project Hystrix by Netflix.

the class SerialHystrixRequestEventsTest method testTwoSuccessesDifferentKey.

@Test
public void testTwoSuccessesDifferentKey() throws IOException {
    List<HystrixInvokableInfo<?>> executions = new ArrayList<HystrixInvokableInfo<?>>();
    HystrixInvokableInfo<Integer> foo1 = new SimpleExecution(fooKey, 23, HystrixEventType.SUCCESS);
    HystrixInvokableInfo<Integer> bar1 = new SimpleExecution(barKey, 34, HystrixEventType.SUCCESS);
    executions.add(foo1);
    executions.add(bar1);
    HystrixRequestEvents request = new HystrixRequestEvents(executions);
    String actual = SerialHystrixRequestEvents.toJsonString(request);
    assertTrue(actual.equals("[{\"name\":\"Foo\",\"events\":[\"SUCCESS\"],\"latencies\":[23]},{\"name\":\"Bar\",\"events\":[\"SUCCESS\"],\"latencies\":[34]}]") || actual.equals("[{\"name\":\"Bar\",\"events\":[\"SUCCESS\"],\"latencies\":[34]},{\"name\":\"Foo\",\"events\":[\"SUCCESS\"],\"latencies\":[23]}]"));
}
Also used : ArrayList(java.util.ArrayList) HystrixRequestEvents(com.netflix.hystrix.metric.HystrixRequestEvents) HystrixInvokableInfo(com.netflix.hystrix.HystrixInvokableInfo) Test(org.junit.Test)

Example 12 with HystrixInvokableInfo

use of com.netflix.hystrix.HystrixInvokableInfo in project Hystrix by Netflix.

the class SerialHystrixRequestEventsTest method testSingleFailureFallbackFailure.

@Test
public void testSingleFailureFallbackFailure() throws IOException {
    List<HystrixInvokableInfo<?>> executions = new ArrayList<HystrixInvokableInfo<?>>();
    executions.add(new SimpleExecution(fooKey, 104, HystrixEventType.FAILURE, HystrixEventType.FALLBACK_FAILURE));
    HystrixRequestEvents request = new HystrixRequestEvents(executions);
    String actual = SerialHystrixRequestEvents.toJsonString(request);
    assertEquals("[{\"name\":\"Foo\",\"events\":[\"FAILURE\",\"FALLBACK_FAILURE\"],\"latencies\":[104]}]", actual);
}
Also used : ArrayList(java.util.ArrayList) HystrixRequestEvents(com.netflix.hystrix.metric.HystrixRequestEvents) HystrixInvokableInfo(com.netflix.hystrix.HystrixInvokableInfo) Test(org.junit.Test)

Example 13 with HystrixInvokableInfo

use of com.netflix.hystrix.HystrixInvokableInfo in project Hystrix by Netflix.

the class SerialHystrixRequestEventsTest method testTwoSuccessesOneFailureSameKey.

@Test
public void testTwoSuccessesOneFailureSameKey() throws IOException {
    List<HystrixInvokableInfo<?>> executions = new ArrayList<HystrixInvokableInfo<?>>();
    HystrixInvokableInfo<Integer> foo1 = new SimpleExecution(fooKey, 10, HystrixEventType.SUCCESS);
    HystrixInvokableInfo<Integer> foo2 = new SimpleExecution(fooKey, 67, HystrixEventType.FAILURE, HystrixEventType.FALLBACK_SUCCESS);
    HystrixInvokableInfo<Integer> foo3 = new SimpleExecution(fooKey, 11, HystrixEventType.SUCCESS);
    executions.add(foo1);
    executions.add(foo2);
    executions.add(foo3);
    HystrixRequestEvents request = new HystrixRequestEvents(executions);
    String actual = SerialHystrixRequestEvents.toJsonString(request);
    assertTrue(actual.equals("[{\"name\":\"Foo\",\"events\":[\"SUCCESS\"],\"latencies\":[10,11]},{\"name\":\"Foo\",\"events\":[\"FAILURE\",\"FALLBACK_SUCCESS\"],\"latencies\":[67]}]") || actual.equals("[{\"name\":\"Foo\",\"events\":[\"FAILURE\",\"FALLBACK_SUCCESS\"],\"latencies\":[67]},{\"name\":\"Foo\",\"events\":[\"SUCCESS\"],\"latencies\":[10,11]}]"));
}
Also used : ArrayList(java.util.ArrayList) HystrixRequestEvents(com.netflix.hystrix.metric.HystrixRequestEvents) HystrixInvokableInfo(com.netflix.hystrix.HystrixInvokableInfo) Test(org.junit.Test)

Example 14 with HystrixInvokableInfo

use of com.netflix.hystrix.HystrixInvokableInfo in project Hystrix by Netflix.

the class SerialHystrixRequestEventsTest method testSingleShortCircuitedFallbackSuccess.

@Test
public void testSingleShortCircuitedFallbackSuccess() throws IOException {
    List<HystrixInvokableInfo<?>> executions = new ArrayList<HystrixInvokableInfo<?>>();
    executions.add(new SimpleExecution(fooKey, 1, HystrixEventType.SHORT_CIRCUITED, HystrixEventType.FALLBACK_SUCCESS));
    HystrixRequestEvents request = new HystrixRequestEvents(executions);
    String actual = SerialHystrixRequestEvents.toJsonString(request);
    assertEquals("[{\"name\":\"Foo\",\"events\":[\"SHORT_CIRCUITED\",\"FALLBACK_SUCCESS\"],\"latencies\":[1]}]", actual);
}
Also used : ArrayList(java.util.ArrayList) HystrixRequestEvents(com.netflix.hystrix.metric.HystrixRequestEvents) HystrixInvokableInfo(com.netflix.hystrix.HystrixInvokableInfo) Test(org.junit.Test)

Example 15 with HystrixInvokableInfo

use of com.netflix.hystrix.HystrixInvokableInfo in project Hystrix by Netflix.

the class SerialHystrixRequestEventsTest method testSingleSuccess.

@Test
public void testSingleSuccess() throws IOException {
    List<HystrixInvokableInfo<?>> executions = new ArrayList<HystrixInvokableInfo<?>>();
    executions.add(new SimpleExecution(fooKey, 100, HystrixEventType.SUCCESS));
    HystrixRequestEvents request = new HystrixRequestEvents(executions);
    String actual = SerialHystrixRequestEvents.toJsonString(request);
    assertEquals("[{\"name\":\"Foo\",\"events\":[\"SUCCESS\"],\"latencies\":[100]}]", actual);
}
Also used : ArrayList(java.util.ArrayList) HystrixRequestEvents(com.netflix.hystrix.metric.HystrixRequestEvents) HystrixInvokableInfo(com.netflix.hystrix.HystrixInvokableInfo) Test(org.junit.Test)

Aggregations

HystrixInvokableInfo (com.netflix.hystrix.HystrixInvokableInfo)33 Test (org.junit.Test)31 HystrixRequestEvents (com.netflix.hystrix.metric.HystrixRequestEvents)22 ArrayList (java.util.ArrayList)21 BasicHystrixTest (com.netflix.hystrix.contrib.javanica.test.common.BasicHystrixTest)8 User (com.netflix.hystrix.contrib.javanica.test.common.domain.User)6 HttpResourceGroup (com.netflix.ribbon.http.HttpResourceGroup)2 FallbackHandler (com.netflix.ribbon.hystrix.FallbackHandler)2 ByteBuf (io.netty.buffer.ByteBuf)2 Map (java.util.Map)2 Observable (rx.Observable)2 Func1 (rx.functions.Func1)2 HttpClientResponse (io.reactivex.netty.protocol.http.client.HttpClientResponse)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1