Search in sources :

Example 16 with Envelope

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

the class MockedAppInsightsIngestionServer method getMessageDataInRequest.

public <T extends Domain> List<T> getMessageDataInRequest() {
    List<Envelope> items = getItemsEnvelopeDataType("MessageData");
    List<T> dataItems = new ArrayList<>();
    for (Envelope e : items) {
        String message = ((MessageData) ((Data<?>) e.getData()).getBaseData()).getMessage();
        if (e.getTags().containsKey("ai.operation.id") && !ignoreMessageData(message)) {
            Data<T> dt = (Data<T>) e.getData();
            dataItems.add(dt.getBaseData());
        }
    }
    return dataItems;
}
Also used : MessageData(com.microsoft.applicationinsights.smoketest.schemav2.MessageData) ArrayList(java.util.ArrayList) MessageData(com.microsoft.applicationinsights.smoketest.schemav2.MessageData) Data(com.microsoft.applicationinsights.smoketest.schemav2.Data) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope)

Example 17 with Envelope

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

the class PerfCountersDataTest method testPerformanceCounterData.

@Test
@TargetUri(value = "index.jsp", delay = 5000)
public void testPerformanceCounterData() throws Exception {
    System.out.println("Waiting for performance data...");
    long start = System.currentTimeMillis();
    // need to accommodate for START_COLLECTING_DELAY_IN_MILLIS = 60 seconds
    int timeout = 70;
    Envelope availableMem = mockedIngestion.waitForItem(getPerfMetricPredicate("\\Memory\\Available Bytes"), timeout, TimeUnit.SECONDS);
    Envelope totalCpu = mockedIngestion.waitForItem(getPerfMetricPredicate("\\Processor(_Total)\\% Processor Time"), timeout, TimeUnit.SECONDS);
    Envelope processIo = mockedIngestion.waitForItem(getPerfMetricPredicate("\\Process(??APP_WIN32_PROC??)\\IO Data Bytes/sec"), timeout, TimeUnit.SECONDS);
    Envelope processMemUsed = mockedIngestion.waitForItem(getPerfMetricPredicate("\\Process(??APP_WIN32_PROC??)\\Private Bytes"), timeout, TimeUnit.SECONDS);
    Envelope processCpu = mockedIngestion.waitForItem(getPerfMetricPredicate("\\Process(??APP_WIN32_PROC??)\\% Processor Time"), timeout, TimeUnit.SECONDS);
    System.out.println("PerformanceCounterData are good: " + (System.currentTimeMillis() - start));
    MetricData metricMem = getBaseData(availableMem);
    assertPerfMetric(metricMem);
    assertEquals("\\Memory\\Available Bytes", metricMem.getMetrics().get(0).getName());
    MetricData pdCpu = getBaseData(totalCpu);
    assertPerfMetric(pdCpu);
    assertEquals("\\Processor(_Total)\\% Processor Time", pdCpu.getMetrics().get(0).getName());
    assertPerfMetric(getBaseData(processIo));
    assertPerfMetric(getBaseData(processMemUsed));
    assertPerfMetric(getBaseData(processCpu));
    start = System.currentTimeMillis();
    System.out.println("Waiting for metric data...");
    Envelope deadlocks = mockedIngestion.waitForItem(getPerfMetricPredicate("Suspected Deadlocked Threads"), timeout, TimeUnit.SECONDS);
    Envelope heapUsed = mockedIngestion.waitForItem(getPerfMetricPredicate("Heap Memory Used (MB)"), timeout, TimeUnit.SECONDS);
    Envelope gcTotalCount = mockedIngestion.waitForItem(getPerfMetricPredicate("GC Total Count"), timeout, TimeUnit.SECONDS);
    Envelope gcTotalTime = mockedIngestion.waitForItem(getPerfMetricPredicate("GC Total Time"), timeout, TimeUnit.SECONDS);
    System.out.println("MetricData are good: " + (System.currentTimeMillis() - start));
    MetricData mdDeadlocks = getBaseData(deadlocks);
    assertPerfMetric(mdDeadlocks);
    assertEquals(0.0, mdDeadlocks.getMetrics().get(0).getValue(), Math.ulp(0.0));
    MetricData mdHeapUsed = getBaseData(heapUsed);
    assertPerfMetric(mdHeapUsed);
    assertTrue(mdHeapUsed.getMetrics().get(0).getValue() > 0.0);
    MetricData mdGcTotalCount = getBaseData(gcTotalCount);
    assertPerfMetric(mdGcTotalCount);
    MetricData mdGcTotalTime = getBaseData(gcTotalTime);
    assertPerfMetric(mdGcTotalTime);
}
Also used : Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) DataPoint(com.microsoft.applicationinsights.smoketest.schemav2.DataPoint) MetricData(com.microsoft.applicationinsights.smoketest.schemav2.MetricData) Test(org.junit.Test)

Example 18 with Envelope

use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope 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/*");
}
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 19 with Envelope

use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope 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/*");
}
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 20 with Envelope

use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope 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/*");
}
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)

Aggregations

Envelope (com.microsoft.applicationinsights.smoketest.schemav2.Envelope)57 Test (org.junit.Test)52 RequestData (com.microsoft.applicationinsights.smoketest.schemav2.RequestData)45 RemoteDependencyData (com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData)28 Envelope (org.opensaml.soap.soap11.Envelope)16 Body (org.opensaml.soap.soap11.Body)11 Header (org.opensaml.soap.soap11.Header)11 AiSmokeTest (com.microsoft.applicationinsights.smoketest.AiSmokeTest)10 TargetUri (com.microsoft.applicationinsights.smoketest.TargetUri)10 ExceptionData (com.microsoft.applicationinsights.smoketest.schemav2.ExceptionData)9 MessageData (com.microsoft.applicationinsights.smoketest.schemav2.MessageData)9 Data (com.microsoft.applicationinsights.smoketest.schemav2.Data)8 EventData (com.microsoft.applicationinsights.smoketest.schemav2.EventData)6 MetricData (com.microsoft.applicationinsights.smoketest.schemav2.MetricData)6 RequestDataMatchers.hasDuration (com.microsoft.applicationinsights.smoketest.matchers.RequestDataMatchers.hasDuration)4 DataPoint (com.microsoft.applicationinsights.smoketest.schemav2.DataPoint)4 ExceptionDetails (com.microsoft.applicationinsights.smoketest.schemav2.ExceptionDetails)4 Duration (com.microsoft.applicationinsights.smoketest.telemetry.Duration)4 PageViewData (com.microsoft.applicationinsights.smoketest.schemav2.PageViewData)3 HttpServletResponse (javax.servlet.http.HttpServletResponse)3