This eliminates the possibility of hitting MSGQ_READ_UNKNOWN_FD, and, in fact,
we can even deprecate this message. And then, process_socket() becomes
a 2-line function called only by _process_fd() and can be integrated into
the latter. so it's done, too.
This way we check the logging works to the correct place and that the
configuration is handled. It is better checked by lettuce than unit
tests, since there's a lot of inter-module communication in it.
This will be needed in the following work. If we run in the same thread
and tried to connect to self by the cc library, it would deadlock, since
the library blocks waiting for answer.
Also, small cleanup of shutdown is included.
No functional change should be observable.
Do the initialization in tests too (the executable script initializes it
only when run separately, to know the correct parameters).
Also, remove deprecated and unused auxiliary script that doesn't and
didn't work.
callable() has been removed in Python 3, but was reintroduced in Python 3.2. This fix (check for isinstance(obj, collections.Callable) should make the test work with 3.1 and older versions of 3.
(acked on jabber)
Introduced a lowlevel mechanism into msgq to stop it (other than ye olde SIGTERM); a lowlevel message 'stop' will cause it to stop listening and shut down. Needed to add timeouts to poll() and control() for that, but chose them relatively high (their loop should simply reloop if they time out)
This allows the threaded msgq testing code to be more reliable (and not having to daemonize and arbitrarily kill threads except in the case of major failures, in which case the test itself will fail)
Test setup raising arbitrary exceptions from the write socket.
We can extend this to do the same for reading I think.
Also added tests; some for things that worked already (EAGAIN, EWOULDBLOCK), but also for the SIGPIPE that is the problem in #2398
* kqueue maybe doesn't survive fork on MacOS
* add_kqueue_socket wanted socket, not fileno
* Some systems don't have MSG_DONTWAIT, so we set the socket nonblocking
Some of our built machines time out, for two possible reasons:
* They have long buffer before they start blocking. Therefore the amount
of data sent is increased.
* They have clock with low precision, so if now - last_sent > 0.1:
happens after a long time. So the timeout waiting for that was
increased.
It could happen in rare occasions that the subprocess survived death of
the tests, mostly when exceptions happened in the parent process and it
didn't kill it. So there's a finally now and the subprocess has a
limited life length just in case it still slipped somehow without kill.
* Tests that try sending data and expect to time out.
* Test that tries to repeatedly send a command to msgq and expects it to
be answered (to see that the sending does not only timeout, but works
when the data are read as well).
on the msgq and python side, the socket file is either:
- what is speficied as an argument to the constructor, OR
- environment variable BIND10_MSGQ_SOCKET_FILE, OR
- default (@localstatedir@/msgq_socket)
in that order.
two open items:
TODO: run_X scripts should set a local file in BIND10_MSGQ_SOCKET_FILE (so if installed dirs don't exist run from source fails right now)
TODO: the c++ boost::asio version has no 'manual override', only environment variable or default. (which is better than what it was before, only hardcoded port 9912), fixing this would mean an API change somewhere
git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac183@1901 e5f2f494-b856-4b98-b285-d166d9295462
Moved msgq tests to own directory.
Added targets for all known python unittests.
Note this is for those that use the unittest module.
Other tests are ignored for now.
These tests are ran using "make check" even if not built
with gtest.
Some of these tests fail. I will comment them out in later commit.
git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac153@1753 e5f2f494-b856-4b98-b285-d166d9295462