From 2f1e4bd2c7db37bc500f65536fe165cde790eb99 Mon Sep 17 00:00:00 2001 From: John Coffey Date: Sat, 19 Sep 2026 15:38:01 -0700 Subject: [PATCH] Tests: give the fail2ban and task-manager checks room under load Two long-standing flakes in system_tests, both timing: - security: the ban period was set to one second, but the test makes a hundred more requests before it checks that a valid password from the banned address is refused, so under load the ban had already expired. Five seconds, and the expiry check sleeps six. - task: a task scheduled one second out was queried for straight away, and under load the query landed after the task manager had run and removed it. Three seconds. Seven consecutive system_tests runs, neither recurred. --- tests/src/system/security.rs | 9 ++++++--- tests/src/system/task.rs | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/src/system/security.rs b/tests/src/system/security.rs index b85a92f..497f620 100644 --- a/tests/src/system/security.rs +++ b/tests/src/system/security.rs @@ -174,8 +174,11 @@ pub async fn test(test: &mut TestServer) { .registry_update_object( ObjectType::Security, Id::singleton(), + // inbuxa: five seconds, not one: the checks below make a hundred + // more requests before the ban is tested, and under load a + // one-second ban expired first json!({ - Property::AuthBanPeriod: registry::types::duration::Duration::from_millis(1000) + Property::AuthBanPeriod: registry::types::duration::Duration::from_millis(5000) }), ) .await; @@ -206,8 +209,8 @@ pub async fn test(test: &mut TestServer) { assert_eq!(blocked_ip.reason, BlockReason::AuthFailure); assert!(blocked_ip.expires_at.is_some()); - // After 1 second the ban should be lifted - tokio::time::sleep(Duration::from_secs(2)).await; + // After the ban period the ban should be lifted + tokio::time::sleep(Duration::from_secs(6)).await; validate_password_with_ip( "user@example.org", "this is a very strong password", diff --git a/tests/src/system/task.rs b/tests/src/system/task.rs index 3443904..faed530 100644 --- a/tests/src/system/task.rs +++ b/tests/src/system/task.rs @@ -39,7 +39,9 @@ pub async fn test(test: &mut TestServer) { admin.assert_no_tasks().await; // Create a successful task for future execution - admin.schedule_test_task(TASK_SUCCESS, 1).await; + // inbuxa: three seconds, not one: the query below takes longer than a + // second under load, and the task had already run and been removed + admin.schedule_test_task(TASK_SUCCESS, 3).await; admin.assert_has_tasks(1).await; admin.assert_no_tasks().await;