zerocode icon indicating copy to clipboard operation
zerocode copied to clipboard

feat: add abortAfterTimeLapsedInSeconds support to ExecutorServiceRunner

Open CommitToday opened this issue 1 month ago • 0 comments

Overview

This pull request implements the abort.after.time.lapsed.in.seconds feature to allow load tests to be automatically aborted after a specified time period. It adds a timeout mechanism to the ExecutorServiceRunner class that checks elapsed time at key points during test execution and throws a runtime exception if the configured timeout is exceeded.

Checklist

  • [x] Code changes are complete
  • [x] Tests pass
  • [x] Documentation updated (if applicable)

Proof that changes are correct

The implementation adds a new abortAfterTimeLapsedInSeconds field and parameter to the ExecutorServiceRunner constructor. The timeout check is performed at multiple points in the execution flow:

  1. Before each loop iteration
  2. Before executing each thread
  3. After sleeping between threads
  4. While waiting for tasks to complete

The timeout check is wrapped in a private isTimeoutExceeded method that compares the elapsed time since the start of the test with the configured timeout. When the timeout is exceeded, a runtime exception is thrown and the executor service is shut down. This ensures that tests will not run indefinitely and can be controlled by the configured timeout value.

CommitToday avatar Nov 08 '25 03:11 CommitToday