Search in sources :

Example 66 with Data

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

the class CoreAndFilterTests method testTrackException.

@Test
@TargetUri("/trackException")
public void testTrackException() throws Exception {
    List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
    Envelope rdEnvelope = rdList.get(0);
    String operationId = rdEnvelope.getTags().get("ai.operation.id");
    List<Envelope> edList = mockedIngestion.waitForItemsInOperation("ExceptionData", 3, operationId);
    assertEquals(0, mockedIngestion.getCountForType("EventData"));
    Envelope edEnvelope1 = edList.get(0);
    Envelope edEnvelope2 = edList.get(1);
    Envelope edEnvelope3 = edList.get(2);
    RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
    final String expectedName = "This is track exception.";
    final String expectedProperties = "value";
    final Double expectedMetrice = 1d;
    List<ExceptionData> exceptions = mockedIngestion.getTelemetryDataByTypeInRequest("ExceptionData");
    assertThat(exceptions, hasItem(hasException(withMessage(expectedName))));
    assertThat(exceptions, hasItem(allOf(hasException(withMessage(expectedName)), ExceptionDataMatchers.hasProperty("key", expectedProperties), hasMeasurement("key", expectedMetrice))));
    assertThat(exceptions, hasItem(allOf(hasException(withMessage(expectedName)), hasSeverityLevel(SeverityLevel.Error))));
    assertParentChild(rd, rdEnvelope, edEnvelope1, "GET /CoreAndFilter/trackException");
    assertParentChild(rd, rdEnvelope, edEnvelope2, "GET /CoreAndFilter/trackException");
    assertParentChild(rd, rdEnvelope, edEnvelope3, "GET /CoreAndFilter/trackException");
}
Also used : RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) ExceptionData(com.microsoft.applicationinsights.smoketest.schemav2.ExceptionData) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) Test(org.junit.Test)

Example 67 with Data

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

the class CoreAndFilterTests method testTrackPageView.

