Search in sources :

Example 16 with IpConnectivityLog

use of android.net.metrics.IpConnectivityLog in project android_frameworks_base by DirtyUnicorns.

the class IpConnectivityMetricsTest method testRateLimiting.

@SmallTest
public void testRateLimiting() {
    final IpConnectivityLog logger = new IpConnectivityLog(mService.impl);
    final ApfProgramEvent ev = new ApfProgramEvent(0, 0, 0, 0, 0);
    final long fakeTimestamp = 1;
    // More than burst quota, but less than buffer size.
    int attempt = 100;
    for (int i = 0; i < attempt; i++) {
        logger.log(ev);
    }
    String output1 = getdump("flush");
    assertFalse("".equals(output1));
    for (int i = 0; i < attempt; i++) {
        assertFalse("expected event to be dropped", logger.log(fakeTimestamp, ev));
    }
    String output2 = getdump("flush");
    assertEquals("", output2);
}
Also used : IpConnectivityLog(android.net.metrics.IpConnectivityLog) ApfProgramEvent(android.net.metrics.ApfProgramEvent) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 17 with IpConnectivityLog

use of android.net.metrics.IpConnectivityLog in project android_frameworks_base by ResurrectionRemix.

the class IpConnectivityMetricsTest method testRateLimiting.

@SmallTest
public void testRateLimiting() {
    final IpConnectivityLog logger = new IpConnectivityLog(mService.impl);
    final ApfProgramEvent ev = new ApfProgramEvent(0, 0, 0, 0, 0);
    final long fakeTimestamp = 1;
    // More than burst quota, but less than buffer size.
    int attempt = 100;
    for (int i = 0; i < attempt; i++) {
        logger.log(ev);
    }
    String output1 = getdump("flush");
    assertFalse("".equals(output1));
    for (int i = 0; i < attempt; i++) {
        assertFalse("expected event to be dropped", logger.log(fakeTimestamp, ev));
    }
    String output2 = getdump("flush");
    assertEquals("", output2);
}
Also used : IpConnectivityLog(android.net.metrics.IpConnectivityLog) ApfProgramEvent(android.net.metrics.ApfProgramEvent) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 18 with IpConnectivityLog

use of android.net.metrics.IpConnectivityLog in project android_frameworks_base by ResurrectionRemix.

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 19 with IpConnectivityLog

use of android.net.metrics.IpConnectivityLog 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 20 with IpConnectivityLog

use of android.net.metrics.IpConnectivityLog in project android_frameworks_base by crdroidandroid.

the class IpConnectivityMetricsTest method testRateLimiting.

@SmallTest
public void testRateLimiting() {
    final IpConnectivityLog logger = new IpConnectivityLog(mService.impl);
    final ApfProgramEvent ev = new ApfProgramEvent(0, 0, 0, 0, 0);
    final long fakeTimestamp = 1;
    // More than burst quota, but less than buffer size.
    int attempt = 100;
    for (int i = 0; i < attempt; i++) {
        logger.log(ev);
    }
    String output1 = getdump("flush");
    assertFalse("".equals(output1));
    for (int i = 0; i < attempt; i++) {
        assertFalse("expected event to be dropped", logger.log(fakeTimestamp, ev));
    }
    String output2 = getdump("flush");
    assertEquals("", output2);
}
Also used : IpConnectivityLog(android.net.metrics.IpConnectivityLog) ApfProgramEvent(android.net.metrics.ApfProgramEvent) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

IpConnectivityLog (android.net.metrics.IpConnectivityLog)20 SmallTest (android.test.suitebuilder.annotation.SmallTest)15 ConnectivityMetricsEvent (android.net.ConnectivityMetricsEvent)8 ApfProgramEvent (android.net.metrics.ApfProgramEvent)4 ApfStats (android.net.metrics.ApfStats)4 DefaultNetworkEvent (android.net.metrics.DefaultNetworkEvent)4 DhcpClientEvent (android.net.metrics.DhcpClientEvent)4 IpManagerEvent (android.net.metrics.IpManagerEvent)4 IpReachabilityEvent (android.net.metrics.IpReachabilityEvent)4 RaEvent (android.net.metrics.RaEvent)4 ValidationProbeEvent (android.net.metrics.ValidationProbeEvent)4 Parcelable (android.os.Parcelable)4