openresty / test-nginx

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

Is it possible to load a complete nginx config? #85

Closed steebchen closed 5 years ago

steebchen commented 5 years ago

Is it possible to load a complete nginx config string with top level directives and http, server and location blocks in my test? It seems you can only edit top-level options with main_config but not the http block, and I can't find any option to provide a full nginx config. I have a slightly different use case for this module where I have a full nginx config ready and I want to test my app with that config, so it would be really helpful.

My current solution is to disable the nginx manager and run it myself, though it would be cool if there was another way:

export TEST_NGINX_CLIENT_PORT=8123
export TEST_NGINX_NO_NGINX_MANAGER=1
prove

If it's neither possible nor planned, feel free to close this issue without comment.

agentzh commented 5 years ago

No, the test scaffold does have many assumptions about the nginx.conf to work properly, not to mention all those advanced test modes which require server side collobrations in nginx.conf.

agentzh commented 5 years ago

Allowing user-supplied complete nginx.conf is too hard to get exactly right so IMHO it's not worth it at all.

steebchen commented 5 years ago

Okay, thanks, I just wanted to check.

agentzh commented 5 years ago

Just for the record, we're thinking about creating another Test::ORApp test scaffold for testing complete openresty web applications so that the targets can use their own complete nginx.conf files and everything. We used to create something similar in house for testing proprietary openresty apps, just need to make a more generalized solution for the public community.

steebchen commented 5 years ago

Nice, glad to hear that! Thanks for posting. If your in-house solution becomes open source or if any other app does something similar, it would be great if you could post it in this thread.

mhamann commented 4 years ago

@steebchen how did you end up solving your testing needs? I thought Test::Nginx would help me, but seems like it applies mainly to modules rather than an "app" build using OpenResty.