Search in sources :

Example 6 with HystrixInvokableInfo

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

the class SerialHystrixRequestEventsTest method testSingleSemaphoreRejectedFallbackSuccess.

@Test
public void testSingleSemaphoreRejectedFallbackSuccess() throws IOException {
    List<HystrixInvokableInfo<?>> executions = new ArrayList<HystrixInvokableInfo<?>>();
    executions.add(new SimpleExecution(fooKey, 1, HystrixEventType.SEMAPHORE_REJECTED, HystrixEventType.FALLBACK_SUCCESS));
    HystrixRequestEvents request = new HystrixRequestEvents(executions);
    String actual = SerialHystrixRequestEvents.toJsonString(request);
    assertEquals("[{\"name\":\"Foo\",\"events\":[\"SEMAPHORE_REJECTED\",\"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 7 with HystrixInvokableInfo

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

the class SerialHystrixRequestEventsTest method testEmpty.

@Test
public void testEmpty() throws IOException {
    HystrixRequestEvents request = new HystrixRequestEvents(new ArrayList<HystrixInvokableInfo<?>>());
    String actual = SerialHystrixRequestEvents.toJsonString(request);
    assertEquals("[]", actual);
}
Also used : HystrixRequestEvents(com.netflix.hystrix.metric.HystrixRequestEvents) HystrixInvokableInfo(com.netflix.hystrix.HystrixInvokableInfo) Test(org.junit.Test)

Example 8 with HystrixInvokableInfo

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

the class SerialHystrixRequestEventsTest method testSingleFailureFallbackMissing.

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

Example 9 with HystrixInvokableInfo

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

the class SerialHystrixRequestEventsTest method testSingleTimeoutFallbackSuccess.

@Test
public void testSingleTimeoutFallbackSuccess() throws IOException {
    List<HystrixInvokableInfo<?>> executions = new ArrayList<HystrixInvokableInfo<?>>();
    executions.add(new SimpleExecution(fooKey, 105, HystrixEventType.TIMEOUT, HystrixEventType.FALLBACK_SUCCESS));
    HystrixRequestEvents request = new HystrixRequestEvents(executions);
    String actual = SerialHystrixRequestEvents.toJsonString(request);
    assertEquals("[{\"name\":\"Foo\",\"events\":[\"TIMEOUT\",\"FALLBACK_SUCCESS\"],\"latencies\":[105]}]", 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 HystrixInvokableInfo

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

the class SerialHystrixRequestEventsTest method testMultipleCacheKeys.

@Test
public void testMultipleCacheKeys() throws IOException {
    List<HystrixInvokableInfo<?>> executions = new ArrayList<HystrixInvokableInfo<?>>();
    HystrixInvokableInfo<Integer> foo1 = new SimpleExecution(fooKey, 23, "cacheKeyA", HystrixEventType.SUCCESS);
    HystrixInvokableInfo<Integer> cachedFoo1 = new SimpleExecution(fooKey, "cacheKeyA");
    HystrixInvokableInfo<Integer> foo2 = new SimpleExecution(fooKey, 67, "cacheKeyB", HystrixEventType.SUCCESS);
    HystrixInvokableInfo<Integer> cachedFoo2 = new SimpleExecution(fooKey, "cacheKeyB");
    executions.add(foo1);
    executions.add(cachedFoo1);
    executions.add(foo2);
    executions.add(cachedFoo2);
    HystrixRequestEvents request = new HystrixRequestEvents(executions);
    String actual = SerialHystrixRequestEvents.toJsonString(request);
    assertTrue(actual.equals("[{\"name\":\"Foo\",\"events\":[\"SUCCESS\"],\"latencies\":[67],\"cached\":1},{\"name\":\"Foo\",\"events\":[\"SUCCESS\"],\"latencies\":[23],\"cached\":1}]") || actual.equals("[{\"name\":\"Foo\",\"events\":[\"SUCCESS\"],\"latencies\":[23],\"cached\":1},{\"name\":\"Foo\",\"events\":[\"SUCCESS\"],\"latencies\":[67],\"cached\":1}]"));
}
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