🐛 Fix ZeroDivisionError in test_time_overhead_on_handlers_of_auth_decorators#9046
🐛 Fix ZeroDivisionError in test_time_overhead_on_handlers_of_auth_decorators#9046GitHK wants to merge 1 commit intoITISFoundation:masterfrom
test_time_overhead_on_handlers_of_auth_decorators#9046Conversation
|
|
@Mergifyio queue |
Merge Queue Status
Waiting for:
All conditions
|
| ref_elapsed_ns = statistics.median(public_elapsed_times) | ||
| elapsed_ns = statistics.median(admin_elapsed_times) | ||
| elapsed_ratio = elapsed_ns / max(ref_elapsed_ns, 1) | ||
| elapsed_ratio = elapsed_ns / max(ref_elapsed_ns, sys.float_info.min) |
There was a problem hiding this comment.
Why would denominator max(ref_elapsed_ns, 1) produce a division by zero?
if ref_elapsed_ns==0 then max(ref_elapsed_ns, 1) == 1 and elapsed_ns / max(ref_elapsed_ns, 1) = elapsed_ns
In the description you mention that it has to do with 1 being integer... but i od not undrstand it. You mean it has to be ``max(ref_elapsed_ns, 1.0)`
There was a problem hiding this comment.
Thisi s a bit strange ...
It seems to me that the code tested is not the same as the one you modify here. In the snapshot below (from the CI ) i do not see the line elapsed_ratio = elapsed_ns / max(ref_elapsed_ns, 1) ...
what am i missing here?
There was a problem hiding this comment.
You are correct, this was coming form the hot fix branch which does not have this fix implemented. Closing PR since it's useless.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9046 +/- ##
==========================================
- Coverage 87.35% 82.77% -4.58%
==========================================
Files 2056 792 -1264
Lines 81003 37011 -43992
Branches 1451 182 -1269
==========================================
- Hits 70758 30636 -40122
+ Misses 9834 6325 -3509
+ Partials 411 50 -361
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
|
did not properly check, already fixed, the Hotfix branch was casing issues |



What do these changes do?
Fixes a flaky
ZeroDivisionErrorintest_time_overhead_on_handlers_of_auth_decoratorsthat occurs whenref_elapsed_ns(the median of public endpoint timings) resolves to 0.The previous guard
max(ref_elapsed_ns, 1)used an integer floor of 1, which does not protect against a float 0.0 fromstatistics.median. Replaced withmax(ref_elapsed_ns, sys.float_info.min)(~2.2e-308), the smallest positive normalized float, guaranteeing the denominator is never zero.Related issue/s
How to test
Dev-ops