@Test
@TargetUri("/trackPageView")
public void testTrackPageView() throws Exception {
    List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
    Envelope rdEnvelope = rdList.get(0);
    List<Envelope> pvdList = mockedIngestion.waitForItems("PageViewData", 3);
    assertEquals(0, mockedIngestion.getCountForType("EventData"));
    RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
    Envelope pvdEnvelope1 = null;
    Envelope pvdEnvelope2 = null;
    Envelope pvdEnvelope3 = null;
    for (Envelope pvdEnvelope : pvdList) {
        PageViewData pv = (PageViewData) ((Data<?>) pvdEnvelope.getData()).getBaseData();
        if (pv.getName().equals("test-page")) {
            pvdEnvelope1 = pvdEnvelope;
        } else if (pv.getName().equals("test-page-2")) {
            pvdEnvelope2 = pvdEnvelope;
        } else if (pv.getName().equals("test-page-3")) {
            pvdEnvelope3 = pvdEnvelope;
        } else {
            throw new AssertionError("Unexpected page view: " + pv.getName());
        }
    }
    PageViewData pv1 = (PageViewData) ((Data<?>) pvdEnvelope1.getData()).getBaseData();
    PageViewData pv2 = (PageViewData) ((Data<?>) pvdEnvelope2.getData()).getBaseData();
    PageViewData pv3 = (PageViewData) ((Data<?>) pvdEnvelope3.getData()).getBaseData();
    assertNotNull(pv1);
    assertEquals(new Duration(0), pv1.getDuration());
    // checking that instrumentation key, cloud role name, cloud role instance, and sdk version are
    // from the agent
    assertEquals("00000000-0000-0000-0000-0FEEDDADBEEF", pvdEnvelope1.getIKey());
    assertEquals("testrolename", pvdEnvelope1.getTags().get("ai.cloud.role"));
    assertEquals("testroleinstance", pvdEnvelope1.getTags().get("ai.cloud.roleInstance"));
    assertTrue(pvdEnvelope1.getTags().get("ai.internal.sdkVersion").startsWith("java:3."));
    assertNotNull(pv2);
    assertEquals(new Duration(123456), pv2.getDuration());
    assertEquals("2010-10-10T00:00:00Z", pvdEnvelope2.getTime());
    assertEquals("value", pv2.getProperties().get("key"));
    assertEquals("a-value", pv2.getProperties().get("a-prop"));
    assertEquals("another-value", pv2.getProperties().get("another-prop"));
    // operation name is verified below in assertParentChild()
    assertEquals("user-id-goes-here", pvdEnvelope2.getTags().get("ai.user.id"));
    assertEquals("account-id-goes-here", pvdEnvelope2.getTags().get("ai.user.accountId"));
    assertEquals("user-agent-goes-here", pvdEnvelope2.getTags().get("ai.user.userAgent"));
    assertEquals("os-goes-here", pvdEnvelope2.getTags().get("ai.device.os"));
    assertEquals("session-id-goes-here", pvdEnvelope2.getTags().get("ai.session.id"));
    assertEquals("1.2.3.4", pvdEnvelope2.getTags().get("ai.location.ip"));
    // checking that instrumentation key, cloud role name and cloud role instance are overridden
    assertEquals("12341234-1234-1234-1234-123412341234", pvdEnvelope2.getIKey());
    assertEquals("role-goes-here", pvdEnvelope2.getTags().get("ai.cloud.role"));
    assertEquals("role-instance-goes-here", pvdEnvelope2.getTags().get("ai.cloud.roleInstance"));
    // checking that sdk version is from the agent
    assertTrue(pvdEnvelope2.getTags().get("ai.internal.sdkVersion").startsWith("java:3."));
    assertNotNull(pv3);
    assertEquals(new Duration(123456), pv3.getDuration());
    assertEquals("2010-10-10T00:00:00Z", pvdEnvelope3.getTime());
    assertEquals("value", pv3.getProperties().get("key"));
    assertEquals("a-value", pv3.getProperties().get("a-prop"));
    assertEquals("another-value", pv3.getProperties().get("another-prop"));
    // operation name is verified below in assertParentChild()
    assertEquals("user-id-goes-here", pvdEnvelope3.getTags().get("ai.user.id"));
    assertEquals("account-id-goes-here", pvdEnvelope3.getTags().get("ai.user.accountId"));
    assertEquals("user-agent-goes-here", pvdEnvelope3.getTags().get("ai.user.userAgent"));
    assertEquals("os-goes-here", pvdEnvelope3.getTags().get("ai.device.os"));
    assertEquals("session-id-goes-here", pvdEnvelope3.getTags().get("ai.session.id"));
    assertEquals("1.2.3.4", pvdEnvelope3.getTags().get("ai.location.ip"));
    // checking that instrumentation key, cloud role name and cloud role instance are from the agent
    assertEquals("00000000-0000-0000-0000-0FEEDDADBEEF", pvdEnvelope3.getIKey());
    assertEquals("testrolename", pvdEnvelope3.getTags().get("ai.cloud.role"));
    assertEquals("testroleinstance", pvdEnvelope3.getTags().get("ai.cloud.roleInstance"));
    // checking that sdk version is from the agent
    assertTrue(pvdEnvelope3.getTags().get("ai.internal.sdkVersion").startsWith("java:3."));
    assertParentChild(rd, rdEnvelope, pvdEnvelope1, "GET /CoreAndFilter/trackPageView");
    assertEquals("operation-id-goes-here", pvdEnvelope2.getTags().get("ai.operation.id"));
    assertEquals("operation-parent-id-goes-here", pvdEnvelope2.getTags().get("ai.operation.parentId"));
    assertEquals("operation-name-goes-here", pvdEnvelope2.getTags().get("ai.operation.name"));
    assertEquals("operation-id-goes-here", pvdEnvelope3.getTags().get("ai.operation.id"));
    assertEquals("operation-parent-id-goes-here", pvdEnvelope3.getTags().get("ai.operation.parentId"));
    assertEquals("operation-name-goes-here", pvdEnvelope3.getTags().get("ai.operation.name"));
}
Also used : RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) RequestDataMatchers.hasDuration(com.microsoft.applicationinsights.smoketest.matchers.RequestDataMatchers.hasDuration) Duration(com.microsoft.applicationinsights.smoketest.telemetry.Duration) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) PageViewData(com.microsoft.applicationinsights.smoketest.schemav2.PageViewData) Test(org.junit.Test)

Example 68 with Data

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

the class JmsDisabledTest method doMostBasicTest.

