openresty / test-nginx

Data-driven test scaffold for Nginx C module and OpenResty Lua library development
http://search.cpan.org/dist/Test-Nginx
438 stars 105 forks source link

bugfix: log correct server address when server_addr_for_client section is used #105

Closed patthiel closed 3 years ago

patthiel commented 3 years ago

This had me scratching my head for a while, I had been writing a test where I was using the server_addr_for_client section with a non 127.0.0.1 value, and I included the --curl in the test and set log_level('debug');.

The test was failing, and the curl command printed was not reflecting my server_addr_for_client value, which led me to believe it was making the request to the wrong server. After a fair bit of debugging, i discovered it was making the request to the correct server address, but the logs generated by test-nginx were wrong.

This patch fixes the logging in several places to use server_addr, which may be overridden by the server_addr_for_client section, but otherwise will default to ServerAddr

Please let me know if anything else is required for this contribution. I'd be happy if other folks didn't spend time debugging this like I did 🙃

agentzh commented 3 years ago

Merged. Thanks!