Skip to content

fix(tests): four tests that wait for a time window fail under host load - #2139

Merged
dan-petty merged 1 commit into
mainfrom
fix/2092-tests-wait-for-events
Oct 24, 2026
Merged

dan-petty merged 1 commit into
mainfrom
fix/2092-tests-wait-for-events

Conversation

@dan-petty

@dan-petty dan-petty commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

Summary

Four tests of #2092, and the test of #2069, failed on a loaded host and passed alone. Each had its own cause, and two of the causes were defects in devops ci test. This change removes each time window that load could exceed. No timeout is longer, no test is retried or marked as flaky, and no test is skipped.

  • A stop signal to devops ci test could wait 300 s (a product defect, found by the 50-run check of this change). The SIGTERM case of test_a_signal_to_devops_ci_test_lets_pytest_tear_down_then_stops_its_group failed with assert (True, 130, True, False), and devops exited 300 s after its child started. The run set its handlers with signal.signal. Such a handler runs only when the main thread runs bytecode again, and the epoll wait of the event loop reads a pending signal only when the wait ends with EINTR. A signal that comes just before the wait, or that the kernel hands to another thread, does not wake the loop. The run then took the signal only when its child exited, after the 300 s hold of the grandchild. The run now sets its handlers with loop.add_signal_handler, which writes each signal to the loop's own socket (signal.set_wakeup_fd). The new test_each_stop_signal_cancels_the_run_through_the_event_loop hands a SIGTERM to a thread other than the main one while the loop waits. It fails with the old handlers ({'loop waits': True, 'torn down': False}) and passes with the new ones.
  • A second Ctrl-C could skip the SIGKILL (fix(tests): the second-signal test of devops ci test waits for an event, not a time window, so it passes under load #2069, a product defect). asyncio.run sets its own SIGINT handler, which raises KeyboardInterrupt at a second Ctrl-C between any two bytecodes. When a loaded host keeps devops off the CPU just after the stop sends the run's group its SIGINT, the second Ctrl-C's handler runs there, before the try whose finally sends the SIGKILL. The group then stays alive: the wait_until(watch.stopped) false of fix(tests): the second-signal test of devops ci test waits for an event, not a time window, so it passes under load #2069. The run now takes over SIGINT, as it takes over SIGTERM and SIGHUP (CONST_CI_RUN_STOP_SIGNAL_NAMES). Each signal only cancels the run, so the stop always sends its SIGKILL, and a Ctrl-C exits as cancelled, 130, as before. The new test_a_second_ctrl_c_just_after_the_stop_sends_its_sigint_cannot_skip_the_sigkill raises each Ctrl-C at those two points. It fails on the base with assert ([True], 'Key... False, False) == ([True], 130, True, False).
  • The end-to-end signal tests waited 30 s for a fresh devops to start. The full run of the fix(valkey): valkey.url is one validated url, its path names the database, and the separate host, port and db settings go #2060 commit (24 minutes, load average 40 to 106) failed with assert (False, 130, False, False) for SIGTERM and assert (False, -1, False, False) for SIGHUP: started was false, and -1 shows that devops had not yet set its handlers. On a quiet host the start takes 0.44 s to 0.51 s. The new wait_while_running in tests/support/waits.py waits until the fake uv writes its pids or devops exits, and the tests wait for the exit of devops with no timeout. A devops that hangs fails at the hang bound of pytest-timeout. docs/TESTING.md has the rule.
  • test_a_slow_subsystem_does_not_freeze_the_interface held the k8s fetch for 10 s. The hold ran out before the test looked. The hold now lasts until the test releases it, which a finally inside the app's context does on every path. The wait for the worker uses THREAD_HANDOFF_BOUND_SECONDS.
  • test_property_parse_whitelist_entry_reads_ipv6_hosts_and_ports_oracle ran under the 200 ms default deadline of Hypothesis. Every run now loads Hypothesis's built-in ci profile (--hypothesis-profile=ci in addopts), which GitHub Actions already loads by itself: no deadline and no too_slow health check. A new test checks that the sandbox properties run under it.
  • The [real-0.03] clock contract case measured from the first call. ratelimit opens its window when it builds it, so a stall between the two made the measured time short: the False of the issue. The case now measures from a seam reading taken just before the build. The real case asserts the lower bound that the contract needs, because a stall longer than the period lets the third call through with no wait. The fake case also asserts the one wait.

Evidence on the base c030c1b6: a scratch pytest plugin added each stall at the point that each time window covered, and each test failed as in the issues: a child that starts 35 s late ((False, 130, False, False)), a 5 ms stall after the window opens (the message of #2092), a 40 ms stall before the third call, a 60 ms parse (DeadlineExceeded: Test took 300.99ms), and an 11 s tab switch (('tab-docker', 1, False)). With the change, each of these runs passes.

Load and results: the host has 16 CPUs. stress-ng is not installed, so 16 python3 -c "while True: pass" processes ran pinned to CPUs 0-3 with taskset, and the test command ran pinned to the same 4 CPUs: 5 runnable processes for each CPU, as a load average of about 80 on 16 CPUs.

  • uv run devops ci test tests/test_ci.py tests/test_ui_reactive.py tests/test_sandbox_policy_properties.py tests/core/test_clock_contract.py tests/test_support_waits.py -k "signal_to_devops_ci_test or second_ctrl_c_just_after or another_thread_takes or slow_subsystem_does_not_freeze or ipv6_hosts_and_ports_oracle or ci_profile or third_call_wait_out_the_period or wait_while_a_process_runs" --repeat 50: 50 of 50 runs passed, 15 tests in each run, 750 test runs in 54 minutes. Each run took 18 s to 118 s. The host's load average was 39 at the end.
  • An earlier 50-run check of this change stopped at run 3 with the SIGTERM failure of the first bullet above, which led to the fix with loop.add_signal_handler.
  • On the base, 20 runs of the six end-to-end signal tests passed under a lighter pinned load (8 busy loops on 2 CPUs). The failures of the issues need the stalls of a full run under load, which the stall plugin above reproduced.

The issues ask for a second uv run devops ci test as the load. The host is shared by other agents, so the pinned busy loops replaced it.

Follow-up: the other waits in tests/ that keep a deadline of their own, such as the 5 s and 10 s waits of tests/test_ui_reactive.py, and the 30 s waits for a fresh devops in tests/test_cli_startup_imports.py and tests/test_github_session.py.

Follow-up

Item

Closes #2092

Also delivers #2069.

Change: openspec/changes/archive/2026-10-24-2092-tests-wait-for-events/

Fail-to-pass: uv run devops ci fail-to-pass --base origin/main on 7de2e332: 4 failed on base and 407 passed. The tests that fail on the base are test_a_second_ctrl_c_just_after_the_stop_sends_its_sigint_cannot_skip_the_sigkill, test_each_stop_signal_cancels_the_run_through_the_event_loop, test_the_properties_run_under_the_ci_profile_so_a_loaded_host_cannot_fail_them and test_the_full_gate_collects_the_test_module_ban. The other changed tests remove a time window from a test, so they also pass on the base on a quiet host; the stall plugin above shows each of them fail on the base.

Each test of #2092 and #2069 had a time window that a loaded host could
exceed. This change removes each window:

- devops ci test sets its stop handlers with loop.add_signal_handler, so
  a signal wakes the event loop wherever it lands. A signal.signal
  handler that came just before the loop's wait, or that the kernel
  handed to another thread, waited until the child exited.
- devops ci test takes over Ctrl-C's SIGINT for its run, as it takes
  over SIGTERM and SIGHUP. asyncio.run's own handler raised
  KeyboardInterrupt at a second Ctrl-C before the stop's try, and the
  stop then skipped its SIGKILL (#2069).
- The end-to-end signal tests wait for the start and the exit of a
  fresh devops with no bound of their own, through wait_while_running.
- The UI test holds its k8s fetch until the test releases it.
- Every run loads Hypothesis's built-in ci profile: no deadline.
- The real clock contract case measures from the opening of the window
  and asserts the lower bound that the contract needs.

Closes #2092
@dan-petty
dan-petty force-pushed the fix/2092-tests-wait-for-events branch from bd8b4ab to 2eac039 Compare October 24, 2026 19:23
@dan-petty
dan-petty marked this pull request as ready for review October 24, 2026 19:30
@dan-petty
dan-petty merged commit fc12d05 into main Oct 24, 2026
17 checks passed
@dan-petty
dan-petty deleted the fix/2092-tests-wait-for-events branch October 24, 2026 19:33
dan-petty pushed a commit that referenced this pull request Oct 24, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.4.0](v0.3.1...v0.4.0)
(2026-10-24)


### Features

* **ai:** AST support for YAML, Dockerfiles and Helm templates
([#2057](#2057))
([d4d6816](d4d6816)),
closes [#539](#539)
* **ai:** devops ai gateway status reports failover while a route is
failover:*, and failover --reset restores the default routes
([#2081](#2081))
([0325fd6](0325fd6))
* **ai:** llm gateway tuning cost from real traffic and no-load capacity
estimates ([#2050](#2050))
([1424eaa](1424eaa)),
closes [#477](#477)
* **ai:** measured per-deployment capability probes in gateway tune
([#2083](#2083))
([876df77](876df77)),
closes [#595](#595)
* **ai:** synthetic prompt adversaries for injection resistance
([#2032](#2032))
([68f8830](68f8830)),
closes [#417](#417)
* **ai:** the LLM stack dashboard shows latency per output token, and
the Ollama docs record the keep-alive and slot-lease behaviour
([#2091](#2091))
([1b25771](1b25771))
* **ci:** a pull request that changes the docs builds the pages site, so
a site break fails before the merge
([#2021](#2021))
([922989f](922989f))
* **cli:** outward-facing capability and upstream maturity survey
([#2044](#2044))
([e38fd02](e38fd02))
* **cli:** reasoning-token share in the spend ledger and
provider-reported stream usage
([#2076](#2076))
([f117292](f117292)),
closes [#591](#591)
* **cli:** thinking-stream sanitizer initial state, unopened-tag count
and thought cap
([#2074](#2074))
([5eed986](5eed986)),
closes [#590](#590)
* **config:** a settings save writes only the changed keys and keeps the
comments and unknown keys of config.yaml
([#2113](#2113))
([c9767df](c9767df)),
closes [#1999](#1999)
* **config:** devops config set stores a multi-line secret, such as a
pem private key, from a file or stdin, never from argv or a one-line
prompt ([#1962](#1962))
([a1a3fac](a1a3fac))
* **k8s:** the homelab runs gitea under argo cd as a read-write internal
forge, served in-cluster over http and to workstations at
https://git.<domain> through the cloudflare tunnel, with its admin
secret pushed from the keyring
([#2145](#2145))
([7c4f143](7c4f143)),
closes [#1081](#1081)
* **review:** a review runs its tools in the network-less sandbox by
default ([#2133](#2133))
([b94adcc](b94adcc))
* **review:** golangci-lint sarif adapter for go in scan and review
([#2085](#2085))
([bba1f5c](bba1f5c))
* **review:** group analysis is profiled as its own stage, and
analysis.json counts dispatched, replayed and failed jobs apart
([#2049](#2049))
([e2a5fee](e2a5fee))
* **review:** the SARIF export of a review carries the ToolRun of each
scan in the run of its tool
([#2103](#2103))
([76a1b64](76a1b64))
* **roadmap:** refine looks at a blocked item again when the code its
block cites changes on main
([#2082](#2082))
([70578b6](70578b6)),
closes [#2005](#2005)
* **scan:** prompt-injection smuggling detector and canary audit
([#2067](#2067))
([25c0d71](25c0d71))
* **sdlc:** an OpenSpec change folder is the record of every item, and
readiness checks its archive
([#2020](#2020))
([2638317](2638317))


### Bug Fixes

* **ai:** a hosted gateway call is priced at the deployment model that
the gateway names, not at the route name
([#2080](#2080))
([9068795](9068795))
* **ai:** analyze --enhanced and ai agents use the metadata task model
([#1068](#1068))
([#2155](#2155))
([1897550](1897550))
* **ai:** embedding requests reach the spend ledger and the AI usage
counters, priced against an embedding reference model
([#1970](#1970))
([4bb052c](4bb052c))
* **ai:** local savings use one reference price per request kind for
every process, and an unknown model or reference warns instead of
pricing at $0
([#2062](#2062))
([8a3b79e](8a3b79e))
* **ai:** run ids with a trailing newline fail validation
([#2120](#2120))
([3fe0bf6](3fe0bf6)),
closes [#917](#917)
* **ai:** spend ledger records every attempt the gateway failed
([#1019](#1019))
([#2140](#2140))
([b170358](b170358))
* **ai:** the default fallback model and the open webui default model
name models that the gateway serves
([#2126](#2126))
([c030c1b](c030c1b))
* **ai:** the gateway failover routes name models that a serving tier
holds ([#2052](#2052))
([84b5cb3](84b5cb3))
* **ai:** the spend series exists at $0, a gateway call counts as local
or hosted by the backend that served it, and the ledger exposition stops
reusing the OTLP names
([#2040](#2040))
([02540c0](02540c0))
* **argocd:** every application pins automated sync enabled in git, so
the devops application syncs again and a ui pause is reverted
([#2017](#2017))
([6030445](6030445))
* **argo:** derive workflow pod names and default container to main
([#2123](#2123))
([a5aaccc](a5aaccc)),
closes [#988](#988)
* **cache:** one circuit breaker with open, cooldown and half-open
states guards the valkey cache tier and the rag lookup pause
([#2109](#2109))
([9d61b39](9d61b39))
* **ci:** a commit runs no test suite in pre-commit; the pre-push gate
and CI run the tests
([#2090](#2090))
([08551af](08551af))
* **config:** devops config init names the file it writes, not the
default config path
([#2065](#2065))
([9772769](9772769))
* **config:** validate settings field types on load and assignment
([#2124](#2124))
([6e1bf4a](6e1bf4a))
* **deps:** fastmcp 4.1.2 and filelock 4.2.4 fix seven advisories, which
fail the audit check of every pull request
([#2013](#2013))
([188c107](188c107))
* **deps:** virtualenv 21.14.13 fixes GHSA-cx6f-vjhg-g3cc, which fails
the audit check of every pull request
([#2006](#2006))
([05211d5](05211d5))
* **docs:** the Pages build applies the site settings, which live in
docs/_config.yml only
([#2068](#2068))
([6c3f27b](6c3f27b)),
closes [#2001](#2001)
* **github:** devops gh api rate_limit --jq fails with Invalid
rate_limit payload format
([#1963](#1963))
([79626a8](79626a8))
* **k8s:** a changed gateway ConfigMap rolls the gateway deployment, so
deploy-stack never leaves a stale pod
([#2033](#2033))
([70e775f](70e775f))
* **k8s:** grafana moves to the grafana-community chart on a grafana 13
release that fixes cve-2026-76154, and provisioning prunes removed
datasources
([#2023](#2023))
([6d978ff](6d978ff))
* **k8s:** open webui, the ollama ingress, the gateway and the cli's
default ollama service point at tiers that have pods
([#1965](#1965))
([0bff85f](0bff85f))
* **k8s:** qdrant requires its api key, and open webui sends it
([#2014](#2014))
([8810767](8810767))
* **k8s:** start minikube with calico cni and align bootstrap help
([#2122](#2122))
([e7b9db7](e7b9db7)),
closes [#990](#990)
* **k8s:** stateful local-path volumes bind on nodes with disk headroom
instead of the control-plane node's 84%-full root disk
([#2150](#2150))
([3a00772](3a00772))
* **k8s:** the gateway sends embeddings to every serving ollama tier,
fastest first, so a rag batch never waits behind the slow tier
([#1991](#1991))
([060ccd6](060ccd6))
* **k8s:** the llm valkey cache requires a password and admits only its
clients, like valkey-runs
([#1981](#1981))
([a752a14](a752a14))
* **k8s:** the shared llm valkey has a memory bound below its container
limit and refuses writes at the bound
([#2097](#2097))
([760b197](760b197)),
closes [#711](#711)
* **k8s:** the unauthenticated in-cluster image registry leaves the
cluster, and gitea's container registry replaces it
([#2136](#2136))
([df8e2ee](df8e2ee))
* **monitoring:** grafana pins its four drilldown app plugins at the 3.x
releases that grafana 13 needs
([#2056](#2056))
([1c60233](1c60233))
* **monitoring:** grafana provisioning deletes the read-only jaeger
datasource that the grafana 12 install left behind
([#2037](#2037))
([787d760](787d760))
* **monitoring:** the alloy-metrics write-ahead log survives a pod
restart ([#2137](#2137))
([77a6430](77a6430)),
closes [#1967](#1967)
* **monitoring:** the Grafana rate panels hold two samples, the
dashboard queries match the live series, and the k8s-monitoring values
use the chart's documented settings
([#1958](#1958))
([4b06d31](4b06d31))
* **rag:** a slow embedding batch halves the batch size once for the
size it was sent at, and the size grows back only after a cooldown and
below a margin
([#2088](#2088))
([21a49cd](21a49cd))
* **rag:** a timed-out embedding batch closes the HTTP client that the
other parallel batches use, so intake reports a healthy gateway as down
([#2030](#2030))
([e4e0694](e4e0694))
* **review:** --pre-analysis-only stops after pre-analysis and runs no
evidence tool
([#2066](#2066))
([4b9fa24](4b9fa24))
* **review:** a one-file path review takes minutes in the payloads stage
because the lockfile coverage scan walks the whole checkout and mypy
starts with an empty cache
([#2048](#2048))
([ae4acaf](ae4acaf))
* **review:** a review records its prompt digest when it starts, and a
benchmark arm refuses runs whose prompts or code changed
([#2134](#2134))
([51d0f16](51d0f16)),
closes [#1050](#1050)
* **review:** classify C++ files and Helm chart templates in file
analysis ([#2055](#2055))
([3807f8f](3807f8f))
* **review:** review path --watch reviews only the files that changed
([#2135](#2135))
([f4d7066](f4d7066))
* **review:** the binary digest of a Python review tool names its
package, not its launcher script
([#2099](#2099))
([51a8e0a](51a8e0a))
* **roadmap:** a backlog full of ready items does not stop refine before
it looks at the backlog's other new items
([#2071](#2071))
([0a2bfe1](0a2bfe1))
* **roadmap:** intake calls a candidate a duplicate only when it asks
for the same change, not when it shares a theme
([#2018](#2018))
([64e74dd](64e74dd))
* **roadmap:** intake judges a split part a duplicate of the issue that
its --source names, so the part gets no issue
([#2038](#2038))
([0f254f0](0f254f0))
* **roadmap:** refine gives every item it cannot ready a next step
instead of skipping it as unchanged
([#2016](#2016))
([354d281](354d281))
* **security:** a gitleaks list scan keeps its start and end times in
sarif ([#2119](#2119))
([8ff16de](8ff16de))
* **security:** secret masking tells code from literals by the file's
syntax, not by receiver names
([#2104](#2104))
([a18a342](a18a342)),
closes [#889](#889)
* **security:** the agent scan tools run the scanner adapters and report
a missing or failed scan as such, not as clean
([#2112](#2112))
([02fee43](02fee43))
* **service:** roadmap-service exports its AI usage counters after every
lane batch, under one series identity that survives a pod restart
([#2042](#2042))
([a97a93d](a97a93d))
* **telemetry:** a command span sets no process.command_line, which the
conventions give to the full command line
([#2075](#2075))
([a9835d1](a9835d1))
* **telemetry:** a subprocess span holds the executable and the argument
count, and the arguments only when a person turns them on
([#2061](#2061))
([0983f6c](0983f6c))
* **telemetry:** a usage error records its error class, never the
argument text, and counts as a failed command
([#2063](#2063))
([53c9106](53c9106))
* **telemetry:** the profile span holds the command path and the
argument count, never the argument values
([#2077](#2077))
([0a2d42e](0a2d42e))
* **tests:** a test that writes a real config.yaml fails at the write
and names itself, and every config write keeps a backup and a change
record ([#2019](#2019))
([ce0c21f](ce0c21f))
* **tests:** four tests that wait for a time window fail under host load
([#2139](#2139))
([fc12d05](fc12d05))
* **tests:** the synthetic tiktoken encoding of the prepared-cache test
stays in tiktoken's registry, so later token counts on that worker are
per byte ([#2015](#2015))
([bd5f648](bd5f648))
* **tests:** twelve tests still assert elapsed wall-clock time, and no
check enforces the rule in docs/TESTING.md
([#1973](#1973))
([dd6052c](dd6052c))
* **valkey:** valkey.url is one validated url, its path names the
database, and the separate host, port and db settings go
([#2087](#2087))
([12fa20c](12fa20c)),
closes [#2060](#2060)
* **valkey:** valkey.url keeps its scheme, so a valkeys url dials tls
with host name checks
([#2064](#2064))
([5f36c4c](5f36c4c))


### Performance Improvements

* **review:** pre-analysis of a 17-file pull request takes four minutes
because it refreshes metadata for 2,339 files
([#1980](#1980))
([45f1669](45f1669))


### Code Refactoring

* **cli:** one process runner owns execution, process groups and dry-run
([#2117](#2117))
([0a9725d](0a9725d))
* **config:** remove config barrel and unused config names, and stop
package init re-exports
([#2102](#2102))
([ae3c0c6](ae3c0c6)),
closes [#776](#776)
* **github:** the board's priority field is the only priority source,
and stray type labels merge into type/bug
([#2105](#2105))
([f730cdb](f730cdb)),
closes [#880](#880)
* **review:** the review orchestrator and the scanners take the reviewed
workspace from their caller, and no review or scanner module reads
Path.cwd()
([#2128](#2128))
([11ddf0f](11ddf0f))
* **review:** the synthetic corpus drops contradict-documented-default,
which no tool can detect
([#2053](#2053))
([3c8f627](3c8f627))
* **roadmap:** intake files every new candidate, with no agent filing
quota ([#1964](#1964))
([4ed262a](4ed262a))
* **sdlc:** the task files that merged after the openspec switch are
deleted, and the decommission check is strict
([#2051](#2051))
([5787ea7](5787ea7))
* **security:** mypy and the review canary start their tools through a
ToolExecutor
([#2114](#2114))
([34bae84](34bae84))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(tests): four tests that wait for a time window fail under host load

1 participant