Skip to content

test: make the example tests pass on macOS - #332

Closed
u5surf wants to merge 1 commit into
nginx:mainfrom
u5surf:test/macos-example-tests
Closed

u5surf wants to merge 1 commit into
nginx:mainfrom
u5surf:test/macos-example-tests

Conversation

@u5surf

@u5surf u5surf commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Proposed changes

Two unrelated failures in examples/t, both only visible once the functional
suite runs on a Mac, which no CI job does yet. #320 adds such a job and both
turned up there.

awssig.t writes a config using a module that is no longer built on
Darwin after #319, so nginx refuses to start. Skip the file there, matching the
configure-time condition.

shared_dict.t fails on its check() calls, subtests 3, 4 and 6. check()
records the worker pid that answered and retries back to back until a different
one answers, which is what proves the value came from shared memory rather than
worker-local state. Consecutive connections keep landing on the worker that is
already awake, so the loop exhausts without ever seeing a second pid. With
plain nginx and two workers:

worker_processes 2;
events { }
http {
    server {
        listen 127.0.0.1:18099;
        location / { return 200 "$pid\n"; }
    }
}
$ for i in $(seq 1 40); do curl -sS http://127.0.0.1:18099/; done | sort | uniq -c
  2 52118
 38 52120

Pausing between retries lets the worker that just answered go back to sleep, so
the kernel has a reason to wake the other one.

Testing

macOS 14.6, Apple Silicon, nginx 1.30.4, running shared_dict.t in a loop:

failures
before 50 / 50
after 0 / 50

The loop returns as soon as it sees a second pid, so on a platform where the
first retry already lands on the other worker the cost is one pause per
check(). The whole of examples/t takes about 2s here either way.

accept_mutex on and listen ... reuseport were both tried first; on this
platform each made the split worse, 40 / 0.

Checklist

  • I have written my commit messages in the Conventional Commits format.
  • I have read the CONTRIBUTING doc
  • I have added tests (when possible) that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto main
  • I will ensure my PR is targeting the main branch and pulling from my branch from my own fork

Two unrelated failures, both only visible once the functional suite runs
on a Mac, which no CI job does yet.

awssig.t started a config for a module that is no longer built there.
Skip it on Darwin, matching the configure-time condition added in nginx#319.

shared_dict.t's check() waits for a second worker pid to prove the value
came from shared memory, retrying back to back. Consecutive connections
keep landing on the worker that is already awake: 38 of 40 in a plain
nginx with two workers, so the loop exhausts and the test fails almost
every run. Pausing between retries spreads them, measured 0 failures in
50 runs against 50 in 50 before. The loop still returns as soon as it
sees a second pid, so the cost is one pause per check where the first
retry already lands elsewhere.

Signed-off-by: Y.Horie <u5.horie@gmail.com>
@u5surf

u5surf commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Folded into #320, which is where both failures surfaced.

@u5surf u5surf closed this Sep 17, 2026
@u5surf
u5surf deleted the test/macos-example-tests branch September 17, 2026 11:49
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.

1 participant