Search in sources :

Example 51 with ConnectivityMetricsEvent

use of android.net.ConnectivityMetricsEvent in project android_frameworks_base by crdroidandroid.

the class IpConnectivityEventBuilderTest method testRaEventSerialization.

@SmallTest
public void testRaEventSerialization() {
    ConnectivityMetricsEvent ev = describeIpEvent(aType(RaEvent.class), aLong(2000), aLong(400), aLong(300), aLong(-1), aLong(1000), aLong(-1));
    String want = joinLines("dropped_events: 0", "events <", "  time_ms: 1", "  transport: 0", "  ra_event <", "    dnssl_lifetime: -1", "    prefix_preferred_lifetime: 300", "    prefix_valid_lifetime: 400", "    rdnss_lifetime: 1000", "    route_info_lifetime: -1", "    router_lifetime: 2000", "  >", ">", "version: 2");
    verifySerialization(want, ev);
}
Also used : RaEvent(android.net.metrics.RaEvent) ConnectivityMetricsEvent(android.net.ConnectivityMetricsEvent) MetricsTestUtil.aString(com.android.server.connectivity.MetricsTestUtil.aString) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 52 with ConnectivityMetricsEvent

use of android.net.ConnectivityMetricsEvent in project android_frameworks_base by crdroidandroid.

the class IpConnectivityEventBuilderTest method testDnsEventSerialization.

@SmallTest
public void testDnsEventSerialization() {
    ConnectivityMetricsEvent ev = describeIpEvent(aType(DnsEvent.class), anInt(101), aByteArray(b(1), b(1), b(2), b(1), b(1), b(1), b(2), b(2)), aByteArray(b(0), b(0), b(22), b(3), b(1), b(0), b(200), b(178)), anIntArray(3456, 267, 1230, 45, 2111, 450, 638, 1300));
    String want = joinLines("dropped_events: 0", "events <", "  time_ms: 1", "  transport: 0", "  dns_lookup_batch <", "    event_types: 1", "    event_types: 1", "    event_types: 2", "    event_types: 1", "    event_types: 1", "    event_types: 1", "    event_types: 2", "    event_types: 2", "    latencies_ms: 3456", "    latencies_ms: 267", "    latencies_ms: 1230", "    latencies_ms: 45", "    latencies_ms: 2111", "    latencies_ms: 450", "    latencies_ms: 638", "    latencies_ms: 1300", "    network_id <", "      network_id: 101", "    >", "    return_codes: 0", "    return_codes: 0", "    return_codes: 22", "    return_codes: 3", "    return_codes: 1", "    return_codes: 0", "    return_codes: 200", "    return_codes: 178", "  >", ">", "version: 2");
    verifySerialization(want, ev);
}
Also used : ConnectivityMetricsEvent(android.net.ConnectivityMetricsEvent) MetricsTestUtil.aString(com.android.server.connectivity.MetricsTestUtil.aString) DnsEvent(android.net.metrics.DnsEvent) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 53 with ConnectivityMetricsEvent

use of android.net.ConnectivityMetricsEvent in project android_frameworks_base by crdroidandroid.

the class IpConnectivityEventBuilderTest method testApfStatsSerialization.

@SmallTest
public void testApfStatsSerialization() {
    ConnectivityMetricsEvent ev = describeIpEvent(aType(ApfStats.class), aLong(45000), anInt(10), anInt(2), anInt(2), anInt(1), anInt(2), anInt(4), anInt(2048));
    String want = joinLines("dropped_events: 0", "events <", "  time_ms: 1", "  transport: 0", "  apf_statistics <", "    dropped_ras: 2", "    duration_ms: 45000", "    matching_ras: 2", "    max_program_size: 2048", "    parse_errors: 2", "    program_updates: 4", "    received_ras: 10", "    zero_lifetime_ras: 1", "  >", ">", "version: 2");
    verifySerialization(want, ev);
}
Also used : ApfStats(android.net.metrics.ApfStats) ConnectivityMetricsEvent(android.net.ConnectivityMetricsEvent) MetricsTestUtil.aString(com.android.server.connectivity.MetricsTestUtil.aString) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 54 with ConnectivityMetricsEvent

