Search in sources :

Example 21 with ConnectivityMetricsEvent

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

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)

Example 22 with ConnectivityMetricsEvent

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

the class IpConnectivityMetricsTest method testLoggingEventsWithMultipleCallers.

@SmallTest
public void testLoggingEventsWithMultipleCallers() throws Exception {
    IpConnectivityLog logger = new IpConnectivityLog(mMockService);
    final int nCallers = 10;
    final int nEvents = 10;
    for (int n = 0; n < nCallers; n++) {
        final int i = n;
        new Thread() {

            public void run() {
                for (int j = 0; j < nEvents; j++) {
                    assertTrue(logger.log(i * 100 + j, FAKE_EV));
                }
            }
        }.start();
    }
    List<ConnectivityMetricsEvent> got = verifyEvents(nCallers * nEvents, 100);
    Collections.sort(got, EVENT_COMPARATOR);
    Iterator<ConnectivityMetricsEvent> iter = got.iterator();
    for (int i = 0; i < nCallers; i++) {
        for (int j = 0; j < nEvents; j++) {
            int expectedTimestamp = i * 100 + j;
            assertEventsEqual(expectedEvent(expectedTimestamp), iter.next());
        }
    }
}
Also used : IpConnectivityLog(android.net.metrics.IpConnectivityLog) ConnectivityMetricsEvent(android.net.ConnectivityMetricsEvent) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 23 with ConnectivityMetricsEvent

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

the class IpConnectivityEventBuilderTest method testValidationProbeEventSerialization.

@SmallTest
public void testValidationProbeEventSerialization() {
    ConnectivityMetricsEvent ev = describeIpEvent(aType(ValidationProbeEvent.class), anInt(120), aLong(40730), anInt(ValidationProbeEvent.PROBE_HTTP), anInt(204));
    String want = joinLines("dropped_events: 0", "events <", "  time_ms: 1", "  transport: 0", "  validation_probe_event <", "    latency_ms: 40730", "    network_id <", "      network_id: 120", "    >", "    probe_result: 204", "    probe_type: 1", "  >", ">", "version: 2");
    verifySerialization(want, ev);
}
Also used : ConnectivityMetricsEvent(android.net.ConnectivityMetricsEvent) ValidationProbeEvent(android.net.metrics.ValidationProbeEvent) MetricsTestUtil.aString(com.android.server.connectivity.MetricsTestUtil.aString) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 24 with ConnectivityMetricsEvent

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

the class IpConnectivityEventBuilderTest method testIpManagerEventSerialization.

@SmallTest
public void testIpManagerEventSerialization() {
    ConnectivityMetricsEvent ev = describeIpEvent(aType(IpManagerEvent.class), aString("wlan0"), anInt(IpManagerEvent.PROVISIONING_OK), aLong(5678));
    String want = joinLines("dropped_events: 0", "events <", "  time_ms: 1", "  transport: 0", "  ip_provisioning_event <", "    event_type: 1", "    if_name: \"wlan0\"", "    latency_ms: 5678", "  >", ">", "version: 2");
    verifySerialization(want, ev);
}
Also used : ConnectivityMetricsEvent(android.net.ConnectivityMetricsEvent) IpManagerEvent(android.net.metrics.IpManagerEvent) MetricsTestUtil.aString(com.android.server.connectivity.MetricsTestUtil.aString) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 25 with ConnectivityMetricsEvent

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

the class IpConnectivityEventBuilderTest method testNetworkEventSerialization.

@SmallTest
public void testNetworkEventSerialization() {
    ConnectivityMetricsEvent ev = describeIpEvent(aType(NetworkEvent.class), anInt(100), anInt(5), aLong(20410));
    String want = joinLines("dropped_events: 0", "events <", "  time_ms: 1", "  transport: 0", "  network_event <", "    event_type: 5", "    latency_ms: 20410", "    network_id <", "      network_id: 100", "    >", "  >", ">", "version: 2");
    verifySerialization(want, ev);
}
Also used : NetworkEvent(android.net.metrics.NetworkEvent) DefaultNetworkEvent(android.net.metrics.DefaultNetworkEvent) ConnectivityMetricsEvent(android.net.ConnectivityMetricsEvent) MetricsTestUtil.aString(com.android.server.connectivity.MetricsTestUtil.aString) SmallTest(android.test.suitebuilder.annotation.SmallTest)

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