Search in sources :

Example 21 with RemoteDependencyData

use of com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData in project ApplicationInsights-Java by microsoft.

the class TelemetryFilteringSmokeTest method testRegularJdbc.

@Test
@TargetUri("/regular-jdbc")
public void testRegularJdbc() throws Exception {
    List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
    Envelope rdEnvelope = rdList.get(0);
    String operationId = rdEnvelope.getTags().get("ai.operation.id");
    List<Envelope> rddList = mockedIngestion.waitForItemsInOperation("RemoteDependencyData", 1, operationId);
    assertEquals(0, mockedIngestion.getCountForType("EventData"));
    Envelope rddEnvelope = rddList.get(0);
    RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
    RemoteDependencyData rdd = (RemoteDependencyData) ((Data<?>) rddEnvelope.getData()).getBaseData();
    assertEquals("87654321-0000-0000-0000-0FEEDDADBEEF", rdEnvelope.getIKey());
    assertTrue(rd.getSuccess());
    assertEquals("SQL", rdd.getType());
    assertEquals("testdb", rdd.getTarget());
    assertEquals("SELECT testdb.abc", rdd.getName());
    assertEquals("select * from abc", rdd.getData());
    assertEquals("87654321-0000-0000-0000-0FEEDDADBEEF", rddEnvelope.getIKey());
    assertTrue(rdd.getSuccess());
    assertParentChild(rd, rdEnvelope, rddEnvelope, "GET /TelemetryFiltering/*");
}
Also used : RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) RemoteDependencyData(com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) AiSmokeTest(com.microsoft.applicationinsights.smoketest.AiSmokeTest) Test(org.junit.Test) TargetUri(com.microsoft.applicationinsights.smoketest.TargetUri)

Example 22 with RemoteDependencyData

use of com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData in project ApplicationInsights-Java by microsoft.

the class TelemetryFilteringSmokeTest method testNoisyJdbc.

@Test
@TargetUri("/noisy-jdbc")
public void testNoisyJdbc() throws Exception {
    List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
    Thread.sleep(10000);
    assertEquals(0, mockedIngestion.getCountForType("RemoteDependencyData"));
    Envelope rdEnvelope = rdList.get(0);
    RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
    assertEquals("00000000-0000-0000-0000-0FEEDDADBEEF", rdEnvelope.getIKey());
    assertTrue(rd.getSuccess());
}
Also used : RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) AiSmokeTest(com.microsoft.applicationinsights.smoketest.AiSmokeTest) Test(org.junit.Test) TargetUri(com.microsoft.applicationinsights.smoketest.TargetUri)

Example 23 with RemoteDependencyData

use of com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData in project ApplicationInsights-Java by microsoft.

the class SpringBootControllerSpansEnabledTest method testResultCodeWhenRestControllerThrows.

@Test
@TargetUri("/throwsException")
public void testResultCodeWhenRestControllerThrows() throws Exception {
    List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
    Envelope rdEnvelope = rdList.get(0);
    String operationId = rdEnvelope.getTags().get("ai.operation.id");
    List<Envelope> rddList = mockedIngestion.waitForItemsInOperation("RemoteDependencyData", 1, operationId);
    List<Envelope> edList = mockedIngestion.waitForItems(new Predicate<Envelope>() {

        @Override
        public boolean test(Envelope input) {
            if (!"ExceptionData".equals(input.getData().getBaseType())) {
                return false;
            }
            if (!operationId.equals(input.getTags().get("ai.operation.id"))) {
                return false;
            }
            // lastly, filter out ExceptionData captured from tomcat logger
            ExceptionData data = (ExceptionData) ((Data<?>) input.getData()).getBaseData();
            return !data.getProperties().containsKey("LoggerName");
        }
    }, 2, 10, TimeUnit.SECONDS);
    assertEquals(0, mockedIngestion.getCountForType("EventData"));
    Envelope rddEnvelope1 = rddList.get(0);
    Envelope edEnvelope1 = edList.get(0);
    RequestData rd = getTelemetryDataForType(0, "RequestData");
    RemoteDependencyData rdd1 = (RemoteDependencyData) ((Data<?>) rddEnvelope1.getData()).getBaseData();
    assertEquals("GET /SpringBootTest/throwsException", rd.getName());
    assertEquals("500", rd.getResponseCode());
    assertTrue(rd.getProperties().isEmpty());
    assertFalse(rd.getSuccess());
    assertEquals("TestController.resultCodeTest", rdd1.getName());
    assertNull(rdd1.getData());
    assertEquals("InProc", rdd1.getType());
    assertNull(rdd1.getTarget());
    assertTrue(rdd1.getProperties().isEmpty());
    assertFalse(rdd1.getSuccess());
    assertParentChild(rd, rdEnvelope, rddEnvelope1, "GET /SpringBootTest/throwsException");
    assertParentChild(rdd1, rddEnvelope1, edEnvelope1, "GET /SpringBootTest/throwsException");
}
Also used : RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) ExceptionData(com.microsoft.applicationinsights.smoketest.schemav2.ExceptionData) RemoteDependencyData(com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData) RemoteDependencyData(com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData) RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) EventData(com.microsoft.applicationinsights.smoketest.schemav2.EventData) ExceptionData(com.microsoft.applicationinsights.smoketest.schemav2.ExceptionData) Data(com.microsoft.applicationinsights.smoketest.schemav2.Data) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) Test(org.junit.Test)

