about summary refs log tree commit homepage
path: root/test
DateCommit message (Collapse)
2009-04-01test_rails: 4x speedup
Loading Rails takes a very long time, so consolidate most of the tests into one big test that allows us to avoid loading Rails. It makes the test less like unit tests, but they could still be split up into private functions if one wants to run them individually.
2009-04-01Add more tests for Rails
Additional tests for Rails have been added * cookies and sessions * POST requests * POST requests with multipart uploads * 404 handling * static file serving * cached static file serving (resources with ";" caching in some old 1.2.x version not yet tested)
2009-03-31test: factor out exec helpers into common code for Rails tests
2009-03-31Rails stack tests for unicorn_rails
Very preliminary for now. Basically just sets up a basic controller and response. Requires git to clone the official Rails repository.
2009-03-31Better canonicalization of listener paths + tests
* Expand addresses like "1:8080" to "127.0.0.1:8080" beforehand so sock_name() in SocketHelper will always return consistent results. * Add support for "unix:/path/to/foo" paths for easier synchronization with nginx config files.
2009-03-29test_exec: fix another race condition
2009-03-29test_exec: fix response bodies
They were non-conformant for the longest time
2009-03-29test_exec: fix race conditions
We need to ensure the QUIT signal to the old processes are processed when fixing the config. Additionally, the log rotation checker was not reliable because the master log emitted a similar message to the workers and we were not distinguishing between them. Check for all 5 logs (1 master + 4 workers) to be rotated.
2009-03-29http11: use :http_body instead of "HTTP_BODY"
"HTTP_BODY" could conflict with a "Body:" HTTP header if there ever is one. Also, try to hide this body from the Rack environment before @app is called since it is only used by Unicorn internally.
2009-03-29configurator: favor "listen" directive over "listeners"
We still need to support "listeners" for easy use of command-line options, but folks using the config file should use "listen" as it is more flexible.
2009-03-29configurator: per-listener backlog, {rcv,snd}buf config
Instead of having global options for all listeners, make all socket options per-listener. This allows reverse-proxies to pick different listeners to get different options on different sockets. Given a cluster of machines (10.0.0.1, 10.0.0.2, 10.0.0.3) running Unicorn with the following config: ------------------ 8< ---------------- listen "/tmp/local.sock", :backlog => 1 listen "*:8080" # use the backlog=1024 default ------------------ 8< ---------------- It is possible to configure a reverse proxy to try to use "/tmp/local.sock" first and then fall back to using the TCP listener on port 8080 in a failover configuration. Thus the nginx upstream configuration on 10.0.0.1 to compliment this would be: ------------------ 8< ---------------- upstream unicorn_cluster { # reject connections ASAP if we are overloaded server unix:/tmp/local.sock; # fall back to other machines in the cluster via "backup" # listeners which have a large backlog queue. server 10.0.0.2:8080 backup; server 10.0.0.3:8080 backup; } ------------------ 8< ---------------- This removes the global "backlog" config option which was inflexible with multiple machines in a cluster and exposes the ability to change SO_SNDBUF/SO_RCVBUF via setsockopt(2) for the first time.
2009-03-29test_response: ensure response body is closed
This is in the Rack specification and a good idea. Remind ourselves to prevent file descriptor or other resource leaks in case the body is not an Array.
2009-03-29test_response: ensure closed socket after write
We always close the socket immediately after a successful write for two reasons: 1) To prevent error responses from being rewritten. If we throw an exception in our request/app/response chain, we'll attempt to write an HTTP 400/500 response out if the socket is open. No way to write to an open socket. 2) To uncork the socket if TCP_CORK is enabled (Linux) ASAP. This should be a tick faster than waiting to go back up the stack and close it there.
2009-03-27Always try to send a valid HTTP response back
This reworks error handling throughout the entire stack to be more Ruby-ish. Exceptions are raised instead of forcing the us to check return values. If a client is sending us a bad request, we send a 400. If unicorn or app breaks in an unexpected way, we'll send a 500. Both of these last-resort error responses are sent using IO#write_nonblock to avoid tying Unicorn up longer than necessary and all exceptions raised are ignored. Sending a valid HTTP response back should reduce the chance of us from being marked as down or broken by a load balancer. Previously, some load balancers would mark us as down if we close a socket without sending back a valid response; so make a best effort to send one. If for some reason we cannot write a valid response, we're still susceptible to being marked as down. A successful HttpResponse.write() call will now close the socket immediately (instead of doing it higher up the stack). This ensures the errors will never get written to the socket on a successful response.
2009-03-27test_server: quieter tests
2009-03-27style: symbols instead of strings for signal names
They're easier for me to type and read and just barely faster when doing comparisons on.
2009-03-27Deferred log rotation in workers
Instead of rotating logs immediately when SIGUSR1 is caught, defer it until the current client is processing is complete. This allows multi-line log messages generated by apps to not be broken up if SIGUSR1 is received while the app is running. If we're sleeping inside IO.select, we close a pipe in the exceptfds set to cause EBADF to be raised. This also adds a small reliability improvement to test_exec so we wait until signals are ready before sending USR1 to rotate logs.
2009-03-25Merge commit 'v0.2.3'
* commit 'v0.2.3': unicorn 0.2.3 Ensure Tempfiles are unlinked after every request Don't bother unlinking UNIX sockets Conflicts: lib/unicorn/socket.rb
2009-03-25Ensure Tempfiles are unlinked after every request
Otherwise we bloat TMPDIR and run the host out of space, oops!
2009-03-25Socket: add {snd,rcv}buf opts to bind_listen
bind_listen takes a hash as its second parameter now, allowing the addition of :sndbuf and :rcvbuf options to specify the size of the buffers in bytes. These correspond to the SO_SNDBUF and SO_RCVBUF options via setsockopt(2) respectively. This also adds support for per-listener backlogs to be used. However, this is only an internal API change and the changes have not yet been exposed to the user via Unicorn::Configurator, yet. Also add a bunch of SocketHelper tests
2009-03-24simplify the HttpParser interface
This cuts the HttpParser interface down to #execute and #reset method. HttpParser#execute will return true if it completes and false if it is not. http->nread state is kept internally so we don't have to keep track of it in Ruby; removing one parameter from #execute. HttpParser#reset is unchanged. All errors are handled through exceptions anyways, so the HttpParser#error? method stopped being useful. Also added some more unit tests to the HttpParser since I know some folks are (rightfully) uncomfortable with changing stable C code. We now have tests for incremental parsing. In summary, we have: * more test cases * less C code * simpler interfaces * small performance improvement => win \o/
2009-03-22Merge commit 'origin/benchmark' into release
* commit 'origin/benchmark': benchmark: header values must be strings All new benchmarks, old ones removed
2009-03-22benchmark: header values must be strings
Newer versions of Unicorn "enforce" this by splitting on "\n" to handle Rack-style multi-value headers.
2009-03-22All new benchmarks, old ones removed
dd.ru is a rackup file is intended as a dd(1)-like test for I/O performance. There are also individual request, response, and big_request benchmarks for micro benchmarking some parts of Unicorn. The rest of the benchmarks are gone: I am not interested in performance comparisons (and pissing matches) with other web servers (or their fanboys/girls). I will _NEVER_ publically publish benchmarks comparing Unicorn against other web servers. I will only compare Unicorn against other versions of Unicorn, possibly on different platforms. Neutral third-parties are invited to publish their own benchmarks (along with detailed procedures, version numbers and other details) comparing Unicorn to other servers. Signed-off-by: Eric Wong <normalperson@yhbt.net>
2009-03-21Handle Rack multivalue headers correctly
Rack uses a single newline character to represent multi-value headers. Thus { 'Set-Cookie' => "foo=bar\nbar=foo" } will get you: Set-Cookie: foo=bar Set-Cookie: bar=foo While RFC2616 says you can combine headers as: Set-Cookie: foo=bar,bar=foo There are probably HTTP clients out there that don't handle things correctly so don't bother... Additionally, don't bother doing duplicate suppression anymore. Just assume Rack or a higher layer knows what it's doing regarding duplicates and we'll get a Hash most of the time anyways.
2009-03-21Rotate master logs before workers.
The master _may_ run with different user/group/umask than the workers. Since the logs were always created by the master process, the master should rotate them first to ensure correct ownership and permissions. This way if the workers fail log rotation and die, they'll be automatically respawned with the new logs in place.
2009-03-21HttpRequest test so our requests pass Rack::Lint
This test requires Rack to be loaded and will not run without it. This also seems broken on 1.9 still with Rack 0.9.1...
2009-03-21unicorn/http11: remove GATEWAY_INTERFACE
It's a CGI-ism and is not in the Rack spec, so don't bother.
2009-03-18Add signal queueing for test reliability
Although I didn't like the idea initially, signal queueing allows test_exec to run more reliably and the limited signal queue size will prevent scary queued signal behavior. Also, always wakeup the master immediately when CHLD is trapped to reduce the performance impact of SIGHUP-based config reloading. Combined with an extra check in test_exec, this should make test_exec run much more reliably than before.
2009-03-18tests: do not trust (our correct use of) 1.9 encodings
Despite reading numerous articles and inspecting the 1.9.1-p0 C source, I will never trust that we're always handling encoding-aware IO objects correctly. Thus this new test uses UNIX shell utilities that should always operate on files/sockets on a byte-level. Signed-off-by: Eric Wong <normalperson@yhbt.net>
2009-03-09test_exec: increase backlog to 128
Hopefully this increases test reliability
2009-03-09Revert "Remove -P/--pid switch from CLI"
This reverts commit 4414d9bf34f162a604d2aacc765ab1ca2fc90404.
2009-03-09Revert "exec: disable embedded switch parsing in config.ru"
This reverts commit e66ab79b8b5bc5311c750bf03868a7b2574f4ea1. Conflicts: bin/unicorn
2009-03-03test_exec: remove extraneous fcntl require
There used to be a log rotation lambda in there, but that got moved to lib/unicorn/util.rb for convenience.
2009-03-03Add configurator test
2009-03-03Make USR1 rotate log files by default
I consider it a sensible default for long-running servers. Additionally, there is no easy way to make USR1 rotate the master process log without this.
2009-03-03Add Unicorn::Util for a reopen_logs method
Since I use it myself and also in the tests, we might as well implement it correctly as a class method so people can run it in their trap('USR2') hooks.
2009-03-03test_exec: avoid mis-teardown just in case...
Probably not a real bug, but test_exec has been experiencing mysterious failures....
2009-03-03test_exec: avoid hiding error when binary can't be found
Oops, that was making debugging tests quite difficult.
2009-03-03Remove -P/--pid switch from CLI
It's confusing with the lowercase "-p" option which is more common for developers to use. PID files are only needed for production deployments, and those should be using config files anyways.
2009-03-03test_exec: higher timeouts for log reading
Yeah, some of my test machines are ridiculously slow...
2009-03-03test_exec: be more liberal regarding terminal output
23x79 looks better in a terminal, but the Ruby 1.9 OptionParser output adds a little more whitespace requiring 24x80 output, which is still fine...
2009-03-03test/exec: avoid letting child processes unlink tempfiles
Hopefully this fixes some random test failures I've been experiencing...
2009-03-03test for "unicorn --help" output
Ensure the output fits in a standard ANSI terminal so it's easy to read for all users regardless of what interface they're working from.
2009-03-03exec: disable embedded switch parsing in config.ru
Since not all rackup command-line options can be supported by Unicorn, disable this gross hack to avoid potentially unpredictable or undefined behavior. config.ru will not be able to specify the config file for unicorn-specific options; but the unicorn-specific config files themselves will be allowed to override the default config.ru location.
2009-03-03test_exec: simplify check for unicorn binary
2009-03-03test/aggregate: remove Ruby version from output
This was accidentally left in there during 1.9 compatibility testing.
2009-02-21Fix+test reexec error handling on bad inputs
People can screw config files up, it's not my fault if they do, but they do... Don't let the original process get wedged if we can help it..
2009-02-21test_exec: fix for temporary files not being cleaned
Apparently the at_exit handlers were not triggering for an execed process.
2009-02-21GNUMakefile: revamp for parallel 1.8/1.9 runs
Add a install-test for doing a mock install with private http11 and bin/unicorn and appropriate PATH/RUBYLIB env. Also add a normal install target so we can just type "make install" and just be done with a regular installation (and it'll revert files if using git). I use the following local.mk to augment my GNUmakefile. It allows me to run "make -j full-test" and run both 1.8 and 1.9 tests in parallel. --------------------------- 8< ------------------------- DLEXT := so rack_ver := 0.9.1 ifeq ($(r19),) ruby := $(HOME)/bin/ruby RUBYLIB := $(HOME)/lib/ruby/gems/1.8/gems/rack-$(rack_ver)/lib else export PATH := $(HOME)/ruby-1.9/bin:$(PATH) ruby := $(HOME)/ruby-1.9/bin/ruby RUBYLIB := $(HOME)/ruby-1.9/lib/ruby/gems/1.9.1/gems/rack-$(rack_ver)/lib endif SHELL := /bin/bash -e -o pipefail full-test: test-18 test-19 test-18: $(MAKE) test 2>&1 | sed -u -e 's!^!1.8 !' test-19: $(MAKE) test r19=1 2>&1 | sed -u -e 's!^!1.9 !' --------------------------- 8< -------------------------