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.
This commit is contained in:
@@ -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(
|
||||
"[email protected]",
|
||||
"this is a very strong password",
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user