Title: test: use the virtual-time harness to remove long retry waits · Issue #409 · jangala-dev/devicecode-lua · GitHub
Open Graph Title: test: use the virtual-time harness to remove long retry waits · Issue #409 · jangala-dev/devicecode-lua
X Title: test: use the virtual-time harness to remove long retry waits · Issue #409 · jangala-dev/devicecode-lua
Description: The test suite spends most of its elapsed time waiting for real retry and backoff timers. Now that the runner reports OS monotonic elapsed time rather than CPU time, these waits are visible. In a full run of 1,707 tests, five tests in te...
Open Graph Description: The test suite spends most of its elapsed time waiting for real retry and backoff timers. Now that the runner reports OS monotonic elapsed time rather than CPU time, these waits are visible. In a f...
X Description: The test suite spends most of its elapsed time waiting for real retry and backoff timers. Now that the runner reports OS monotonic elapsed time rather than CPU time, these waits are visible. In a f...
Opengraph URL: https://github.com/jangala-dev/devicecode-lua/issues/409
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"test: use the virtual-time harness to remove long retry waits","articleBody":"The test suite spends most of its elapsed time waiting for real retry and backoff timers. Now that the runner reports OS monotonic elapsed time rather than CPU time, these waits are visible.\n\nIn a full run of 1,707 tests, five tests in `tests/unit/gsm/test_modes.lua` consumed **170.5 seconds**, approximately 72% of the 237 seconds accounted for by complete timed result lines. The run had one expected failure from an uncommitted PDP regression; these five tests all passed. Fifteen result lines could not be timed from the capture because output was interleaved, so 237 seconds is not an exact overall runtime.\n\n## Highest-impact candidates\n\n| Test in `unit.gsm.test_modes` | Measured elapsed time |\n| --- | ---: |\n| `state_event_recovery_preserves_and_resumes_the_apn_retry_deadline` | 50.181s |\n| `expired_apn_retry_waits_for_failed_mode_state_refresh_to_recover` | 40.112s |\n| `state_refresh_recovery_preserves_a_future_apn_retry_deadline` | 40.111s |\n| `state_refresh_recovery_connects_without_an_apn_retry_deadline` | 20.071s |\n| `mode_retry_does_not_preempt_apn_backoff` | 20.062s |\n\nThese tests explicitly call `sleep.sleep(20.05)`, `sleep.sleep(30.05)`, and similar waits. They were introduced in #347 (`455d478`).\n\n## Proposed change\n\nUse the existing `tests/support/virtual_time.lua` clock together with `tests/support/time_harness.lua` to advance simulated time and give fibers bounded scheduling turns instead of waiting for real seconds.\n\n- Install and reliably restore the virtual clock around each relevant test.\n- Advance to meaningful retry/backoff boundaries, allowing runnable fibers to settle between advances.\n- Preserve assertions that recovery does not preempt an APN cooldown, that the original deadline is retained, and that connecting resumes when that deadline is reached. Check behaviour immediately before and after the boundary where appropriate.\n- Keep test-duration reporting on the OS monotonic clock, independent of simulated fiber time (see branch `fix/test_durations`, commit `e4fc12a`).\n- Avoid merely shortening production retry constants or removing waits/assertions: retain coverage of the actual configured deadlines.\n\n## Other candidates to investigate\n\n| Test | Measured elapsed time |\n| --- | ---: |\n| `unit.hal.openwrt_speedtest_spec :: test_worker_deadline_shuts_down_stalled_process` | 9.810s |\n| `unit.gsm.test_apn_legacy_import_service :: test_import_waits_for_the_store_to_answer` | 3.024s |\n| `unit.hal.modem_pdp_spec :: test_pdp_setter_verifies_silent_timeout` | 3.004s |\n| `unit.net.test_service_behaviour :: test_failure_retry_is_not_lost_behind_an_earlier_interval_timer` | 2.335s |\n| `unit.net.test_service_behaviour :: test_raising_interval_rearms_the_timer_for_the_cached_result` | 2.033s |\n| `unit.net.test_service_behaviour :: test_active_scope_interval_timer_follows_the_latest_result` | 2.026s |\n\nThe APN and network timer tests are plausible harness candidates. Inspect tests involving real subprocesses or external I/O separately: retain bounded real-time integration coverage where virtual fiber time cannot drive the underlying operation.\n\n## Validation\n\n- Run the converted tests individually and as part of the full suite to catch virtual-clock leaks.\n- Confirm existing deadline/recovery assertions still pass and regression detection is retained.\n- Compare elapsed durations before and after; the five GSM tests should no longer spend roughly 170 seconds in real waits.\n","author":{"url":"https://github.com/rslater-cs","@type":"Person","name":"rslater-cs"},"datePublished":"2026-11-12T15:35:43Z","url":"https://github.com/jangala-dev/devicecode-lua/issues/409"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e8b8bcaf-9e19-636a-486e-e29506c28d62 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E4DA:29D7A5:15E7F40:1CD4BA9:6AF89A9D |
| html-safe-nonce | 685fdff42cd29799f1de97e46c6ac6af2bee8e01f7b74bc48747f9b2b9c2bc41 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNERBOjI5RDdBNToxNUU3RjQwOjFDRDRCQTk6NkFGODlBOUQiLCJ2aXNpdG9yX2lkIjoiMTM2NTc3NTIyMjY2MDUzMjc3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e67fc38881d8e656cd56f4cf2d05a9eca6256fb94c4ffb308e95dafb174e8a8c |
| hovercard-subject-tag | issue:6353258836 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/jangala-dev/devicecode-lua/409/issue_layout |
| twitter:image | https://opengraph.githubassets.com/771d27db3e999db0a49abf82dd23910622069d4925b2c172b25f0ed4d3523474/jangala-dev/devicecode-lua/issues/409 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/771d27db3e999db0a49abf82dd23910622069d4925b2c172b25f0ed4d3523474/jangala-dev/devicecode-lua/issues/409 |
| og:image:alt | The test suite spends most of its elapsed time waiting for real retry and backoff timers. Now that the runner reports OS monotonic elapsed time rather than CPU time, these waits are visible. In a f... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rslater-cs |
| hostname | github.com |
| expected-hostname | github.com |
| None | 612d3e6ffd693e7ea8d9fcf452370995872baef31d825b1fedef704cd3d24ac7 |
| turbo-cache-control | no-preview |
| go-import | github.com/jangala-dev/devicecode-lua git https://github.com/jangala-dev/devicecode-lua.git |
| octolytics-dimension-user_id | 44901909 |
| octolytics-dimension-user_login | jangala-dev |
| octolytics-dimension-repository_id | 814022112 |
| octolytics-dimension-repository_nwo | jangala-dev/devicecode-lua |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 814022112 |
| octolytics-dimension-repository_network_root_nwo | jangala-dev/devicecode-lua |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 072e34035c13c31543fba9f025cbbbda4210dae4 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width