use of android.net.ConnectivityMetricsEvent in project android_frameworks_base by crdroidandroid.

the class IpConnectivityMetricsTest method testLoggingEvents.

@SmallTest
public void testLoggingEvents() throws Exception {
    IpConnectivityLog logger = new IpConnectivityLog(mMockService);
    assertTrue(logger.log(1, FAKE_EV));
    assertTrue(logger.log(2, FAKE_EV));
    assertTrue(logger.log(3, FAKE_EV));
    List<ConnectivityMetricsEvent> got = verifyEvents(3);
    assertEventsEqual(expectedEvent(1), got.get(0));
    assertEventsEqual(expectedEvent(2), got.get(1));
    assertEventsEqual(expectedEvent(3), got.get(2));
}
Also used : IpConnectivityLog(android.net.metrics.IpConnectivityLog) ConnectivityMetricsEvent(android.net.ConnectivityMetricsEvent) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 55 with ConnectivityMetricsEvent

use of android.net.ConnectivityMetricsEvent in project android_frameworks_base by crdroidandroid.

the class MetricsLoggerServiceTest method logAndDumpConcurrently.

public void logAndDumpConcurrently() throws Exception {
    final CountDownLatch latch = new CountDownLatch((int) N_EVENTS);
    final FileDescriptor fd = new FileOutputStream("/dev/null").getFD();
    for (ConnectivityMetricsEvent ev : EVENTS) {
        new Thread() {

            public void run() {
                mService.mBinder.logEvent(ev);
                latch.countDown();
            }
        }.start();
    }
    new Thread() {

        public void run() {
            while (latch.getCount() > 0) {
                mService.mBinder.dump(fd, new String[] { "--all" });
            }
        }
    }.start();
    latch.await(100, TimeUnit.MILLISECONDS);
    Reference r = new Reference(0);
    ConnectivityMetricsEvent[] got = mService.mBinder.getEvents(r);
    Arrays.sort(got, new EventComparator());
    assertArrayEquals(EVENTS, got);
    assertEquals(N_EVENTS, r.getValue());
}
Also used : Reference(android.net.ConnectivityMetricsEvent.Reference) FileOutputStream(java.io.FileOutputStream) ConnectivityMetricsEvent(android.net.ConnectivityMetricsEvent) CountDownLatch(java.util.concurrent.CountDownLatch) FileDescriptor(java.io.FileDescriptor)

Aggregations

ConnectivityMetricsEvent (android.net.ConnectivityMetricsEvent)63 MetricsTestUtil.aString (com.android.server.connectivity.MetricsTestUtil.aString)44 SmallTest (android.test.suitebuilder.annotation.SmallTest)39 DefaultNetworkEvent (android.net.metrics.DefaultNetworkEvent)8 IpConnectivityLog (android.net.metrics.IpConnectivityLog)8 Reference (android.net.ConnectivityMetricsEvent.Reference)6 IpConnectivityEvent (com.android.server.connectivity.metrics.IpConnectivityLogClass.IpConnectivityEvent)5 ArrayList (java.util.ArrayList)5 ApfProgramEvent (android.net.metrics.ApfProgramEvent)4 ApfStats (android.net.metrics.ApfStats)4 DhcpClientEvent (android.net.metrics.DhcpClientEvent)4 DhcpErrorEvent (android.net.metrics.DhcpErrorEvent)4 DnsEvent (android.net.metrics.DnsEvent)4 IpManagerEvent (android.net.metrics.IpManagerEvent)4 IpReachabilityEvent (android.net.metrics.IpReachabilityEvent)4 NetworkEvent (android.net.metrics.NetworkEvent)4 RaEvent (android.net.metrics.RaEvent)4 ValidationProbeEvent (android.net.metrics.ValidationProbeEvent)4 FileDescriptor (java.io.FileDescriptor)3 FileOutputStream (java.io.FileOutputStream)3