jmeter icon indicating copy to clipboard operation
jmeter copied to clipboard

RandomDate: include end date and handle single-day ranges

Open weillercarvalho opened this issue 1 month ago • 0 comments

Description

RandomDate now picks inclusive date ranges by delegating the day selection to a new pickRandomDay(...) helper. That method returns the single-day range immediately and otherwise calls ThreadLocalRandom.nextLong(start, end + 1) using Math.incrementExact, so the configured end date can be emitted and start == end no longer throws. The tests for __RandomDate were updated to accept both bounds and now include explicit coverage for the single-day case and for ensuring the end date eventually appears.

Motivation and Context

Fixes #6609 . The current implementation treats the end date as exclusive and blows up when both bounds are equal, which makes it impossible to configure fixed dates or truly closed intervals in test plans.

How Has This Been Tested?

  • ./gradlew :src:functions:test --tests org.apache.jmeter.functions.TestTimeRandomDateFunction

  • ./gradlew check (fails in :src:protocol:bolt:test due to the flaky BoltSamplerTest.should ignore invalid timeout values() timeout; unrelated to this change)

    Screenshots (if appropriate):

    n/a

    Types of changes

  • [x] Bug fix (non-breaking change which fixes an issue)

  • [ ] New feature (non-breaking change which adds functionality)

  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

    Checklist:

  • [x] My code follows the code style of this project.

  • [ ] I have updated the documentation accordingly.

weillercarvalho avatar Nov 17 '25 19:11 weillercarvalho