@Test
@TargetUri("/sendMessage")
public void doMostBasicTest() throws Exception {
    List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
    Envelope rdEnvelope = rdList.get(0);
    RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
    assertEquals(0, mockedIngestion.getCountForType("EventData"));
    assertEquals("GET /sendMessage", rd.getName());
    assertEquals("200", rd.getResponseCode());
    assertTrue(rd.getProperties().isEmpty());
    assertTrue(rd.getSuccess());
    // verify the downstream http dependency that is no longer part of the same trace
    List<Envelope> rddList = mockedIngestion.waitForItems("RemoteDependencyData", 1);
    Envelope rddEnvelope = rddList.get(0);
    RemoteDependencyData rdd = (RemoteDependencyData) ((Data<?>) rddEnvelope.getData()).getBaseData();
    assertEquals("GET /", rdd.getName());
    assertEquals("https://www.bing.com", rdd.getData());
    assertTrue(rdd.getProperties().isEmpty());
    assertTrue(rdd.getSuccess());
    // sleep a bit and make sure no kafka "requests" or dependencies are reported
    Thread.sleep(5000);
    assertEquals(1, mockedIngestion.getCountForType("RequestData"));
    assertEquals(1, mockedIngestion.getCountForType("RemoteDependencyData"));
}
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 69 with Data

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

the class KafkaDisabledTest method doMostBasicTest.

@Test
@TargetUri("/sendMessage")
public void doMostBasicTest() throws Exception {
    List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
    Envelope rdEnvelope = rdList.get(0);
    RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
    String operationId = rdEnvelope.getTags().get("ai.operation.id");
    assertEquals(0, mockedIngestion.getCountForType("EventData"));
    assertEquals("GET /sendMessage", rd.getName());
    assertEquals("200", rd.getResponseCode());
    assertTrue(rd.getProperties().isEmpty());
    assertTrue(rd.getSuccess());
    // verify the downstream http dependency that is no longer part of the same trace
    List<Envelope> rddList = mockedIngestion.waitForItems("RemoteDependencyData", 1);
    Envelope rddEnvelope = rddList.get(0);
    RemoteDependencyData rdd = (RemoteDependencyData) ((Data<?>) rddEnvelope.getData()).getBaseData();
    assertEquals("GET /", rdd.getName());
    assertEquals("https://www.bing.com", rdd.getData());
    assertTrue(rdd.getProperties().isEmpty());
    assertTrue(rdd.getSuccess());
    // sleep a bit and make sure no kafka "requests" or dependencies are reported
    Thread.sleep(5000);
    assertEquals(1, mockedIngestion.getCountForType("RequestData"));
    assertEquals(1, mockedIngestion.getCountForType("RemoteDependencyData"));
}
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 70 with Data

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

the class KafkaTest 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, "mytopic process");
    Envelope rddEnvelope1 = getDependencyEnvelope(rddList, "mytopic 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("mytopic send", rdd1.getName());
    assertNull(rdd1.getData());
    assertEquals("Queue Message | kafka", rdd1.getType());
    assertEquals("mytopic", rdd1.getTarget());
    assertTrue(rdd1.getProperties().isEmpty());
    assertTrue(rdd1.getSuccess());
    assertEquals("mytopic process", rd2.getName());
    assertEquals("mytopic", 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", "mytopic process", false);
    assertParentChild(rd2.getId(), rdEnvelope2, rddEnvelope2, "mytopic process", "mytopic 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

Test (org.junit.Test)65 Envelope (com.microsoft.applicationinsights.smoketest.schemav2.Envelope)53 RequestData (com.microsoft.applicationinsights.smoketest.schemav2.RequestData)45 Data (org.geotoolkit.wps.xml.v200.Data)42 RemoteDependencyData (com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData)26 UnconvertibleObjectException (org.apache.sis.util.UnconvertibleObjectException)20 IOException (java.io.IOException)16 DataInput (org.geotoolkit.wps.xml.v200.DataInput)15 Format (org.geotoolkit.wps.xml.v200.Format)12 AiSmokeTest (com.microsoft.applicationinsights.smoketest.AiSmokeTest)10 TargetUri (com.microsoft.applicationinsights.smoketest.TargetUri)10 MessageData (com.microsoft.applicationinsights.smoketest.schemav2.MessageData)10 ComplexData (org.geotoolkit.wps.xml.v200.ComplexData)10 ExceptionData (com.microsoft.applicationinsights.smoketest.schemav2.ExceptionData)9 ReferenceProxy (org.geotoolkit.wps.xml.ReferenceProxy)9 Data (com.microsoft.applicationinsights.smoketest.schemav2.Data)8 DataStoreException (org.apache.sis.storage.DataStoreException)8 LiteralValue (org.geotoolkit.wps.xml.v200.LiteralValue)7 EventData (com.microsoft.applicationinsights.smoketest.schemav2.EventData)6 MetricData (com.microsoft.applicationinsights.smoketest.schemav2.MetricData)6