Search in sources :

Example 21 with PluginTestVerifier

use of com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier in project pinpoint by naver.

the class HystrixCommand_1_3_20_IT method testTraceContinuation.

@Test
public void testTraceContinuation() throws Exception {
    String name = "Pinpoint";
    executeInvokeSayHelloCommand(name);
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    // If the trace is propagated properly to a HystrixCommand's run() method, there should be 6 total traces.
    // 3 for InvokeSayHelloCommand, 3 for SayHelloCommand.
    verifier.verifyTraceCount(6);
}
Also used : PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Example 22 with PluginTestVerifier

use of com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier in project pinpoint by naver.

the class HystrixCommand_1_3_20_IT method testSyncCall.

@Test
public void testSyncCall() throws Exception {
    String name = "Pinpoint";
    executeSayHelloCommand(name);
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    Method queue = HystrixCommand.class.getMethod("queue");
    Method executeCmd = HystrixCommand.class.getDeclaredMethod("executeCommand");
    verifier.verifyTrace(Expectations.async(Expectations.event("HYSTRIX_COMMAND", queue, annotation("hystrix.command", SayHelloCommand.class.getSimpleName())), Expectations.event("ASYNC", "Asynchronous Invocation"), Expectations.event("HYSTRIX_COMMAND_INTERNAL", executeCmd)));
    // no more traces
    verifier.verifyTraceCount(0);
}
Also used : Method(java.lang.reflect.Method) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Example 23 with PluginTestVerifier

use of com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier in project pinpoint by naver.

the class HystrixCommand_1_3_20_IT method testAsyncCall.

@Test
public void testAsyncCall() throws Exception {
    String name = "Pinpoint";
    queueAndGetSayHelloCommand(name);
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    Method queue = HystrixCommand.class.getMethod("queue");
    Method executeCmd = HystrixCommand.class.getDeclaredMethod("executeCommand");
    verifier.verifyTrace(Expectations.async(Expectations.event("HYSTRIX_COMMAND", queue, annotation("hystrix.command", SayHelloCommand.class.getSimpleName())), Expectations.event("ASYNC", "Asynchronous Invocation"), Expectations.event("HYSTRIX_COMMAND_INTERNAL", executeCmd)));
    // no more traces
    verifier.verifyTraceCount(0);
}
Also used : Method(java.lang.reflect.Method) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Example 24 with PluginTestVerifier

use of com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier in project pinpoint by naver.

the class HystrixCommand_1_3_20_IT method testExecutionExceptionWithFallback.

@Test
public void testExecutionExceptionWithFallback() throws Exception {
    Exception expectedException = new RuntimeException("expected");
    String fallbackMessage = "Fallback";
    executeThrowExceptionWithFallbackCommand(expectedException, fallbackMessage);
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    Method queue = HystrixCommand.class.getMethod("queue");
    Method executeCmd = HystrixCommand.class.getDeclaredMethod("executeCommand");
    Method getFallbackOrThrowException = HystrixCommand.class.getDeclaredMethod("getFallbackOrThrowException", HystrixEventType.class, HystrixRuntimeException.FailureType.class, String.class, Exception.class);
    verifier.verifyTrace(Expectations.async(Expectations.event("HYSTRIX_COMMAND", queue, annotation("hystrix.command", ThrowExceptionCommandWithFallback.class.getSimpleName())), Expectations.event("ASYNC", "Asynchronous Invocation"), Expectations.event("HYSTRIX_COMMAND_INTERNAL", executeCmd), Expectations.event("HYSTRIX_COMMAND_INTERNAL", getFallbackOrThrowException, annotation("hystrix.command.fallback.cause", expectedException.toString()))));
    // no more traces
    verifier.verifyTraceCount(0);
}
Also used : HystrixRuntimeException(com.netflix.hystrix.exception.HystrixRuntimeException) Method(java.lang.reflect.Method) HystrixRuntimeException(com.netflix.hystrix.exception.HystrixRuntimeException) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) HystrixRuntimeException(com.netflix.hystrix.exception.HystrixRuntimeException) Test(org.junit.Test)

Example 25 with PluginTestVerifier

use of com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier in project pinpoint by naver.

the class HystrixCommand_1_4_1_to_1_4_2_IT method testExecutionExceptionWithFallback.

@Test
public void testExecutionExceptionWithFallback() throws Exception {
    Exception expectedException = new RuntimeException("expected");
    String fallbackMessage = "Fallback";
    executeThrowExceptionWithFallbackCommand(expectedException, fallbackMessage);
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    Method queue = HystrixCommand.class.getMethod("queue");
    Class<?> executionObservableClazz = Class.forName(EXECUTION_OBSERVABLE_INNER_CLASS);
    Method executionObservableCallCmd = executionObservableClazz.getDeclaredMethod("call", Subscriber.class);
    Class<?> fallbackObservableClazz = Class.forName(FALLBACK_OBSERVABLE_INNER_CLASS);
    Method fallbackObservableCallCmd = fallbackObservableClazz.getDeclaredMethod("call", Subscriber.class);
    verifier.verifyTrace(Expectations.async(Expectations.event("HYSTRIX_COMMAND", queue, annotation("hystrix.command", ThrowExceptionCommandWithFallback.class.getSimpleName())), Expectations.event("ASYNC", "Asynchronous Invocation"), Expectations.event("HYSTRIX_COMMAND_INTERNAL", executionObservableCallCmd, annotation("hystrix.command.execution", "run")), Expectations.event("HYSTRIX_COMMAND_INTERNAL", fallbackObservableCallCmd, annotation("hystrix.command.execution", "fallback"))));
    // no more traces
    verifier.verifyTraceCount(0);
}
Also used : Method(java.lang.reflect.Method) PluginTestVerifier(com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier) Test(org.junit.Test)

Aggregations

PluginTestVerifier (com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier)101 Method (java.lang.reflect.Method)80 Test (org.junit.Test)80 SqlSession (org.apache.ibatis.session.SqlSession)8 SqlMapClientTemplate (org.springframework.orm.ibatis.SqlMapClientTemplate)8 IOException (java.io.IOException)5 RpcException (com.alibaba.dubbo.rpc.RpcException)4 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)3 Gson (com.google.gson.Gson)3 ExpectedTrace (com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace)3 HttpURLConnection (java.net.HttpURLConnection)3 URI (java.net.URI)3 URL (java.net.URL)3 FailoverClusterInvoker (com.alibaba.dubbo.rpc.cluster.support.FailoverClusterInvoker)2 AbstractProxyInvoker (com.alibaba.dubbo.rpc.proxy.AbstractProxyInvoker)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ObjectReader (com.fasterxml.jackson.databind.ObjectReader)2 GenericUrl (com.google.api.client.http.GenericUrl)2 HttpRequest (com.google.api.client.http.HttpRequest)2 HttpRequestFactory (com.google.api.client.http.HttpRequestFactory)2