use of org.apache.servicecomb.core.Invocation in project java-chassis by ServiceComb.
the class TestInvocationStageTrace method producer.
@Test
public void producer() {
invocation = new Invocation(endpoint, operationMeta, args);
stageTrace = new InvocationStageTrace(invocation);
stageTrace.start(1);
nanoTime = 2;
stageTrace.startSchedule();
nanoTime = 3;
stageTrace.startExecution();
nanoTime = 4;
stageTrace.startServerFiltersRequest();
nanoTime = 5;
stageTrace.startHandlersRequest();
nanoTime = 6;
stageTrace.startBusinessMethod();
nanoTime = 7;
stageTrace.finishBusiness();
nanoTime = 8;
stageTrace.finishHandlersResponse();
nanoTime = 9;
stageTrace.finishServerFiltersResponse();
nanoTime = 10;
stageTrace.finish();
Assert.assertEquals(1, stageTrace.getStart());
Assert.assertEquals(2, stageTrace.getStartSchedule());
Assert.assertEquals(3, stageTrace.getStartExecution());
Assert.assertEquals(4, stageTrace.getStartServerFiltersRequest());
Assert.assertEquals(5, stageTrace.getStartHandlersRequest());
Assert.assertEquals(6, stageTrace.getStartBusinessMethod());
Assert.assertEquals(7, stageTrace.getFinishBusiness());
Assert.assertEquals(8, stageTrace.getFinishHandlersResponse());
Assert.assertEquals(9, stageTrace.getFinishServerFiltersResponse());
Assert.assertEquals(10, stageTrace.getFinish());
Assert.assertEquals(1f, stageTrace.calcInvocationPrepareTime(), 0.1f);
Assert.assertEquals(1f, stageTrace.calcThreadPoolQueueTime(), 0.1f);
Assert.assertEquals(1f, stageTrace.calcServerFiltersRequestTime(), 0.1f);
Assert.assertEquals(1f, stageTrace.calcHandlersRequestTime(), 0.1f);
Assert.assertEquals(1f, stageTrace.calcBusinessTime(), 0.1f);
Assert.assertEquals(1f, stageTrace.calcHandlersResponseTime(), 0.1f);
Assert.assertEquals(1f, stageTrace.calcServerFiltersResponseTime(), 0.1f);
Assert.assertEquals(1f, stageTrace.calcSendResponseTime(), 0.1f);
Assert.assertEquals(9f, stageTrace.calcTotalTime(), 0.1f);
}
use of org.apache.servicecomb.core.Invocation in project java-chassis by ServiceComb.
the class ProcessingTimeStrategyTest method should_do_nothing_when_not_first_node_of_a_process.
@Test
void should_do_nothing_when_not_first_node_of_a_process() {
Invocation invocation = new Invocation();
invocation.setLocalContext(ImmutableMap.of(CHAIN_START_TIME, 10L, CHAIN_PROCESSING, 0L));
Throwable throwable = catchThrowable(() -> strategy.start(invocation));
assertThat(throwable).isNull();
}
use of org.apache.servicecomb.core.Invocation in project java-chassis by ServiceComb.
the class ProcessingTimeStrategyTest method should_init_when_start_as_first_chain_node.
@Test
void should_init_when_start_as_first_chain_node() {
Invocation invocation = new Invocation();
invocation.getInvocationStageTrace().start(10);
strategy.start(invocation);
assertThat(invocation.<Long>getLocalContext(CHAIN_START_TIME)).isEqualTo(10L);
assertThat(invocation.<Long>getLocalContext(CHAIN_PROCESSING)).isEqualTo(0L);
}
use of org.apache.servicecomb.core.Invocation in project java-chassis by ServiceComb.
the class PassingTimeStrategyTest method should_init_when_start_as_first_chain_node.
@Test
void should_init_when_start_as_first_chain_node() {
Invocation invocation = new Invocation();
invocation.getInvocationStageTrace().setStartTimeMillis(10);
strategy.start(invocation);
assertThat(invocation.getContext(CHAIN_START_TIME)).isEqualTo("10");
assertThat(invocation.<Long>getLocalContext(CHAIN_START_TIME)).isEqualTo(10L);
}
use of org.apache.servicecomb.core.Invocation in project java-chassis by ServiceComb.
the class PassingTimeStrategyTest method should_init_when_start_as_first_node_of_a_process_but_not_first_of_a_chain.
@Test
void should_init_when_start_as_first_node_of_a_process_but_not_first_of_a_chain() {
Invocation invocation = new Invocation();
invocation.setContext(ImmutableMap.of(CHAIN_START_TIME, "10"));
strategy.start(invocation);
assertThat(invocation.getContext(CHAIN_START_TIME)).isEqualTo("10");
assertThat(invocation.<Long>getLocalContext(CHAIN_START_TIME)).isEqualTo(10L);
}
Aggregations