Search in sources :

Example 1 with ActualTrace

use of com.navercorp.pinpoint.test.wrapper.ActualTrace in project pinpoint by naver.

the class PluginVerifierExternalAdaptor method verifyTrace.

@Override
public void verifyTrace(ExpectedTrace... expectations) {
    if (ArrayUtils.isEmpty(expectations)) {
        throw new IllegalArgumentException("No expectations");
    }
    for (ExpectedTrace expected : expectations) {
        ResolvedExpectedTrace resolved = resolveExpectedTrace(expected, null);
        final Item<SpanType> actualItem = popItem();
        if (actualItem == null) {
            AssertionErrorBuilder builder = new AssertionErrorBuilder("actualItem is null", resolved, "null");
            builder.throwAssertionError();
        }
        final SpanType actual = actualItem.getValue();
        ActualTrace wrapped = ActualTraceFactory.wrap(actual);
        verifySpan(resolved, wrapped);
        verifyAsyncTraces(expected, wrapped);
    }
}
Also used : ExpectedTrace(com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace) SpanType(com.navercorp.pinpoint.profiler.context.SpanType) AssertionErrorBuilder(com.navercorp.pinpoint.test.util.AssertionErrorBuilder) ActualTrace(com.navercorp.pinpoint.test.wrapper.ActualTrace)

Example 2 with ActualTrace

use of com.navercorp.pinpoint.test.wrapper.ActualTrace in project pinpoint by naver.

the class PluginVerifierExternalAdaptor method verifyDiscreteTraceBlock.

public void verifyDiscreteTraceBlock(ExpectedTrace[] expectations, Integer asyncId) {
    if (ArrayUtils.isEmpty(expectations)) {
        throw new IllegalArgumentException("No expectations");
    }
    ExpectedTrace expected = expectations[0];
    ResolvedExpectedTrace resolved = resolveExpectedTrace(expected, asyncId);
    int i = 0;
    Iterator<SpanType> iterator = this.handler.getOrderedSpanRecorder().iterator();
    while (iterator.hasNext()) {
        final SpanType next = iterator.next();
        ActualTrace actual = ActualTraceFactory.wrap(next);
        try {
            verifySpan(resolved, actual);
        } catch (AssertionError e) {
            continue;
        }
        iterator.remove();
        verifyAsyncTraces(expected, actual);
        if (++i == expectations.length) {
            return;
        }
        expected = expectations[i];
        resolved = resolveExpectedTrace(expected, asyncId);
    }
    throw new AssertionError("Failed to match " + i + "th expectation: " + resolved);
}
Also used : ExpectedTrace(com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace) SpanType(com.navercorp.pinpoint.profiler.context.SpanType) ActualTrace(com.navercorp.pinpoint.test.wrapper.ActualTrace)

Example 3 with ActualTrace

use of com.navercorp.pinpoint.test.wrapper.ActualTrace in project pinpoint by naver.

the class PluginVerifierExternalAdaptor method hasTrace.

private boolean hasTrace(ExpectedTrace expectedTrace) {
    if (expectedTrace == null) {
        return false;
    }
    ResolvedExpectedTrace resolvedExpectedTrace = resolveExpectedTrace(expectedTrace, null);
    Iterator<SpanType> iterator = this.handler.getOrderedSpanRecorder().iterator();
    while (iterator.hasNext()) {
        try {
            SpanType value = iterator.next();
            ActualTrace actualTrace = ActualTraceFactory.wrapOrNull(value);
            if (actualTrace == null) {
                continue;
            }
            verifySpan(resolvedExpectedTrace, actualTrace);
            return true;
        } catch (Throwable ignore) {
        }
    }
    return false;
}
Also used : SpanType(com.navercorp.pinpoint.profiler.context.SpanType) ActualTrace(com.navercorp.pinpoint.test.wrapper.ActualTrace)

Aggregations

SpanType (com.navercorp.pinpoint.profiler.context.SpanType)3 ActualTrace (com.navercorp.pinpoint.test.wrapper.ActualTrace)3 ExpectedTrace (com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace)2 AssertionErrorBuilder (com.navercorp.pinpoint.test.util.AssertionErrorBuilder)1