Repository navigation
Conversation
The tests started servers on the fixed ports 8080, 8081 and 12345, so the suite could not run on a host where another service holds one of them, e.g. 8080. Test::Nginx's $TEST_NGINX_RAND_PORT_N variables give each test block free ports instead. Test::Nginx doesn't expand these variables in --- error_log, so the Host header tests of t/14-host-header.t now have the server (or the proxy) echo the Host header it received and compare it in
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.
Some tests start servers on fixed ports:
listen *:8080and*:8081int/14-host-header.tandt/16-http-proxy.t, and--- tcp_listen: 12345int/01-basic.t,t/07-keepalive.t,t/15-instance-reuse.tandt/16-http-proxy.t. On a host where another service holds one of these ports, nginx can't start and the suite stops:That host was a server with CrowdSec, whose API listens on 8080 by default.
This PR uses Test::Nginx's
$TEST_NGINX_RAND_PORT_1and$TEST_NGINX_RAND_PORT_2instead. Test::Nginx expands them in the configuration,--- tcp_listenand--- response_body, giving each test block free ports. The12345int/03-requestbody.tis a request body, not a port, so it stays.Test::Nginx 0.32 doesn't expand these variables in
--- error_log. So TESTs 3, 4 and 6 oft/14-host-header.t, which checked the Host header in the debug log, now have the server (or, in TEST 6, the proxy) echo the Host header it received. They compare it in--- response_body, ast/16-http-proxy.talready does withngx.req.raw_header(). This checks the header as it arrived rather than as it was logged. They still fail if the port goes missing from the Host header: withlib/resty/http.luachanged to send onlyself.host, all three reportgot: '127.0.0.1',expected: '127.0.0.1:<port>'. (openresty/test-nginx#191 proposes the expansion in--- error_log, but this PR doesn't need it.)Tested with nginx 1.30.7 and lua-nginx-module 0.10.32rc8, with another process listening on 8080:
prove -r t), Test::Nginx 0.32: all 21 files and 434 tests pass. Without this change, the run stops att/14-host-header.t.TEST_NGINX_RANDOMIZE=1 prove -j32 -r t), five times each with Test::Nginx 0.32 and with its current master: all pass.-j16each), eight times with Test::Nginx's current master: all pass. With 0.32, a random port occasionally collided with the other copy's: random ports in 0.32 aren't coordinated across processes. That affects the server port ofTEST_NGINX_RANDOMIZEjust the same, and Test::Nginx's master has fixed it.🤖 Generated with Claude Code