tag1consulting / goose

Load testing framework, inspired by Locust
https://tag1.com/goose
Apache License 2.0
809 stars 70 forks source link

shutdown hangs when a delay >1s is configured #390

Closed jeremyandrews closed 2 years ago

jeremyandrews commented 2 years ago

It seems if you enable a delay of greater than 1s between tasks, shutdown hangs indefinitely. If the delay is <1000ms it doesn't hang.

For example, with the following edit the drupal_memcache example hangs on shutdown:

diff --git a/examples/drupal_memcache.rs b/examples/drupal_memcache.rs
index bad120e..a375afb 100644
--- a/examples/drupal_memcache.rs
+++ b/examples/drupal_memcache.rs
@@ -52,6 +52,7 @@ async fn main() -> Result<(), GooseError> {
         .register_taskset(
             taskset!("AuthBrowsingUser")
                 .set_weight(1)?
+               .set_wait_time(std::time::Duration::from_millis(1001), std::time::Duration::from_millis(1500))?
                 .register_task(
                     task!(drupal_memcache_login)
                         .set_on_start()

If run as follows:

% cargo run --release --example drupal_memcache -- --host http://apache -u 10 -s5 -t5 -v

It starts and runs correctly:

08:12:19 [INFO] entering GooseAttack phase: Starting
08:12:19 [INFO] launching user 1 from AnonBrowsingUser...
08:12:19 [INFO] launching user 2 from AnonBrowsingUser...
08:12:20 [INFO] launching user 3 from AnonBrowsingUser...
08:12:20 [INFO] launching user 4 from AuthBrowsingUser...
08:12:21 [INFO] launching user 5 from AnonBrowsingUser...
08:12:21 [INFO] launching user 6 from AnonBrowsingUser...
08:12:22 [INFO] launching user 7 from AnonBrowsingUser...
08:12:22 [INFO] launching user 8 from AnonBrowsingUser...
08:12:23 [INFO] launching user 9 from AuthBrowsingUser...
08:12:24 [INFO] launching user 10 from AnonBrowsingUser...
08:12:24 [INFO] launched 10 users...

But the AuthBrowsingUser with the delay fails to stop when the load test completes:

08:12:24 [INFO] entering GooseAttack phase: Running
08:12:29 [INFO] entering GooseAttack phase: Stopping
08:12:29 [INFO] stopping after 5 seconds...
08:12:29 [INFO] waiting for users to exit
08:12:29 [INFO] exiting user 7 from AnonBrowsingUser...
08:12:29 [INFO] exiting user 6 from AnonBrowsingUser...
08:12:29 [INFO] exiting user 3 from AnonBrowsingUser...
08:12:29 [INFO] exiting user 8 from AnonBrowsingUser...
08:12:29 [INFO] exiting user 5 from AnonBrowsingUser...
08:12:29 [INFO] exiting user 10 from AnonBrowsingUser...
08:12:29 [INFO] exiting user 2 from AnonBrowsingUser...
08:12:32 [INFO] exiting user 1 from AnonBrowsingUser...
^C08:12:57 [WARN] caught ctrl-c, stopping...
^C08:13:01 [WARN] caught another ctrl-c, exiting immediately...

(And if instead we edit AnonBrowsingUser then all of its threads instead fail to shut down ...)