use of org.apache.ignite.internal.processors.tracing.SpanType.EXCHANGE_FUTURE in project ignite by apache.
the class OpenCensusTracingSpiTest method testPartitionsMapExchangeTracing.
/**
* Test checks that PME process in case of node left discovery event is traced correctly in positive case.
*/
@Test
public void testPartitionsMapExchangeTracing() throws Exception {
long curTopVer = grid(0).cluster().topologyVersion();
String leftNodeId = grid(GRID_CNT - 1).localNode().id().toString();
stopGrid(GRID_CNT - 1);
awaitPartitionMapExchange();
handler().flush();
// Check PME for NODE_LEFT event on remaining nodes:
for (int i = 0; i < GRID_CNT - 1; i++) {
List<SpanData> exchFutSpans = handler().spansReportedByNode(getTestIgniteInstanceName(i)).filter(span -> EXCHANGE_FUTURE.spanName().equals(span.getName())).filter(span -> span.getStatus() == Status.OK).filter(span -> AttributeValue.stringAttributeValue(String.valueOf(EventType.EVT_NODE_LEFT)).equals(span.getAttributes().getAttributeMap().get(SpanTags.tag(SpanTags.EVENT, SpanTags.TYPE)))).filter(span -> stringAttributeValue(leftNodeId).equals(span.getAttributes().getAttributeMap().get(SpanTags.tag(SpanTags.EVENT_NODE, SpanTags.ID)))).collect(Collectors.toList());
Assert.assertTrue(String.format("%s span not found (or more than 1), nodeId=%d, exchFutSpans=%s", EXCHANGE_FUTURE, i, exchFutSpans), exchFutSpans.size() == 1);
exchFutSpans.forEach(span -> {
SpanData parentSpan = handler().spanById(span.getParentSpanId());
Assert.assertNotNull("Parent span doesn't exist for " + span, parentSpan);
Assert.assertEquals("Parent span name is invalid " + parentSpan, DISCOVERY_NODE_LEFT.spanName(), parentSpan.getName());
Assert.assertEquals("Parent span is not related to joined node " + parentSpan, stringAttributeValue(leftNodeId), parentSpan.getAttributes().getAttributeMap().get(SpanTags.tag(SpanTags.EVENT_NODE, SpanTags.ID)));
Assert.assertEquals("Exchange future major topology version is invalid " + span, AttributeValue.stringAttributeValue(String.valueOf(curTopVer + 1)), span.getAttributes().getAttributeMap().get(SpanTags.tag(SpanTags.RESULT, SpanTags.TOPOLOGY_VERSION, SpanTags.MAJOR)));
Assert.assertEquals("Exchange future minor version is invalid " + span, AttributeValue.stringAttributeValue("0"), span.getAttributes().getAttributeMap().get(SpanTags.tag(SpanTags.RESULT, SpanTags.TOPOLOGY_VERSION, SpanTags.MINOR)));
});
}
}
Aggregations