mirror of
https://github.com/espressif/openthread.git
synced 2026-10-20 06:28:14 +00:00
[nexus] increase advance time in border agent wrong key test (#13662)
This commit fixes a test flakiness issue in `nexus_border_agent` where `TestBorderAgentEphemeralKey` and `TestHistoryTrackerBorderAgentEpskcEvent` attempted consecutive DTLS connections with the wrong key in a loop. When a secure session disconnects, `SecureSession::Disconnect` starts a 2-second guard timer (`kGuardTimeNewConnectionMilli`) before transitioning the session to `kStateDisconnected`. If the DTLS handshake took longer than expected (e.g. due to simulated MAC backoff or packet retransmission), advancing a fixed 3 seconds left the session in `kStateDisconnecting`, causing the subsequent `Connect()` call on the same `SecureAgent` to fail with `kErrorInvalidState`. This change increases the advance time from 3 to 6 seconds (well within the 120-second default ephemeral key lifetime) and adds checks to verify that the session is no longer active before initiating the next connection attempt, avoiding unbounded loops while preventing flakiness.
This commit is contained in:
@@ -584,9 +584,10 @@ void TestBorderAgentEphemeralKey(void)
|
||||
|
||||
SuccessOrQuit(node1.Get<Tmf::SecureAgent>().Connect(sockAddr));
|
||||
|
||||
nexus.AdvanceTime(3 * Time::kOneSecondInMsec);
|
||||
nexus.AdvanceTime(6 * Time::kOneSecondInMsec);
|
||||
|
||||
VerifyOrQuit(!node1.Get<Tmf::SecureAgent>().IsConnected());
|
||||
VerifyOrQuit(!node1.Get<Tmf::SecureAgent>().IsConnectionActive());
|
||||
VerifyOrQuit(node0.Get<EphemeralKeyManager>().GetState() == EphemeralKeyManager::kStateStarted);
|
||||
}
|
||||
|
||||
@@ -594,7 +595,7 @@ void TestBorderAgentEphemeralKey(void)
|
||||
|
||||
sEphemeralKeyCallbackCalled = false;
|
||||
SuccessOrQuit(node1.Get<Tmf::SecureAgent>().Connect(sockAddr));
|
||||
nexus.AdvanceTime(3 * Time::kOneSecondInMsec);
|
||||
nexus.AdvanceTime(6 * Time::kOneSecondInMsec);
|
||||
|
||||
VerifyOrQuit(!node1.Get<Tmf::SecureAgent>().IsConnected());
|
||||
VerifyOrQuit(node0.Get<EphemeralKeyManager>().GetState() == EphemeralKeyManager::kStateStopped);
|
||||
@@ -912,16 +913,17 @@ void TestHistoryTrackerBorderAgentEpskcEvent(void)
|
||||
|
||||
SuccessOrQuit(node1.Get<Tmf::SecureAgent>().Connect(sockAddr));
|
||||
|
||||
nexus.AdvanceTime(3 * Time::kOneSecondInMsec);
|
||||
nexus.AdvanceTime(6 * Time::kOneSecondInMsec);
|
||||
|
||||
VerifyOrQuit(!node1.Get<Tmf::SecureAgent>().IsConnected());
|
||||
VerifyOrQuit(!node1.Get<Tmf::SecureAgent>().IsConnectionActive());
|
||||
VerifyOrQuit(node0.Get<EphemeralKeyManager>().GetState() == EphemeralKeyManager::kStateStarted);
|
||||
}
|
||||
|
||||
Log(" Attempt 10 (final attempt) to connect with the wrong key, check that ephemeral key use is stopped");
|
||||
|
||||
SuccessOrQuit(node1.Get<Tmf::SecureAgent>().Connect(sockAddr));
|
||||
nexus.AdvanceTime(3 * Time::kOneSecondInMsec);
|
||||
nexus.AdvanceTime(6 * Time::kOneSecondInMsec);
|
||||
|
||||
VerifyOrQuit(!node1.Get<Tmf::SecureAgent>().IsConnected());
|
||||
VerifyOrQuit(node0.Get<EphemeralKeyManager>().GetState() == EphemeralKeyManager::kStateStopped);
|
||||
|
||||
Reference in New Issue
Block a user