Skip to content

🐛 Stabilize flaky auth decorator overhead test by using high-resolution timing and safe ratio calculation#9041

Merged
mergify[bot] merged 1 commit intoITISFoundation:masterfrom
GitHK:pr-osparc-fix-flay-webserver-unittest
Apr 20, 2026
Merged

🐛 Stabilize flaky auth decorator overhead test by using high-resolution timing and safe ratio calculation#9041
mergify[bot] merged 1 commit intoITISFoundation:masterfrom
GitHK:pr-osparc-fix-flay-webserver-unittest

Conversation

@GitHK
Copy link
Copy Markdown
Contributor

@GitHK GitHK commented Apr 20, 2026

What do these changes do?

This PR fixes a flaky unit test in test_security_web.py, specifically test_time_overhead_on_handlers_of_auth_decorators.

Root cause:

  1. On fast CI runners, the reference median latency could be 0 because of timer granularity.
  2. The test built a diagnostic string with a division by the reference median, which could raise ZeroDivisionError before the assertion.

What changed:

  1. Replaced timing with a high-resolution monotonic clock using perf_counter_ns.
  2. Kept the same performance intent (admin handler overhead vs public handler baseline).
  3. Made ratio computation safe to avoid division-by-zero in diagnostics.
  4. Updated debug output to nanoseconds for clearer CI observability.

Impact:

  1. Removes intermittent CI failures caused by ZeroDivisionError.
  2. Preserves the behavioral purpose of the test.
  3. No production code changes, test-only stabilization.

Related issue/s

How to test

Dev-ops

@GitHK GitHK added this to the Etna milestone Apr 20, 2026
@GitHK GitHK self-assigned this Apr 20, 2026
@GitHK GitHK added the t:maintenance Some planned maintenance work label Apr 20, 2026
@GitHK GitHK marked this pull request as ready for review April 20, 2026 08:00
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Stabilizes a flaky performance-overhead unit test in the webserver security tests by switching to a higher-resolution monotonic timer and making the diagnostic ratio computation resilient to zero/near-zero baselines.

Changes:

  • Replace event-loop timing with time.perf_counter_ns() for higher-resolution measurements.
  • Update median/ratio diagnostics to use nanoseconds and avoid division-by-zero in debug output.
  • Keep the existing overhead assertion intent (admin handler vs public handler baseline).

Comment thread services/web/server/tests/unit/isolated/test_security_web.py
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.77%. Comparing base (16dd1a9) to head (d28c614).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9041      +/-   ##
==========================================
- Coverage   87.35%   82.77%   -4.59%     
==========================================
  Files        2056      792    -1264     
  Lines       80971    36980   -43991     
  Branches     1451      182    -1269     
==========================================
- Hits        70731    30609   -40122     
+ Misses       9829     6321    -3508     
+ Partials      411       50     -361     
Flag Coverage Δ
integrationtests 63.96% <ø> (+0.06%) ⬆️
unittests 86.00% <ø> (-0.23%) ⬇️
Components Coverage Δ
pkg_aws_library ∅ <ø> (∅)
pkg_celery_library ∅ <ø> (∅)
pkg_dask_task_models_library ∅ <ø> (∅)
pkg_models_library ∅ <ø> (∅)
pkg_notifications_library ∅ <ø> (∅)
pkg_postgres_database ∅ <ø> (∅)
pkg_service_integration ∅ <ø> (∅)
pkg_service_library ∅ <ø> (∅)
pkg_settings_library ∅ <ø> (∅)
pkg_simcore_sdk 69.45% <ø> (-16.50%) ⬇️
agent ∅ <ø> (∅)
api_server ∅ <ø> (∅)
autoscaling ∅ <ø> (∅)
catalog ∅ <ø> (∅)
clusters_keeper ∅ <ø> (∅)
dask_sidecar ∅ <ø> (∅)
datcore_adapter ∅ <ø> (∅)
director ∅ <ø> (∅)
director_v2 79.08% <ø> (-12.52%) ⬇️
dynamic_scheduler ∅ <ø> (∅)
dynamic_sidecar 73.91% <ø> (-13.59%) ⬇️
efs_guardian ∅ <ø> (∅)
invitations ∅ <ø> (∅)
payments ∅ <ø> (∅)
resource_usage_tracker ∅ <ø> (∅)
storage ∅ <ø> (∅)
webclient ∅ <ø> (∅)
webserver 86.73% <ø> (-0.04%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 16dd1a9...d28c614. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@GitHK GitHK added the 🤖-automerge marks PR as ready to be merged for Mergify label Apr 20, 2026
@GitHK
Copy link
Copy Markdown
Contributor Author

GitHK commented Apr 20, 2026

@Mergifyio queue

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Apr 20, 2026

Merge Queue Status

🛑 Queue command has been cancelled

@mergify mergify Bot added the queued label Apr 20, 2026
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Apr 20, 2026

Merge Queue Status

  • Entered queue2026-04-20 08:24 UTC · Rule: default
  • Checks skipped · PR is already up-to-date
  • Merged2026-04-20 08:24 UTC · at d28c614129ee7e7d8372d726d2f41d713014030c

This pull request spent 11 seconds in the queue, including 1 second running CI.

Required conditions to merge

@mergify mergify Bot merged commit 864bb0b into ITISFoundation:master Apr 20, 2026
98 of 101 checks passed
@mergify mergify Bot removed the queued label Apr 20, 2026
@GitHK GitHK deleted the pr-osparc-fix-flay-webserver-unittest branch April 20, 2026 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖-automerge marks PR as ready to be merged for Mergify t:maintenance Some planned maintenance work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants