DO NOT MERGE Fix IP connectivity metrics tests
am: 9bf9c9b375
Change-Id: Ia6a28b09263729caa72786062e134f8c684e3ccb
This commit is contained in:
@@ -16,6 +16,17 @@
|
|||||||
|
|
||||||
package com.android.server.connectivity;
|
package com.android.server.connectivity;
|
||||||
|
|
||||||
|
import static com.android.server.connectivity.MetricsTestUtil.aBool;
|
||||||
|
import static com.android.server.connectivity.MetricsTestUtil.aByteArray;
|
||||||
|
import static com.android.server.connectivity.MetricsTestUtil.aLong;
|
||||||
|
import static com.android.server.connectivity.MetricsTestUtil.aString;
|
||||||
|
import static com.android.server.connectivity.MetricsTestUtil.aType;
|
||||||
|
import static com.android.server.connectivity.MetricsTestUtil.anInt;
|
||||||
|
import static com.android.server.connectivity.MetricsTestUtil.anIntArray;
|
||||||
|
import static com.android.server.connectivity.MetricsTestUtil.b;
|
||||||
|
import static com.android.server.connectivity.MetricsTestUtil.describeIpEvent;
|
||||||
|
import static com.android.server.connectivity.metrics.IpConnectivityLogClass.IpConnectivityLog;
|
||||||
|
|
||||||
import android.net.ConnectivityMetricsEvent;
|
import android.net.ConnectivityMetricsEvent;
|
||||||
import android.net.metrics.ApfProgramEvent;
|
import android.net.metrics.ApfProgramEvent;
|
||||||
import android.net.metrics.ApfStats;
|
import android.net.metrics.ApfStats;
|
||||||
@@ -28,24 +39,13 @@ import android.net.metrics.IpReachabilityEvent;
|
|||||||
import android.net.metrics.NetworkEvent;
|
import android.net.metrics.NetworkEvent;
|
||||||
import android.net.metrics.RaEvent;
|
import android.net.metrics.RaEvent;
|
||||||
import android.net.metrics.ValidationProbeEvent;
|
import android.net.metrics.ValidationProbeEvent;
|
||||||
import com.google.protobuf.nano.MessageNano;
|
import android.test.suitebuilder.annotation.SmallTest;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import static com.android.server.connectivity.metrics.IpConnectivityLogClass.IpConnectivityLog;
|
|
||||||
import static com.android.server.connectivity.MetricsTestUtil.aBool;
|
|
||||||
import static com.android.server.connectivity.MetricsTestUtil.aByteArray;
|
|
||||||
import static com.android.server.connectivity.MetricsTestUtil.aLong;
|
|
||||||
import static com.android.server.connectivity.MetricsTestUtil.aString;
|
|
||||||
import static com.android.server.connectivity.MetricsTestUtil.aType;
|
|
||||||
import static com.android.server.connectivity.MetricsTestUtil.anInt;
|
|
||||||
import static com.android.server.connectivity.MetricsTestUtil.anIntArray;
|
|
||||||
import static com.android.server.connectivity.MetricsTestUtil.b;
|
|
||||||
import static com.android.server.connectivity.MetricsTestUtil.describeIpEvent;
|
|
||||||
import static com.android.server.connectivity.MetricsTestUtil.ipEv;
|
|
||||||
|
|
||||||
public class IpConnectivityEventBuilderTest extends TestCase {
|
public class IpConnectivityEventBuilderTest extends TestCase {
|
||||||
|
|
||||||
|
@SmallTest
|
||||||
public void testDefaultNetworkEventSerialization() {
|
public void testDefaultNetworkEventSerialization() {
|
||||||
ConnectivityMetricsEvent ev = describeIpEvent(
|
ConnectivityMetricsEvent ev = describeIpEvent(
|
||||||
aType(DefaultNetworkEvent.class),
|
aType(DefaultNetworkEvent.class),
|
||||||
@@ -58,6 +58,8 @@ public class IpConnectivityEventBuilderTest extends TestCase {
|
|||||||
String want = joinLines(
|
String want = joinLines(
|
||||||
"dropped_events: 0",
|
"dropped_events: 0",
|
||||||
"events <",
|
"events <",
|
||||||
|
" time_ms: 1",
|
||||||
|
" transport: 0",
|
||||||
" default_network_event <",
|
" default_network_event <",
|
||||||
" network_id <",
|
" network_id <",
|
||||||
" network_id: 102",
|
" network_id: 102",
|
||||||
@@ -70,13 +72,13 @@ public class IpConnectivityEventBuilderTest extends TestCase {
|
|||||||
" transport_types: 2",
|
" transport_types: 2",
|
||||||
" transport_types: 3",
|
" transport_types: 3",
|
||||||
" >",
|
" >",
|
||||||
" time_ms: 1",
|
|
||||||
">",
|
">",
|
||||||
"version: 2");
|
"version: 2");
|
||||||
|
|
||||||
verifySerialization(want, ev);
|
verifySerialization(want, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SmallTest
|
||||||
public void testDhcpClientEventSerialization() {
|
public void testDhcpClientEventSerialization() {
|
||||||
ConnectivityMetricsEvent ev = describeIpEvent(
|
ConnectivityMetricsEvent ev = describeIpEvent(
|
||||||
aType(DhcpClientEvent.class),
|
aType(DhcpClientEvent.class),
|
||||||
@@ -87,19 +89,20 @@ public class IpConnectivityEventBuilderTest extends TestCase {
|
|||||||
String want = joinLines(
|
String want = joinLines(
|
||||||
"dropped_events: 0",
|
"dropped_events: 0",
|
||||||
"events <",
|
"events <",
|
||||||
|
" time_ms: 1",
|
||||||
|
" transport: 0",
|
||||||
" dhcp_event <",
|
" dhcp_event <",
|
||||||
" duration_ms: 192",
|
" duration_ms: 192",
|
||||||
" error_code: 0",
|
|
||||||
" if_name: \"wlan0\"",
|
" if_name: \"wlan0\"",
|
||||||
" state_transition: \"SomeState\"",
|
" state_transition: \"SomeState\"",
|
||||||
" >",
|
" >",
|
||||||
" time_ms: 1",
|
|
||||||
">",
|
">",
|
||||||
"version: 2");
|
"version: 2");
|
||||||
|
|
||||||
verifySerialization(want, ev);
|
verifySerialization(want, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SmallTest
|
||||||
public void testDhcpErrorEventSerialization() {
|
public void testDhcpErrorEventSerialization() {
|
||||||
ConnectivityMetricsEvent ev = describeIpEvent(
|
ConnectivityMetricsEvent ev = describeIpEvent(
|
||||||
aType(DhcpErrorEvent.class),
|
aType(DhcpErrorEvent.class),
|
||||||
@@ -109,19 +112,20 @@ public class IpConnectivityEventBuilderTest extends TestCase {
|
|||||||
String want = joinLines(
|
String want = joinLines(
|
||||||
"dropped_events: 0",
|
"dropped_events: 0",
|
||||||
"events <",
|
"events <",
|
||||||
|
" time_ms: 1",
|
||||||
|
" transport: 0",
|
||||||
" dhcp_event <",
|
" dhcp_event <",
|
||||||
" duration_ms: 0",
|
" duration_ms: 0",
|
||||||
" error_code: 50397184",
|
|
||||||
" if_name: \"wlan0\"",
|
" if_name: \"wlan0\"",
|
||||||
" state_transition: \"\"",
|
" error_code: 50397184",
|
||||||
" >",
|
" >",
|
||||||
" time_ms: 1",
|
|
||||||
">",
|
">",
|
||||||
"version: 2");
|
"version: 2");
|
||||||
|
|
||||||
verifySerialization(want, ev);
|
verifySerialization(want, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SmallTest
|
||||||
public void testDnsEventSerialization() {
|
public void testDnsEventSerialization() {
|
||||||
ConnectivityMetricsEvent ev = describeIpEvent(
|
ConnectivityMetricsEvent ev = describeIpEvent(
|
||||||
aType(DnsEvent.class),
|
aType(DnsEvent.class),
|
||||||
@@ -133,6 +137,8 @@ public class IpConnectivityEventBuilderTest extends TestCase {
|
|||||||
String want = joinLines(
|
String want = joinLines(
|
||||||
"dropped_events: 0",
|
"dropped_events: 0",
|
||||||
"events <",
|
"events <",
|
||||||
|
" time_ms: 1",
|
||||||
|
" transport: 0",
|
||||||
" dns_lookup_batch <",
|
" dns_lookup_batch <",
|
||||||
" event_types: 1",
|
" event_types: 1",
|
||||||
" event_types: 1",
|
" event_types: 1",
|
||||||
@@ -162,13 +168,13 @@ public class IpConnectivityEventBuilderTest extends TestCase {
|
|||||||
" return_codes: 200",
|
" return_codes: 200",
|
||||||
" return_codes: 178",
|
" return_codes: 178",
|
||||||
" >",
|
" >",
|
||||||
" time_ms: 1",
|
|
||||||
">",
|
">",
|
||||||
"version: 2");
|
"version: 2");
|
||||||
|
|
||||||
verifySerialization(want, ev);
|
verifySerialization(want, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SmallTest
|
||||||
public void testIpManagerEventSerialization() {
|
public void testIpManagerEventSerialization() {
|
||||||
ConnectivityMetricsEvent ev = describeIpEvent(
|
ConnectivityMetricsEvent ev = describeIpEvent(
|
||||||
aType(IpManagerEvent.class),
|
aType(IpManagerEvent.class),
|
||||||
@@ -179,18 +185,20 @@ public class IpConnectivityEventBuilderTest extends TestCase {
|
|||||||
String want = joinLines(
|
String want = joinLines(
|
||||||
"dropped_events: 0",
|
"dropped_events: 0",
|
||||||
"events <",
|
"events <",
|
||||||
|
" time_ms: 1",
|
||||||
|
" transport: 0",
|
||||||
" ip_provisioning_event <",
|
" ip_provisioning_event <",
|
||||||
" event_type: 1",
|
" event_type: 1",
|
||||||
" if_name: \"wlan0\"",
|
" if_name: \"wlan0\"",
|
||||||
" latency_ms: 5678",
|
" latency_ms: 5678",
|
||||||
" >",
|
" >",
|
||||||
" time_ms: 1",
|
|
||||||
">",
|
">",
|
||||||
"version: 2");
|
"version: 2");
|
||||||
|
|
||||||
verifySerialization(want, ev);
|
verifySerialization(want, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SmallTest
|
||||||
public void testIpReachabilityEventSerialization() {
|
public void testIpReachabilityEventSerialization() {
|
||||||
ConnectivityMetricsEvent ev = describeIpEvent(
|
ConnectivityMetricsEvent ev = describeIpEvent(
|
||||||
aType(IpReachabilityEvent.class),
|
aType(IpReachabilityEvent.class),
|
||||||
@@ -200,17 +208,19 @@ public class IpConnectivityEventBuilderTest extends TestCase {
|
|||||||
String want = joinLines(
|
String want = joinLines(
|
||||||
"dropped_events: 0",
|
"dropped_events: 0",
|
||||||
"events <",
|
"events <",
|
||||||
|
" time_ms: 1",
|
||||||
|
" transport: 0",
|
||||||
" ip_reachability_event <",
|
" ip_reachability_event <",
|
||||||
" event_type: 512",
|
" event_type: 512",
|
||||||
" if_name: \"wlan0\"",
|
" if_name: \"wlan0\"",
|
||||||
" >",
|
" >",
|
||||||
" time_ms: 1",
|
|
||||||
">",
|
">",
|
||||||
"version: 2");
|
"version: 2");
|
||||||
|
|
||||||
verifySerialization(want, ev);
|
verifySerialization(want, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SmallTest
|
||||||
public void testNetworkEventSerialization() {
|
public void testNetworkEventSerialization() {
|
||||||
ConnectivityMetricsEvent ev = describeIpEvent(
|
ConnectivityMetricsEvent ev = describeIpEvent(
|
||||||
aType(NetworkEvent.class),
|
aType(NetworkEvent.class),
|
||||||
@@ -221,6 +231,8 @@ public class IpConnectivityEventBuilderTest extends TestCase {
|
|||||||
String want = joinLines(
|
String want = joinLines(
|
||||||
"dropped_events: 0",
|
"dropped_events: 0",
|
||||||
"events <",
|
"events <",
|
||||||
|
" time_ms: 1",
|
||||||
|
" transport: 0",
|
||||||
" network_event <",
|
" network_event <",
|
||||||
" event_type: 5",
|
" event_type: 5",
|
||||||
" latency_ms: 20410",
|
" latency_ms: 20410",
|
||||||
@@ -228,13 +240,13 @@ public class IpConnectivityEventBuilderTest extends TestCase {
|
|||||||
" network_id: 100",
|
" network_id: 100",
|
||||||
" >",
|
" >",
|
||||||
" >",
|
" >",
|
||||||
" time_ms: 1",
|
|
||||||
">",
|
">",
|
||||||
"version: 2");
|
"version: 2");
|
||||||
|
|
||||||
verifySerialization(want, ev);
|
verifySerialization(want, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SmallTest
|
||||||
public void testValidationProbeEventSerialization() {
|
public void testValidationProbeEventSerialization() {
|
||||||
ConnectivityMetricsEvent ev = describeIpEvent(
|
ConnectivityMetricsEvent ev = describeIpEvent(
|
||||||
aType(ValidationProbeEvent.class),
|
aType(ValidationProbeEvent.class),
|
||||||
@@ -247,6 +259,7 @@ public class IpConnectivityEventBuilderTest extends TestCase {
|
|||||||
"dropped_events: 0",
|
"dropped_events: 0",
|
||||||
"events <",
|
"events <",
|
||||||
" time_ms: 1",
|
" time_ms: 1",
|
||||||
|
" transport: 0",
|
||||||
" validation_probe_event <",
|
" validation_probe_event <",
|
||||||
" latency_ms: 40730",
|
" latency_ms: 40730",
|
||||||
" network_id <",
|
" network_id <",
|
||||||
@@ -261,6 +274,7 @@ public class IpConnectivityEventBuilderTest extends TestCase {
|
|||||||
verifySerialization(want, ev);
|
verifySerialization(want, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SmallTest
|
||||||
public void testApfProgramEventSerialization() {
|
public void testApfProgramEventSerialization() {
|
||||||
ConnectivityMetricsEvent ev = describeIpEvent(
|
ConnectivityMetricsEvent ev = describeIpEvent(
|
||||||
aType(ApfProgramEvent.class),
|
aType(ApfProgramEvent.class),
|
||||||
@@ -273,6 +287,8 @@ public class IpConnectivityEventBuilderTest extends TestCase {
|
|||||||
String want = joinLines(
|
String want = joinLines(
|
||||||
"dropped_events: 0",
|
"dropped_events: 0",
|
||||||
"events <",
|
"events <",
|
||||||
|
" time_ms: 1",
|
||||||
|
" transport: 0",
|
||||||
" apf_program_event <",
|
" apf_program_event <",
|
||||||
" current_ras: 9",
|
" current_ras: 9",
|
||||||
" drop_multicast: true",
|
" drop_multicast: true",
|
||||||
@@ -281,13 +297,13 @@ public class IpConnectivityEventBuilderTest extends TestCase {
|
|||||||
" lifetime: 200",
|
" lifetime: 200",
|
||||||
" program_length: 2048",
|
" program_length: 2048",
|
||||||
" >",
|
" >",
|
||||||
" time_ms: 1",
|
|
||||||
">",
|
">",
|
||||||
"version: 2");
|
"version: 2");
|
||||||
|
|
||||||
verifySerialization(want, ev);
|
verifySerialization(want, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SmallTest
|
||||||
public void testApfStatsSerialization() {
|
public void testApfStatsSerialization() {
|
||||||
ConnectivityMetricsEvent ev = describeIpEvent(
|
ConnectivityMetricsEvent ev = describeIpEvent(
|
||||||
aType(ApfStats.class),
|
aType(ApfStats.class),
|
||||||
@@ -303,6 +319,8 @@ public class IpConnectivityEventBuilderTest extends TestCase {
|
|||||||
String want = joinLines(
|
String want = joinLines(
|
||||||
"dropped_events: 0",
|
"dropped_events: 0",
|
||||||
"events <",
|
"events <",
|
||||||
|
" time_ms: 1",
|
||||||
|
" transport: 0",
|
||||||
" apf_statistics <",
|
" apf_statistics <",
|
||||||
" dropped_ras: 2",
|
" dropped_ras: 2",
|
||||||
" duration_ms: 45000",
|
" duration_ms: 45000",
|
||||||
@@ -313,13 +331,13 @@ public class IpConnectivityEventBuilderTest extends TestCase {
|
|||||||
" received_ras: 10",
|
" received_ras: 10",
|
||||||
" zero_lifetime_ras: 1",
|
" zero_lifetime_ras: 1",
|
||||||
" >",
|
" >",
|
||||||
" time_ms: 1",
|
|
||||||
">",
|
">",
|
||||||
"version: 2");
|
"version: 2");
|
||||||
|
|
||||||
verifySerialization(want, ev);
|
verifySerialization(want, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SmallTest
|
||||||
public void testRaEventSerialization() {
|
public void testRaEventSerialization() {
|
||||||
ConnectivityMetricsEvent ev = describeIpEvent(
|
ConnectivityMetricsEvent ev = describeIpEvent(
|
||||||
aType(RaEvent.class),
|
aType(RaEvent.class),
|
||||||
@@ -333,6 +351,8 @@ public class IpConnectivityEventBuilderTest extends TestCase {
|
|||||||
String want = joinLines(
|
String want = joinLines(
|
||||||
"dropped_events: 0",
|
"dropped_events: 0",
|
||||||
"events <",
|
"events <",
|
||||||
|
" time_ms: 1",
|
||||||
|
" transport: 0",
|
||||||
" ra_event <",
|
" ra_event <",
|
||||||
" dnssl_lifetime: -1",
|
" dnssl_lifetime: -1",
|
||||||
" prefix_preferred_lifetime: 300",
|
" prefix_preferred_lifetime: 300",
|
||||||
@@ -341,7 +361,6 @@ public class IpConnectivityEventBuilderTest extends TestCase {
|
|||||||
" route_info_lifetime: -1",
|
" route_info_lifetime: -1",
|
||||||
" router_lifetime: 2000",
|
" router_lifetime: 2000",
|
||||||
" >",
|
" >",
|
||||||
" time_ms: 1",
|
|
||||||
">",
|
">",
|
||||||
"version: 2");
|
"version: 2");
|
||||||
|
|
||||||
@@ -351,8 +370,7 @@ public class IpConnectivityEventBuilderTest extends TestCase {
|
|||||||
static void verifySerialization(String want, ConnectivityMetricsEvent... input) {
|
static void verifySerialization(String want, ConnectivityMetricsEvent... input) {
|
||||||
try {
|
try {
|
||||||
byte[] got = IpConnectivityEventBuilder.serialize(0, Arrays.asList(input));
|
byte[] got = IpConnectivityEventBuilder.serialize(0, Arrays.asList(input));
|
||||||
IpConnectivityLog log = new IpConnectivityLog();
|
IpConnectivityLog log = IpConnectivityLog.parseFrom(got);
|
||||||
MessageNano.mergeFrom(log, got);
|
|
||||||
assertEquals(want, log.toString());
|
assertEquals(want, log.toString());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
fail(e.toString());
|
fail(e.toString());
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package com.android.server.connectivity;
|
package com.android.server.connectivity;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.timeout;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.ConnectivityMetricsEvent;
|
import android.net.ConnectivityMetricsEvent;
|
||||||
import android.net.IIpConnectivityMetrics;
|
import android.net.IIpConnectivityMetrics;
|
||||||
@@ -29,9 +32,9 @@ import android.net.metrics.IpReachabilityEvent;
|
|||||||
import android.net.metrics.RaEvent;
|
import android.net.metrics.RaEvent;
|
||||||
import android.net.metrics.ValidationProbeEvent;
|
import android.net.metrics.ValidationProbeEvent;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
import android.test.suitebuilder.annotation.SmallTest;
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
import com.android.server.connectivity.metrics.IpConnectivityLogClass;
|
import com.android.server.connectivity.metrics.IpConnectivityLogClass;
|
||||||
import com.google.protobuf.nano.MessageNano;
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -43,10 +46,6 @@ import org.mockito.ArgumentCaptor;
|
|||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
import static org.mockito.Mockito.timeout;
|
|
||||||
import static org.mockito.Mockito.times;
|
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
|
|
||||||
public class IpConnectivityMetricsTest extends TestCase {
|
public class IpConnectivityMetricsTest extends TestCase {
|
||||||
static final IpReachabilityEvent FAKE_EV =
|
static final IpReachabilityEvent FAKE_EV =
|
||||||
new IpReachabilityEvent("wlan0", IpReachabilityEvent.NUD_FAILED);
|
new IpReachabilityEvent("wlan0", IpReachabilityEvent.NUD_FAILED);
|
||||||
@@ -61,6 +60,7 @@ public class IpConnectivityMetricsTest extends TestCase {
|
|||||||
mService = new IpConnectivityMetrics(mCtx, (ctx) -> 2000);
|
mService = new IpConnectivityMetrics(mCtx, (ctx) -> 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SmallTest
|
||||||
public void testLoggingEvents() throws Exception {
|
public void testLoggingEvents() throws Exception {
|
||||||
IpConnectivityLog logger = new IpConnectivityLog(mMockService);
|
IpConnectivityLog logger = new IpConnectivityLog(mMockService);
|
||||||
|
|
||||||
@@ -74,6 +74,7 @@ public class IpConnectivityMetricsTest extends TestCase {
|
|||||||
assertEventsEqual(expectedEvent(3), got.get(2));
|
assertEventsEqual(expectedEvent(3), got.get(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SmallTest
|
||||||
public void testLoggingEventsWithMultipleCallers() throws Exception {
|
public void testLoggingEventsWithMultipleCallers() throws Exception {
|
||||||
IpConnectivityLog logger = new IpConnectivityLog(mMockService);
|
IpConnectivityLog logger = new IpConnectivityLog(mMockService);
|
||||||
|
|
||||||
@@ -101,6 +102,7 @@ public class IpConnectivityMetricsTest extends TestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SmallTest
|
||||||
public void testBufferFlushing() {
|
public void testBufferFlushing() {
|
||||||
String output1 = getdump("flush");
|
String output1 = getdump("flush");
|
||||||
assertEquals("", output1);
|
assertEquals("", output1);
|
||||||
@@ -113,6 +115,7 @@ public class IpConnectivityMetricsTest extends TestCase {
|
|||||||
assertEquals("", output3);
|
assertEquals("", output3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SmallTest
|
||||||
public void testRateLimiting() {
|
public void testRateLimiting() {
|
||||||
final IpConnectivityLog logger = new IpConnectivityLog(mService.impl);
|
final IpConnectivityLog logger = new IpConnectivityLog(mService.impl);
|
||||||
final ApfProgramEvent ev = new ApfProgramEvent(0, 0, 0, 0, 0);
|
final ApfProgramEvent ev = new ApfProgramEvent(0, 0, 0, 0, 0);
|
||||||
@@ -134,6 +137,7 @@ public class IpConnectivityMetricsTest extends TestCase {
|
|||||||
assertEquals("", output2);
|
assertEquals("", output2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SmallTest
|
||||||
public void testEndToEndLogging() {
|
public void testEndToEndLogging() {
|
||||||
IpConnectivityLog logger = new IpConnectivityLog(mService.impl);
|
IpConnectivityLog logger = new IpConnectivityLog(mService.impl);
|
||||||
|
|
||||||
@@ -154,22 +158,25 @@ public class IpConnectivityMetricsTest extends TestCase {
|
|||||||
String want = joinLines(
|
String want = joinLines(
|
||||||
"dropped_events: 0",
|
"dropped_events: 0",
|
||||||
"events <",
|
"events <",
|
||||||
|
" time_ms: 100",
|
||||||
|
" transport: 0",
|
||||||
" ip_reachability_event <",
|
" ip_reachability_event <",
|
||||||
" event_type: 512",
|
" event_type: 512",
|
||||||
" if_name: \"wlan0\"",
|
" if_name: \"wlan0\"",
|
||||||
" >",
|
" >",
|
||||||
" time_ms: 100",
|
|
||||||
">",
|
">",
|
||||||
"events <",
|
"events <",
|
||||||
|
" time_ms: 200",
|
||||||
|
" transport: 0",
|
||||||
" dhcp_event <",
|
" dhcp_event <",
|
||||||
" duration_ms: 192",
|
" duration_ms: 192",
|
||||||
" error_code: 0",
|
|
||||||
" if_name: \"wlan0\"",
|
" if_name: \"wlan0\"",
|
||||||
" state_transition: \"SomeState\"",
|
" state_transition: \"SomeState\"",
|
||||||
" >",
|
" >",
|
||||||
" time_ms: 200",
|
|
||||||
">",
|
">",
|
||||||
"events <",
|
"events <",
|
||||||
|
" time_ms: 300",
|
||||||
|
" transport: 0",
|
||||||
" default_network_event <",
|
" default_network_event <",
|
||||||
" network_id <",
|
" network_id <",
|
||||||
" network_id: 102",
|
" network_id: 102",
|
||||||
@@ -182,18 +189,19 @@ public class IpConnectivityMetricsTest extends TestCase {
|
|||||||
" transport_types: 2",
|
" transport_types: 2",
|
||||||
" transport_types: 3",
|
" transport_types: 3",
|
||||||
" >",
|
" >",
|
||||||
" time_ms: 300",
|
|
||||||
">",
|
">",
|
||||||
"events <",
|
"events <",
|
||||||
|
" time_ms: 400",
|
||||||
|
" transport: 0",
|
||||||
" ip_provisioning_event <",
|
" ip_provisioning_event <",
|
||||||
" event_type: 1",
|
" event_type: 1",
|
||||||
" if_name: \"wlan0\"",
|
" if_name: \"wlan0\"",
|
||||||
" latency_ms: 5678",
|
" latency_ms: 5678",
|
||||||
" >",
|
" >",
|
||||||
" time_ms: 400",
|
|
||||||
">",
|
">",
|
||||||
"events <",
|
"events <",
|
||||||
" time_ms: 500",
|
" time_ms: 500",
|
||||||
|
" transport: 0",
|
||||||
" validation_probe_event <",
|
" validation_probe_event <",
|
||||||
" latency_ms: 40730",
|
" latency_ms: 40730",
|
||||||
" network_id <",
|
" network_id <",
|
||||||
@@ -204,6 +212,8 @@ public class IpConnectivityMetricsTest extends TestCase {
|
|||||||
" >",
|
" >",
|
||||||
">",
|
">",
|
||||||
"events <",
|
"events <",
|
||||||
|
" time_ms: 600",
|
||||||
|
" transport: 0",
|
||||||
" apf_statistics <",
|
" apf_statistics <",
|
||||||
" dropped_ras: 2",
|
" dropped_ras: 2",
|
||||||
" duration_ms: 45000",
|
" duration_ms: 45000",
|
||||||
@@ -214,9 +224,10 @@ public class IpConnectivityMetricsTest extends TestCase {
|
|||||||
" received_ras: 10",
|
" received_ras: 10",
|
||||||
" zero_lifetime_ras: 1",
|
" zero_lifetime_ras: 1",
|
||||||
" >",
|
" >",
|
||||||
" time_ms: 600",
|
|
||||||
">",
|
">",
|
||||||
"events <",
|
"events <",
|
||||||
|
" time_ms: 700",
|
||||||
|
" transport: 0",
|
||||||
" ra_event <",
|
" ra_event <",
|
||||||
" dnssl_lifetime: -1",
|
" dnssl_lifetime: -1",
|
||||||
" prefix_preferred_lifetime: 300",
|
" prefix_preferred_lifetime: 300",
|
||||||
@@ -225,7 +236,6 @@ public class IpConnectivityMetricsTest extends TestCase {
|
|||||||
" route_info_lifetime: -1",
|
" route_info_lifetime: -1",
|
||||||
" router_lifetime: 2000",
|
" router_lifetime: 2000",
|
||||||
" >",
|
" >",
|
||||||
" time_ms: 700",
|
|
||||||
">",
|
">",
|
||||||
"version: 2");
|
"version: 2");
|
||||||
|
|
||||||
@@ -254,8 +264,7 @@ public class IpConnectivityMetricsTest extends TestCase {
|
|||||||
try {
|
try {
|
||||||
byte[] got = Base64.decode(output, Base64.DEFAULT);
|
byte[] got = Base64.decode(output, Base64.DEFAULT);
|
||||||
IpConnectivityLogClass.IpConnectivityLog log =
|
IpConnectivityLogClass.IpConnectivityLog log =
|
||||||
new IpConnectivityLogClass.IpConnectivityLog();
|
IpConnectivityLogClass.IpConnectivityLog.parseFrom(got);
|
||||||
MessageNano.mergeFrom(log, got);
|
|
||||||
assertEquals(want, log.toString());
|
assertEquals(want, log.toString());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
fail(e.toString());
|
fail(e.toString());
|
||||||
|
|||||||
Reference in New Issue
Block a user