Example 24 with RemoteDependencyData

use of com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData in project ApplicationInsights-Java by microsoft.

the class SpringBootTest method testAsyncDependencyCall.

@Test
@TargetUri("/asyncDependencyCall")
public void testAsyncDependencyCall() throws Exception {
    List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
    Envelope rdEnvelope = rdList.get(0);
    String operationId = rdEnvelope.getTags().get("ai.operation.id");
    List<Envelope> rddList = mockedIngestion.waitForItemsInOperation("RemoteDependencyData", 1, operationId);
    assertEquals(0, mockedIngestion.getCountForType("EventData"));
    Envelope rddEnvelope1 = rddList.get(0);
    RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
    RemoteDependencyData rdd1 = (RemoteDependencyData) ((Data<?>) rddEnvelope1.getData()).getBaseData();
    assertEquals("GET /SpringBootTest/asyncDependencyCall", rd.getName());
    assertEquals("200", rd.getResponseCode());
    assertTrue(rd.getProperties().isEmpty());
    assertTrue(rd.getSuccess());
    assertEquals("GET /", rdd1.getName());
    assertEquals("https://www.bing.com", rdd1.getData());
    assertEquals("www.bing.com", rdd1.getTarget());
    assertTrue(rdd1.getProperties().isEmpty());
    assertTrue(rdd1.getSuccess());
    assertParentChild(rd, rdEnvelope, rddEnvelope1, "GET /SpringBootTest/asyncDependencyCall");
}
Also used : RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) RemoteDependencyData(com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) Test(org.junit.Test)

Example 25 with RemoteDependencyData

use of com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData in project ApplicationInsights-Java by microsoft.

the class SpringCloudStreamTest 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", 1, operationId);
    assertEquals(0, mockedIngestion.getCountForType("EventData"));
    Envelope rdEnvelope2 = rdList.get(1);
    Envelope rddEnvelope1 = rddList.get(0);
    RequestData rd1 = (RequestData) ((Data<?>) rdEnvelope1.getData()).getBaseData();
    RequestData rd2 = (RequestData) ((Data<?>) rdEnvelope2.getData()).getBaseData();
    RemoteDependencyData rdd1 = (RemoteDependencyData) ((Data<?>) rddEnvelope1.getData()).getBaseData();
    assertEquals("GET /sendMessage", rd1.getName());
    assertTrue(rd1.getProperties().isEmpty());
    assertTrue(rd1.getSuccess());
    assertEquals("greetings send", rdd1.getName());
    assertNull(rdd1.getData());
    assertEquals("Queue Message | kafka", rdd1.getType());
    assertEquals("greetings", rdd1.getTarget());
    assertTrue(rdd1.getProperties().isEmpty());
    assertTrue(rdd1.getSuccess());
    assertEquals("greetings process", rd2.getName());
    assertEquals("greetings", rd2.getSource());
    assertTrue(rd2.getProperties().isEmpty());
    assertTrue(rd2.getSuccess());
    assertParentChild(rd1, rdEnvelope1, rddEnvelope1, "GET /sendMessage");
    assertParentChild(rdd1.getId(), rddEnvelope1, rdEnvelope2, "GET /sendMessage", "greetings process", false);
}
Also used : RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) RemoteDependencyData(com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) Test(org.junit.Test)

Aggregations

Envelope (com.microsoft.applicationinsights.smoketest.schemav2.Envelope)27 RemoteDependencyData (com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData)26 Test (org.junit.Test)26 RequestData (com.microsoft.applicationinsights.smoketest.schemav2.RequestData)25 AiSmokeTest (com.microsoft.applicationinsights.smoketest.AiSmokeTest)10 TargetUri (com.microsoft.applicationinsights.smoketest.TargetUri)10 Data (com.microsoft.applicationinsights.smoketest.schemav2.Data)2 ExceptionData (com.microsoft.applicationinsights.smoketest.schemav2.ExceptionData)2 EventData (com.microsoft.applicationinsights.smoketest.schemav2.EventData)1 ExceptionDetails (com.microsoft.applicationinsights.smoketest.schemav2.ExceptionDetails)1