Start the chef-zero server on demand - #54
Open
tas50 wants to merge 1 commit into
Open
Conversation
Requiring chefspec pulls in the ServerRunner, which registers a before(:suite) hook that starts a chef-zero server for every suite, even suites that only ever use the SoloRunner. That reserves one port from the configured range for the whole run, so no more than 11 suites can run concurrently with the default range before they start failing to find a free port. It also runs a data reset after every single example. Start the server the first time something actually needs it, from the cookbook upload, the data loader and the server accessor, and skip the per example reset while it is not running. ServerRunner behavior is unchanged. Fixes chefspec#1017 Signed-off-by: Tim Smith <tsmith84@proton.me>
tas50
force-pushed
the
fix/lazy-chef-zero
branch
from
August 22, 2026 00:09
f4b639d to
a3d2d11
Compare
Author
|
CI on this PR is red for an unrelated reason: main's bundle cannot be installed on Linux, which breaks every job before any test runs. That is fixed separately in #56, which is green across Ruby 3.1 to 3.4. This PR should go green once #56 lands and this branch is rebased. Locally, against a working bundle, this branch passes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes chefspec#1017
Problem
Requiring chefspec pulls in
ServerRunner, which pulls inZeroServer, which registers:A chef-zero server therefore starts for every suite, including suites that only ever use the
SoloRunner. That reserves one port fromserver_runner_port(default8889..8899) for the whole run, so no more than 11 suites can run concurrently before they fail to find a free port. It also runs a data reset after every single example.Measured on a suite that only uses
platformandSoloRunner, before the change:Fix
Start the server the first time something actually needs it, from
upload_cookbooks!,load_dataand theserveraccessor, and skip the per example reset while it is not running.This is the third option the reporter suggested. It is not a breaking change:
ServerRunnerbehavior is unchanged, and code that starts the server explicitly, asexamples/server/spec/exotic_port_spec.rbdoes, still works.Testing
Adds a
no_serveracceptance example asserting no chef-zero server is running for aSoloRunneronly suite.2 examples, 0 failures, and no ports bound2 examples, 1 failureserveracceptance example (allServerRunner):17 examples, 0 failures197 examples, 0 failures