Search in sources :

Example 6 with HystrixRequestEvents

use of com.netflix.hystrix.metric.HystrixRequestEvents 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 7 with HystrixRequestEvents

use of com.netflix.hystrix.metric.HystrixRequestEvents 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 8 with HystrixRequestEvents

use of com.netflix.hystrix.metric.HystrixRequestEvents 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 9 with HystrixRequestEvents

use of com.netflix.hystrix.metric.HystrixRequestEvents 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 10 with HystrixRequestEvents

use of com.netflix.hystrix.metric.HystrixRequestEvents 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

HystrixRequestEvents (com.netflix.hystrix.metric.HystrixRequestEvents)23 HystrixInvokableInfo (com.netflix.hystrix.HystrixInvokableInfo)22 Test (org.junit.Test)22 ArrayList (java.util.ArrayList)21 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)1 StringWriter (java.io.StringWriter)1