Log VCN network validated and not validated events.
Flag: EXEMPT METRICS Test: atest FrameworksVcnTests, CtsVcnTestCases Bug: 288600040 Change-Id: I574db304dc8377e70500f52f52d9b14934e5182a
This commit is contained in:
parent
2cb4715d08
commit
f0c44cb378
2 changed files with 34 additions and 0 deletions
|
|
@ -1860,10 +1860,13 @@ public class VcnGatewayConnection extends StateMachine {
|
|||
if (mIsQuitting.getValue()) {
|
||||
return; // Ignore; VcnGatewayConnection quitting or already quit
|
||||
}
|
||||
// TODO(b/443831229): check if mNetworkAgent is stale first.
|
||||
|
||||
switch (status) {
|
||||
case NetworkAgent.VALIDATION_STATUS_VALID:
|
||||
clearFailedAttemptCounterAndSafeModeAlarm();
|
||||
mVcnMetrics.logVcnNetworkValidated(
|
||||
mId, mNetworkAgent.getIdentityHashCode());
|
||||
break;
|
||||
case NetworkAgent.VALIDATION_STATUS_NOT_VALID:
|
||||
// Trigger re-validation of underlying networks; if it
|
||||
|
|
@ -1877,6 +1880,8 @@ public class VcnGatewayConnection extends StateMachine {
|
|||
// Will only set a new alarm if no safe mode alarm is
|
||||
// currently scheduled.
|
||||
setSafeModeAlarm();
|
||||
mVcnMetrics.logVcnNetworkNotValidated(
|
||||
mId, mNetworkAgent.getIdentityHashCode());
|
||||
break;
|
||||
default:
|
||||
logWtf(
|
||||
|
|
@ -2982,6 +2987,7 @@ public class VcnGatewayConnection extends StateMachine {
|
|||
@VisibleForTesting(visibility = Visibility.PRIVATE)
|
||||
public static class VcnNetworkAgent {
|
||||
private final NetworkAgent mImpl;
|
||||
private final int mId;
|
||||
|
||||
public VcnNetworkAgent(
|
||||
@NonNull VcnContext vcnContext,
|
||||
|
|
@ -3013,6 +3019,7 @@ public class VcnGatewayConnection extends StateMachine {
|
|||
validationStatusCallback.accept(status);
|
||||
}
|
||||
};
|
||||
mId = System.identityHashCode(this);
|
||||
}
|
||||
|
||||
/** Registers the underlying NetworkAgent */
|
||||
|
|
@ -3045,6 +3052,11 @@ public class VcnGatewayConnection extends StateMachine {
|
|||
mImpl.setUnderlyingNetworks(underlyingNetworks);
|
||||
}
|
||||
|
||||
/** Retrieves the identity hash code of the underlying NetworkAgent */
|
||||
public int getIdentityHashCode() {
|
||||
return mId;
|
||||
}
|
||||
|
||||
/** Retrieves the Network for the underlying NetworkAgent */
|
||||
@Nullable
|
||||
public Network getNetwork() {
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ import java.util.function.Consumer;
|
|||
@SmallTest
|
||||
public class VcnGatewayConnectionConnectedStateTest extends VcnGatewayConnectionTestBase {
|
||||
private static final int PARALLEL_SA_COUNT = 4;
|
||||
private static final int NETWORK_AGENT_ID = 1234;
|
||||
|
||||
private VcnIkeSession mIkeSession;
|
||||
private VcnNetworkAgent mNetworkAgent;
|
||||
|
|
@ -114,6 +115,7 @@ public class VcnGatewayConnectionConnectedStateTest extends VcnGatewayConnection
|
|||
|
||||
mVcnNetwork = mock(Network.class);
|
||||
doReturn(mVcnNetwork).when(mNetworkAgent).getNetwork();
|
||||
doReturn(NETWORK_AGENT_ID).when(mNetworkAgent).getIdentityHashCode();
|
||||
|
||||
mGatewayConnection.setUnderlyingNetwork(TEST_UNDERLYING_NETWORK_RECORD_1);
|
||||
|
||||
|
|
@ -611,6 +613,26 @@ public class VcnGatewayConnectionConnectedStateTest extends VcnGatewayConnection
|
|||
verifyNoMoreInteractions(mIpSecSvc);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidatedTriggered_logsMetrics() throws Exception {
|
||||
triggerChildOpened();
|
||||
mTestLooper.dispatchAll();
|
||||
|
||||
triggerValidation(NetworkAgent.VALIDATION_STATUS_VALID);
|
||||
|
||||
verify(mVcnMetrics).logVcnNetworkValidated(anyInt(), eq(NETWORK_AGENT_ID));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotValidatedTriggered_logsMetrics() throws Exception {
|
||||
triggerChildOpened();
|
||||
mTestLooper.dispatchAll();
|
||||
|
||||
triggerValidation(NetworkAgent.VALIDATION_STATUS_NOT_VALID);
|
||||
|
||||
verify(mVcnMetrics).logVcnNetworkNotValidated(anyInt(), eq(NETWORK_AGENT_ID));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccessfulConnectionExitsSafeMode() throws Exception {
|
||||
verifySafeModeTimeoutNotifiesCallbackAndUnregistersNetworkAgent(
|
||||
|
|
|
|||
Loading…
Reference in a new issue