Search in sources :

Example 26 with Data

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

Example 27 with Data

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

the class MockedAppInsightsIngestionServer method getTelemetryDataByType.

private <T extends Domain> List<T> getTelemetryDataByType(String type, boolean inRequestOnly) {
    Objects.requireNonNull(type, "type");
    List<Envelope> items = getItemsEnvelopeDataType(type);
    List<T> dataItems = new ArrayList<>();
    for (Envelope e : items) {
        if (!inRequestOnly || e.getTags().containsKey("ai.operation.id")) {
            Data<T> dt = (Data<T>) e.getData();
            dataItems.add(dt.getBaseData());
        }
    }
    return dataItems;
}
Also used : 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 28 with Data

use of com.microsoft.applicationinsights.smoketest.schemav2.Data 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 29 with Data

use of com.microsoft.applicationinsights.smoketest.schemav2.Data 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 30 with Data

use of com.microsoft.applicationinsights.smoketest.schemav2.Data 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)

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