about summary refs log tree commit homepage
path: root/test/test_server.rb
DateCommit message (Collapse)
2016-06-07cleanup graceful shutdown handling
Using a 10ms tick was too little, use 100ms instead to avoid burning CPU. Ideally, we would not tick at all during shutdown (we're normally tickless); but the common case could be slightly more expensive; and shutdowns are rare (I hope). Then, change our process title to indicate we're shutting down, and finally, cut down on repeated log spew during shutdown and only log dropping changes. This mean we could potentially take 90ms longer to notice when we can do a graceful shutdown, but oh well... While we're at it, add a test to ensure graceful shutdowns work as intended with multiple processes.
2016-02-29test/*: fix mktmpdir usage for 1.9.3
We should not infinite loop, oops :x Also, ensure 'yahns' is in the directory in case tests are SIGKILL-ed and directories are left over.
2016-02-14doc: trim down documentation slightly
The "threads:" option for the "listen" directive is worthless. Having a dedicated thread per-process is already more than enough (and ideal) for a multi-process setup. Multiple acceptor threads is still wrong for a single-process setup (even if we did not have a GVL) as it still incurs contention with the worker pool within the kernel. So remove the documentation regarding "listen ... threads: ", for now; at least until somebody can prove it's useful and not taking up space. Additionally, "atfork_parent" may be useful for restarting background threads/connections if somebody wants to run background jobs in the master process, so stop saying it's completely useless.
2016-01-02copyright updates for 2016
Using the 'update-copyright' script from gnulib[1]: git ls-files | UPDATE_COPYRIGHT_HOLDER='all contributors' \ UPDATE_COPYRIGHT_USE_INTERVALS=2 \ xargs /path/to/gnulib/build-aux/update-copyright We're also switching to 'GPL-3.0+' as recommended by SPDX to be consistent with our gemspec and other metadata (as opposed to the longer but equivalent "GPLv3 or later"). [1] git://git.savannah.gnu.org/gnulib.git
2016-01-02enable frozen_string_literal for Ruby 2.3+
There are likely yet-to-be-discovered bugs in here. Also, keeping explicit #freeze calls for 2.2 users, since most users have not migrated to 2.3, yet.
2015-12-13test_server: fix race condition in hooks test
We need to ensure the master process is done writing to logs when we check them. Do that by sending a SIGQUIT to the master to shut it down, as the master process will defer the SIGQUIT until after the test log is written to the kernel.
2015-10-13copyright updates
Future updates may use the update-copyright script in gnulib: git ls-files | UPDATE_COPYRIGHT_HOLDER='all contributors' \ UPDATE_COPYRIGHT_USE_INTERVALS=2 \ xargs /path/to/gnulib/build-aux/update-copyright
2015-07-03apply TCP socket options on inherited sockets
TCP socket options are now set when inheriting existing sockets from a parent process. I'm fairly certain all the TCP setsockopt knobs we use are idempotent and harmless to change. If anything, the only directive I'd be uncomfortable changing is shortening the listen(2) (aka :backlog) size, but we've always changed that anyways since it also applies to UNIX sockets. Note: removing a configuration knob in a yahns config file can not reset the value to the OS-provided default setting. Inherited sockets must use a new setting to override existing ones. (or the socket needs to be closed and re-created in the process launcher before yahns inherits it). Based on unicorn commit 1db9a8243d42cc86d5ca4901bceb305061d0d212 Noticed-by: Christos Trochalakis <yatiohi@ideopolis.gr> <20150626114129.GA25883@luke.ws.skroutz.gr>
2015-03-13test/test_server: fix leftover process from inherit test
Oops, this test bug was introduced in: commit e413325737f23c5ec27a02246f95077bc1fb038d ("acceptor: close inherited-but-unneeded sockets")
2015-03-09acceptor: close inherited-but-unneeded sockets
When inheriting sockets from the parent via YAHNS_FD, we must close sockets ASAP if they are unconfigured in the child. This bug exists in yahns (and not unicorn) because of the trickier shutdown routine we do for blocking accept system calls to work reliably with the threading support in mainline Ruby 2.x. This bug would not exist in a purely C server using blocking accept, either.
2014-07-16test_server: avoid multiple workers for dead parent check
This test is less reliable when there are multiple workers as the second worker may not be ready to detect a dead parent. This is still a possible race if the master dies very quicklly before a worker is fully setup.
2014-03-22tests: avoid autoclose when inheriting
GC will close redundantly and lead to EBADF when finalizing. This was probably harmless as the original IO objects remained marked; but do not count on it. Seeing EBADF in a MT process is a very bad sign (inadvertant information disclosure is only one race condition away). Fortunately, this bug was limited to our test suite :)
2014-02-08test_server: check_client_connection uses Unix sockets
TCP socket timing is too varied over different OSes, Unix sockets seem to test more reliably than TCP ones on my Debian GNU/kFreeBSD system.
2013-11-10test_server: remove unneccessary IO#wait call
This was failing under Rubinius and not necessary after all ref: https://github.com/rubysl/rubysl-io-wait/issues/2
2013-11-05http_response: fix app-controlled close + test
We allow applications to drop persistent connections, this does not seem forbidden by Rack and gives the app author some control over the lifetime of a connection.
2013-10-31allow atfork_* hooks inside app blocks for ease-of-management
This should allow users to more-easily enable/disable apps and their dependent atfork_* hooks.
2013-10-31remove arity enforcement for atfork_* hooks
It's usually given as a block, so Ruby won't care about arity there. Users will get the worker ID number as the first arg, making it possible to isolate some things to certain processes (e.g. for A/B testing).
2013-10-31implement before_exec hook
This allows modifying the command-line (as an array) passed to Kernel#exec, as well as running anything necessary.
2013-10-31implement shutdown_timeout and expiry on graceful shutdown
Otherwise, the server may stay running forever if a client chooses to stay forever (and there is no FD pressure).
2013-10-30test_server: improve working_directory test robustness
We need to account for the directory change since yahns may lazily require some files. GTL is also not needed inside a child process.
2013-10-30test for overriding rack.errors destination
Different instances/ports of apps may want to point error output elsewhere.
2013-10-30add test for working_directory config parameter
This is often forgotten, and we need to make a tweak to the coverage generator to dump correctly.
2013-10-30tests for SIGTTIN and SIGTTOU
These are implemented trivially and based on working code, but test them anyways.
2013-10-29implement user switching
This was documented (incorrectly) and not implemented for either the master/worker or single process cases. Implement and test all (with mocks, so not fully-tested).
2013-10-28associate private/anonymous queues correctly
We do not want users to use the default queue unless an app context requires it. We also do not want to spin up the default queue unless we are sure we have app contexts using it (and not private/anonymous queues).
2013-10-26fix SIGCHLD w/o workers + PID file renames
We'll hit SIGCHLD if our reexec process fails on us, so the non-MP server must handle it, too. We discovered this bug while porting the PID file renaming changes from unicorn.
2013-10-26tests: increase mkserver use to reduce LoC
This reduces the amount of code we have in our tests to improve maintainability.
2013-10-25enforce FD_CLOEXEC on all pipes, including tests
We need to prevent FD leakage on Ruby 1.9.3
2013-10-22config: implement atfork handlers
These can be used to disconnect/reconnect to databases and other external connections. These are named to match the documentation of pthread_atfork(3)
2013-10-22tests: enforce close_on_exec on all client sockets
Leaking file descriptors may lead to out-of-FD situations in an MT test suite.
2013-10-22tests: do not lose exceptions on quit timeouts
We should see the reason for test failures.
2013-10-22test_server: remove skipped multi-process balance test
We know Linux will try to do this, but cannot be completely successful in all cases.
2013-10-21tests: support disabling parallelization env
Temporarily disabling parallel tests maybe needed to diagnose some problems with tests.
2013-10-20test_server: bigger delays for graceful shutdown test
This should hopefully increase test reliability as timing of signal delivery is not guaranteed...
2013-10-20test_server: skip test_mp_balance for now
This should probably made into statistical test to allow for scheduler unfairness causing imperfect balance between new connections. For now, it's easier to skip it since it fails a small percentage of the time. In real world use, a small amount of imbalance does not matter on a busy system as long as connections are reasonably well distributed.
2013-10-18disable persistent connections on SIGQUIT
We want to shutdown gracefully, but still relatively quickly (to make way for the new one). So we must disable persistent connections to prevent clients from keeping to-be-dead server alive indefinitely.
2013-10-18http_response: respect setups with non-persistent connections
Some users may wish to disable persistent connections for testing or whatever reason, let them. We'll also be using this feature to force SIGQUIT to expire clients.
2013-10-18test: cleanup socket usage and lifetimes
This should help prevent us from running out of FDs prematurely as our test suite becomes more multi-threaded. We can also use plain TCPSocket in tests where we inherit the file descriptor from the parent (w/o accept).
2013-10-18initial commit