use of com.microsoft.applicationinsights.smoketest.schemav2.RequestData in project ApplicationInsights-Java by microsoft.
the class CoreAndFilterTests method validateSlowTest.
private void validateSlowTest(int expectedDurationSeconds, String operationName) throws Exception {
List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
Envelope rdEnvelope = rdList.get(0);
RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
long actual = rd.getDuration().getTotalMilliseconds();
long expected = (new Duration(0, 0, 0, expectedDurationSeconds, 0).getTotalMilliseconds());
// 2 seconds
long tolerance = 2 * 1000;
long min = expected - tolerance;
long max = expected + tolerance;
System.out.printf("Slow response time: expected=%d, actual=%d%n", expected, actual);
assertThat(actual, both(greaterThanOrEqualTo(min)).and(lessThan(max)));
assertEquals(operationName, rdEnvelope.getTags().get("ai.operation.name"));
}
use of com.microsoft.applicationinsights.smoketest.schemav2.RequestData in project ApplicationInsights-Java by microsoft.
the class CustomInstrumentationTest method customInstrumentationSeven.
@Test
@TargetUri("/customInstrumentationSeven")
public void customInstrumentationSeven() throws Exception {
List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
List<Envelope> rddList = mockedIngestion.waitForItemsInRequest("RemoteDependencyData", 1);
Envelope rdEnvelope = rdList.get(0);
Envelope rddEnvelope = rddList.get(0);
RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
RemoteDependencyData rdd = (RemoteDependencyData) ((Data<?>) rddEnvelope.getData()).getBaseData();
assertTrue(rd.getSuccess());
assertEquals(rdd.getName(), "com/microsoft/applicationinsights/smoketestapp/TargetObject.seven");
assertEquals(rdd.getType(), "OTHER");
assertEquals(rdd.getSuccess(), true);
assertParentChild(rd, rdEnvelope, rddEnvelope, "GET /CustomInstrumentation/*");
}
use of com.microsoft.applicationinsights.smoketest.schemav2.RequestData in project ApplicationInsights-Java by microsoft.
the class CustomInstrumentationTest method customInstrumentationOne.
@Test
@TargetUri("/customInstrumentationOne")
public void customInstrumentationOne() throws Exception {
List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
List<Envelope> rddList = mockedIngestion.waitForItemsInRequest("RemoteDependencyData", 1);
Envelope rdEnvelope = rdList.get(0);
Envelope rddEnvelope = rddList.get(0);
RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
RemoteDependencyData rdd = (RemoteDependencyData) ((Data<?>) rddEnvelope.getData()).getBaseData();
assertTrue(rd.getSuccess());
assertEquals(rdd.getName(), "com/microsoft/applicationinsights/smoketestapp/TargetObject.one");
assertEquals(rdd.getType(), "OTHER");
assertEquals(rdd.getSuccess(), true);
assertParentChild(rd, rdEnvelope, rddEnvelope, "GET /CustomInstrumentation/*");
}
use of com.microsoft.applicationinsights.smoketest.schemav2.RequestData in project ApplicationInsights-Java by microsoft.
the class CustomInstrumentationTest method customInstrumentationNine.
@Test
@TargetUri("/customInstrumentationNine")
public void customInstrumentationNine() throws Exception {
List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
List<Envelope> rddList = mockedIngestion.waitForItemsInRequest("RemoteDependencyData", 2);
Envelope rdEnvelope = rdList.get(0);
RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
Envelope nineEnvelope = null;
Envelope httpEnvelope = null;
RemoteDependencyData nineRdd = null;
RemoteDependencyData httpRdd = null;
for (Envelope loopEnvelope : rddList) {
RemoteDependencyData loopData = (RemoteDependencyData) ((Data<?>) loopEnvelope.getData()).getBaseData();
if (loopData.getType().equals("OTHER")) {
nineEnvelope = loopEnvelope;
nineRdd = loopData;
} else if (loopData.getType().equals("Http (tracked component)")) {
httpEnvelope = loopEnvelope;
httpRdd = loopData;
} else {
throw new IllegalStateException("Unexpected remote dependency type: " + loopData.getType());
}
}
assertTrue(rd.getSuccess());
assertNotNull(nineRdd);
assertEquals(nineRdd.getName(), "com/microsoft/applicationinsights/smoketestapp/TargetObject.nine");
assertEquals(nineRdd.getType(), "OTHER");
assertEquals(nineRdd.getSuccess(), true);
assertParentChild(rd, rdEnvelope, nineEnvelope, "GET /CustomInstrumentation/*");
assertNotNull(httpRdd);
assertParentChild(rd, rdEnvelope, httpEnvelope, "GET /CustomInstrumentation/*");
}
use of com.microsoft.applicationinsights.smoketest.schemav2.RequestData in project ApplicationInsights-Java by microsoft.
the class CustomInstrumentationTest method customInstrumentationFive.
@Test
@TargetUri("/customInstrumentationFive")
public void customInstrumentationFive() throws Exception {
List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
List<Envelope> rddList = mockedIngestion.waitForItemsInRequest("RemoteDependencyData", 4);
Envelope rdEnvelope = rdList.get(0);
RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
Envelope fiveEnvelope = null;
Envelope sixEnvelope = null;
Envelope oneEnvelope = null;
Envelope twoEnvelope = null;
RemoteDependencyData fiveRdd = null;
RemoteDependencyData sixRdd = null;
RemoteDependencyData oneRdd = null;
RemoteDependencyData twoRdd = null;
for (Envelope loopEnvelope : rddList) {
RemoteDependencyData loopData = (RemoteDependencyData) ((Data<?>) loopEnvelope.getData()).getBaseData();
if (loopData.getName().endsWith(".five")) {
fiveEnvelope = loopEnvelope;
fiveRdd = loopData;
} else if (loopData.getName().endsWith(".six")) {
sixEnvelope = loopEnvelope;
sixRdd = loopData;
} else if (loopData.getName().endsWith(".one")) {
oneEnvelope = loopEnvelope;
oneRdd = loopData;
} else if (loopData.getName().endsWith(".two")) {
twoEnvelope = loopEnvelope;
twoRdd = loopData;
} else {
throw new IllegalStateException("Unexpected remote dependency: " + loopData.getName());
}
}
assertTrue(rd.getSuccess());
assertNotNull(fiveRdd);
assertEquals(fiveRdd.getName(), "com/microsoft/applicationinsights/smoketestapp/TargetObject.five");
assertEquals(fiveRdd.getType(), "OTHER");
assertEquals(fiveRdd.getSuccess(), true);
assertParentChild(rd, rdEnvelope, fiveEnvelope, "GET /CustomInstrumentation/*");
assertNotNull(sixRdd);
assertEquals(sixRdd.getName(), "com/microsoft/applicationinsights/smoketestapp/TargetObject.six");
assertEquals(sixRdd.getType(), "OTHER");
assertEquals(sixRdd.getSuccess(), true);
assertParentChild(rd, rdEnvelope, sixEnvelope, "GET /CustomInstrumentation/*");
assertNotNull(oneRdd);
assertEquals(oneRdd.getName(), "com/microsoft/applicationinsights/smoketestapp/TargetObject.one");
assertEquals(oneRdd.getType(), "OTHER");
assertEquals(oneRdd.getSuccess(), true);
assertParentChild(rd, rdEnvelope, oneEnvelope, "GET /CustomInstrumentation/*");
assertNotNull(twoRdd);
assertEquals(twoRdd.getName(), "com/microsoft/applicationinsights/smoketestapp/TargetObject.two");
assertEquals(twoRdd.getType(), "OTHER");
assertEquals(twoRdd.getSuccess(), true);
assertParentChild(rd, rdEnvelope, twoEnvelope, "GET /CustomInstrumentation/*");
}
Aggregations