Skip to content

ci(tests): start every resource-monitor sample on its own line (#1888) - #1890

Merged
JarryShaw merged 1 commit into
mainfrom
ci/1888-monitor-mid-line
Oct 17, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
ci/1888-monitor-mid-line

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

Please follow the guide below

What is the purpose of your pull request?

Tick the commit type your subject line carries.

  • fix — corrects a defect
  • feat — adds a feature
  • perf — changes performance, not behaviour
  • refactor — changes neither behaviour nor performance
  • test — tests only
  • docs — documentation only
  • ci — workflows or build tooling
  • release — bumps the version or rolls up a distribution
  • chore — anything else

Root cause. The resource-monitor sampler in .github/workflows/experimental.yml wrote each sample with printf '\n%s\n' "$(sample …)". bash line-buffers builtin output, so that printf goes out as several writes. The tests step then interleaves those writes with pytest's progress through tail -F, so a later write of one sample could land after pytest's unfinished line. That is the uuu.u[monitor] … ps row seen in #1881's job 117297298108.

The worker counted the writes with a SOCK_SEQPACKET socket: a 3-line sample was 3 writes under bash 4.2 and 5.3.

Fix. The step builds the sample first, then writes it with cat <<< $'\n'"$lines", which emits it as one write that opens on a newline. The log format is unchanged, so the stop step's count still reads it.

Test. The new test_each_sample_is_one_write_so_no_output_lands_inside_it runs the real start step against a SOCK_SEQPACKET socket and puts pytest-style output between every two writes, so it does not depend on timing. It fails with the old step and passes now. The test file passed 45 of 45 looped runs.

Unverified: CI's coreutils 9 tail relaying a single write in one piece; the host here has coreutils 8.22.

Closes #1888

- experimental.yml `Start the resource monitor`: bash line-buffers the
  printf builtin's output, so each sample reached the log in several writes;
  `tail -F` in `Run unit tests` could relay them apart and pytest's
  unfinished progress line land between them. The sample is now written
  with `cat` of a here-string, one write that opens on a newline.
- test_resource_monitor_1740.py: run the sampler with a SOCK_SEQPACKET socket
  as its log, which keeps every write apart, put pytest's unfinished line
  between each two, and require every sample to start its own line, in one
  write no larger than PIPE_BUF. `sh()` takes `pass_fds` for the socket.

Closes #1888
@JarryShaw JarryShaw added ci Pull requests that change CI or workflow configuration (ci: subject prefix) review: pending No verdict for the current head - never reviewed, or the head moved since the last one review: running A cross-review is in flight against the current head - no verdict yet and removed review: pending No verdict for the current head - never reviewed, or the head moved since the last one labels Oct 17, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Verdict: GOOD TO GO at 75209fefb. A Sonnet cross-review could not break the fix or the test.

  • The mechanism is real. The base step wrote a realistic 1.6 KB sample in 10 separate writes, and the same happens on a plain file. The PR's step writes it once: 1653 bytes, opening and ending on a newline. In an end-to-end tail -F run with a racing writer, base produced 362 lines with a [monitor] mid-line and the PR produced 0.
  • No sample comes near PIPE_BUF. ps is capped at head -6 | cut -c1-300, so the largest plausible sample is about 2.7 KB against the 4096-byte PIPE_BUF. The test's PIPE_BUF assertion guards that headroom.
  • The test is real. The new test failed 3 of 3 times against the old step; the whole file passed 10 of 10 runs on the PR head.
  • Nothing else changed. The log format is identical, the stop step still counts samples, and the containment summary still parses. experimental.yml's permissions are unchanged.

Unverified: GitHub-hosted runners' bash and coreutils builds. The reviewer tested bash 5.3 here.

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 17, 2026
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Oct 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage: 90.06% (unit tier, Python 3.15, 75209fefb, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 2 20 2 96.77%
pcapkit/const 19595 881 2618 867 92.11%
pcapkit/corekit 2462 69 780 35 96.55%
pcapkit/dumpkit 276 3 100 3 98.40%
pcapkit/foundation 2914 164 1016 34 93.59%
pcapkit/interface 138 7 52 5 93.68%
pcapkit/protocols 17406 224 4580 189 98.10%
pcapkit/toolkit 872 177 298 8 77.18%
pcapkit/utilities 512 2 158 4 99.10%
pcapkit/vendor 4429 2341 1018 156 43.62%

Per-file detail: the coverage-html artifact of this run.

@JarryShaw
JarryShaw merged commit aa05d96 into main Oct 17, 2026
62 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 17, 2026
@JarryShaw
JarryShaw deleted the ci/1888-monitor-mid-line branch October 17, 2026 13:27
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Pull requests that change CI or workflow configuration (ci: subject prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

ci(tests): the resource-monitor test can see a sample written mid-line (flaky)

1 participant