use of com.microsoft.applicationinsights.smoketest.schemav2.Data in project ApplicationInsights-Java by microsoft.
the class JmsTest method doMostBasicTest.
@Test
@TargetUri("/sendMessage")
public void doMostBasicTest() throws Exception {
List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 2);
Envelope rdEnvelope1 = getRequestEnvelope(rdList, "GET /sendMessage");
String operationId = rdEnvelope1.getTags().get("ai.operation.id");
List<Envelope> rddList = mockedIngestion.waitForItemsInOperation("RemoteDependencyData", 2, operationId);
assertEquals(0, mockedIngestion.getCountForType("EventData"));
Envelope rdEnvelope2 = getRequestEnvelope(rdList, "message process");
Envelope rddEnvelope1 = getDependencyEnvelope(rddList, "message send");
Envelope rddEnvelope2 = getDependencyEnvelope(rddList, "GET /");
RequestData rd1 = (RequestData) ((Data<?>) rdEnvelope1.getData()).getBaseData();
RequestData rd2 = (RequestData) ((Data<?>) rdEnvelope2.getData()).getBaseData();
RemoteDependencyData rdd1 = (RemoteDependencyData) ((Data<?>) rddEnvelope1.getData()).getBaseData();
RemoteDependencyData rdd2 = (RemoteDependencyData) ((Data<?>) rddEnvelope2.getData()).getBaseData();
assertEquals("GET /sendMessage", rd1.getName());
assertTrue(rd1.getProperties().isEmpty());
assertTrue(rd1.getSuccess());
assertEquals("message send", rdd1.getName());
assertNull(rdd1.getData());
assertEquals("Queue Message | jms", rdd1.getType());
assertEquals("message", rdd1.getTarget());
assertTrue(rdd1.getProperties().isEmpty());
assertTrue(rdd1.getSuccess());
assertEquals("message process", rd2.getName());
assertEquals("message", rd2.getSource());
assertTrue(rd2.getProperties().isEmpty());
assertTrue(rd2.getSuccess());
assertEquals("GET /", rdd2.getName());
assertEquals("https://www.bing.com", rdd2.getData());
assertEquals("Http", rdd2.getType());
assertEquals("www.bing.com", rdd2.getTarget());
assertTrue(rdd2.getProperties().isEmpty());
assertTrue(rdd2.getSuccess());
assertParentChild(rd1, rdEnvelope1, rddEnvelope1, "GET /sendMessage");
assertParentChild(rdd1.getId(), rddEnvelope1, rdEnvelope2, "GET /sendMessage", "message process", false);
assertParentChild(rd2.getId(), rdEnvelope2, rddEnvelope2, "message process", "message process", false);
}
use of com.microsoft.applicationinsights.smoketest.schemav2.Data in project ApplicationInsights-Java by microsoft.
the class SpringCloudStreamControllerSpansEnabledTest method doMostBasicTest.
@Test
@TargetUri("/sendMessage")
public void doMostBasicTest() throws Exception {
List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 2);
Envelope rdEnvelope1 = rdList.get(0);
String operationId = rdEnvelope1.getTags().get("ai.operation.id");
List<Envelope> rddList = mockedIngestion.waitForItemsInOperation("RemoteDependencyData", 2, operationId);
assertEquals(0, mockedIngestion.getCountForType("EventData"));
Envelope rdEnvelope2 = rdList.get(1);
Envelope rddEnvelope1 = rddList.get(0);
Envelope rddEnvelope2 = rddList.get(1);
RequestData rd1 = (RequestData) ((Data<?>) rdEnvelope1.getData()).getBaseData();
RequestData rd2 = (RequestData) ((Data<?>) rdEnvelope2.getData()).getBaseData();
RemoteDependencyData rdd1 = (RemoteDependencyData) ((Data<?>) rddEnvelope1.getData()).getBaseData();
RemoteDependencyData rdd2 = (RemoteDependencyData) ((Data<?>) rddEnvelope2.getData()).getBaseData();
if (!rdd1.getName().equals("GreetingsController.sendMessage")) {
RemoteDependencyData rddTemp = rdd1;
rdd1 = rdd2;
rdd2 = rddTemp;
Envelope rddEnvelopeTemp = rddEnvelope1;
rddEnvelope1 = rddEnvelope2;
rddEnvelope2 = rddEnvelopeTemp;
}
assertEquals("GET /sendMessage", rd1.getName());
assertTrue(rd1.getProperties().isEmpty());
assertTrue(rd1.getSuccess());
assertEquals("GreetingsController.sendMessage", rdd1.getName());
assertNull(rdd1.getData());
assertEquals("InProc", rdd1.getType());
assertNull(rdd1.getTarget());
assertTrue(rdd1.getProperties().isEmpty());
assertTrue(rdd1.getSuccess());
assertEquals("greetings send", rdd2.getName());
assertNull(rdd2.getData());
assertEquals("Queue Message | kafka", rdd2.getType());
assertEquals("greetings", rdd2.getTarget());
assertTrue(rdd2.getProperties().isEmpty());
assertTrue(rdd2.getSuccess());
assertEquals("greetings process", rd2.getName());
assertEquals("greetings", rd2.getSource());
assertTrue(rd2.getProperties().isEmpty());
assertTrue(rd2.getSuccess());
assertTrue(rd2.getMeasurements().containsKey("timeSinceEnqueued"));
assertParentChild(rd1, rdEnvelope1, rddEnvelope1, "GET /sendMessage");
assertParentChild(rdd1, rddEnvelope1, rddEnvelope2, "GET /sendMessage");
assertParentChild(rdd2.getId(), rddEnvelope2, rdEnvelope2, "GET /sendMessage", "greetings process", false);
}
use of com.microsoft.applicationinsights.smoketest.schemav2.Data in project ApplicationInsights-Java by microsoft.
the class SpringBootAutoTest method test.
@Test
@TargetUri("/test")
public void test() throws Exception {
List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
List<Envelope> mdList = mockedIngestion.waitForMessageItemsInRequest(1);
Envelope rdEnvelope = rdList.get(0);
Envelope mdEnvelope = mdList.get(0);
RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
MessageData md = (MessageData) ((Data<?>) mdEnvelope.getData()).getBaseData();
assertEquals("GET /test", rd.getName());
assertEquals("200", rd.getResponseCode());
assertEquals("z", rd.getProperties().get("tenant"));
assertEquals(1, rd.getProperties().size());
assertTrue(rd.getSuccess());
assertEquals("hello", md.getMessage());
assertEquals(SeverityLevel.Information, md.getSeverityLevel());
assertEquals("Logger", md.getProperties().get("SourceType"));
assertEquals("INFO", md.getProperties().get("LoggingLevel"));
assertEquals("smoketestapp", md.getProperties().get("LoggerName"));
assertNotNull(md.getProperties().get("ThreadName"));
assertEquals("z", rd.getProperties().get("tenant"));
assertEquals(5, md.getProperties().size());
}
use of com.microsoft.applicationinsights.smoketest.schemav2.Data in project ApplicationInsights-Java by microsoft.
the class StatsbeatSmokeTest method testStatsbeat.
@Test
@TargetUri(value = "/index.jsp")
public void testStatsbeat() throws Exception {
List<Envelope> metrics = mockedIngestion.waitForItems(getMetricPredicate("Feature"), 2, 70, TimeUnit.SECONDS);
MetricData data = (MetricData) ((Data<?>) metrics.get(0).getData()).getBaseData();
assertCommon(data);
assertNotNull(data.getProperties().get("feature"));
assertNotNull(data.getProperties().get("type"));
assertEquals("0", data.getProperties().get("type"));
assertEquals(9, data.getProperties().size());
MetricData instrumentationData = (MetricData) ((Data<?>) metrics.get(1).getData()).getBaseData();
assertCommon(instrumentationData);
assertNotNull(instrumentationData.getProperties().get("feature"));
assertNotNull(instrumentationData.getProperties().get("type"));
assertEquals("1", instrumentationData.getProperties().get("type"));
assertEquals(9, instrumentationData.getProperties().size());
List<Envelope> attachMetrics = mockedIngestion.waitForItems(getMetricPredicate("Attach"), 1, 70, TimeUnit.SECONDS);
MetricData attachData = (MetricData) ((Data<?>) attachMetrics.get(0).getData()).getBaseData();
assertCommon(attachData);
assertNotNull(attachData.getProperties().get("rpId"));
assertEquals(8, attachData.getProperties().size());
List<Envelope> requestSuccessCountMetrics = mockedIngestion.waitForItems(getMetricPredicate("Request Success Count"), 1, 70, TimeUnit.SECONDS);
MetricData requestSuccessCountData = (MetricData) ((Data<?>) requestSuccessCountMetrics.get(0).getData()).getBaseData();
assertCommon(requestSuccessCountData);
assertNotNull(requestSuccessCountData.getProperties().get("endpoint"));
assertNotNull(requestSuccessCountData.getProperties().get("host"));
assertEquals(9, requestSuccessCountData.getProperties().size());
List<Envelope> requestDurationMetrics = mockedIngestion.waitForItems(getMetricPredicate("Request Duration"), 1, 70, TimeUnit.SECONDS);
MetricData requestDurationData = (MetricData) ((Data<?>) requestDurationMetrics.get(0).getData()).getBaseData();
assertCommon(requestDurationData);
assertNotNull(requestSuccessCountData.getProperties().get("endpoint"));
assertNotNull(requestSuccessCountData.getProperties().get("host"));
assertEquals(9, requestDurationData.getProperties().size());
}
use of com.microsoft.applicationinsights.smoketest.schemav2.Data in project ApplicationInsights-Java by microsoft.
the class SpringBootAutoTest method doDelayedSystemExitTest.
@Test
@TargetUri("/delayedSystemExit")
public void doDelayedSystemExitTest() throws Exception {
mockedIngestion.waitForItems("RequestData", 1);
mockedIngestion.waitForItem(input -> {
if (!"MessageData".equals(input.getData().getBaseType())) {
return false;
}
MessageData data = (MessageData) ((Data<?>) input.getData()).getBaseData();
return data.getMessage().equals("this is an error right before shutdown");
}, 10, TimeUnit.SECONDS);
}
Aggregations