Skip to content
  • Aditya Narsapurkar's avatar
    3aacd855
    parent 6d0895a4 · 3aacd855
    Aditya Narsapurkar authored
    author Aditya Narsapurkar <adityanarsapurkar@yahoo.com> 1582316102 +0530
    committer Aditya Narsapurkar <adityanarsapurkar@yahoo.com> 1583159505 +0530
    
    parent 6d0895a4
    author Aditya Narsapurkar <adityanarsapurkar@yahoo.com> 1582316102 +0530
    committer Aditya Narsapurkar <adityanarsapurkar@yahoo.com> 1583159327 +0530
    
    Randomize jitter
    - This PR attempts to fix a problem with ActiveJob jitter where the `determine_jitter_for_delay` value may not always be randomized. Especially when the jitter delay multplier is between 1 and 2 it always returns 0.
    - With this change, we pass a range to `Kernel.rand` beginning with 0 to the `jitter_multiplier`. With positive float values, the return value will be a random float number from the range.
    - Includes test cases to verify random wait time when the jitter_multiplier is between 1 and 2.
    - Updated relevant test cases stubbing the `Kernel.rand` method, refactored some by removing unwanted stubs for `Kernel.rand` method where jitter is falsey.
    
    Fixed rubocop issue - used assert_not_equal instead of refute_equal in test case
    
    Fixed rubocop issue - used assert_not_equal instead of refute_equal in test case
    
    Fixed rubocop issue - used assert_not_equal instead of refute_equal in test case
    
    Review updates - separated test cases for random wait time with default and exponentially retrying jobs
    - Another test case added to make sure negative wait time does not affect the randomization
    
    Review updates
    - Instead of using Kernel.rand with range, used simple multiplication with Kernel.rand for calculating delay for jitter
    - Updates to the tests according to changes
    3aacd855
    parent 6d0895a4
    Aditya Narsapurkar authored
    author Aditya Narsapurkar <adityanarsapurkar@yahoo.com> 1582316102 +0530
    committer Aditya Narsapurkar <adityanarsapurkar@yahoo.com> 1583159505 +0530
    
    parent 6d0895a4
    author Aditya Narsapurkar <adityanarsapurkar@yahoo.com> 1582316102 +0530
    committer Aditya Narsapurkar <adityanarsapurkar@yahoo.com> 1583159327 +0530
    
    Randomize jitter
    - This PR attempts to fix a problem with ActiveJob jitter where the `determine_jitter_for_delay` value may not always be randomized. Especially when the jitter delay multplier is between 1 and 2 it always returns 0.
    - With this change, we pass a range to `Kernel.rand` beginning with 0 to the `jitter_multiplier`. With positive float values, the return value will be a random float number from the range.
    - Includes test cases to verify random wait time when the jitter_multiplier is between 1 and 2.
    - Updated relevant test cases stubbing the `Kernel.rand` method, refactored some by removing unwanted stubs for `Kernel.rand` method where jitter is falsey.
    
    Fixed rubocop issue - used assert_not_equal instead of refute_equal in test case
    
    Fixed rubocop issue - used assert_not_equal instead of refute_equal in test case
    
    Fixed rubocop issue - used assert_not_equal instead of refute_equal in test case
    
    Review updates - separated test cases for random wait time with default and exponentially retrying jobs
    - Another test case added to make sure negative wait time does not affect the randomization
    
    Review updates
    - Instead of using Kernel.rand with range, used simple multiplication with Kernel.rand for calculating delay for jitter
    - Updates to the tests according to changes
Loading