Skip to content

Commit 12c0b9b

Browse files
Try to avoid flakiness in test_automatic_wireguard_rotation
1 parent c7dbb69 commit 12c0b9b

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

test/test-manager/src/tests/account.rs

+24-11
Original file line numberDiff line numberDiff line change
@@ -262,19 +262,32 @@ pub async fn test_automatic_wireguard_rotation(
262262
DaemonEvent::Device(device_event) => Some(device_event),
263263
_ => None,
264264
};
265-
let device_event = tokio::task::spawn(tokio::time::timeout(
265+
let device_event_listener = tokio::time::timeout(
266266
Duration::from_secs(100),
267267
helpers::find_daemon_event(event_listener, device_event),
268-
))
269-
.await?
270-
.context("Tunnel event listener timed out")??;
271-
272-
let new_key = device_event
273-
.new_state
274-
.into_device()
275-
.context("Could not get device")?
276-
.device
277-
.pubkey;
268+
);
269+
let new_key = match device_event_listener.await {
270+
Err(err) => {
271+
log::warn!("{err}");
272+
log::warn!(
273+
"Did not observe any daemon event indicating that a key rotation happened"
274+
);
275+
// Note: The key rotation could possible have happened without us noticing due to
276+
// some raceiness in the timeframe between starting the daemon and us starting to
277+
// listen for new daemon events. Thus, it is probably a good idea to check manually if the
278+
// device key was rotated.
279+
log::info!("Manually checking if device key was rotated");
280+
mullvad_client
281+
.get_device()
282+
.await
283+
.context("Failed to get device data")?
284+
}
285+
Ok(device_event) => device_event?.new_state,
286+
}
287+
.logged_in()
288+
.context("Client is not logged in to a valid account")?
289+
.device
290+
.pubkey;
278291

279292
assert_ne!(old_key, new_key);
280293
}

0 commit comments

Comments
 (0)