ros/actionlib — pull request #8 by miguelsdc (2013-08-04 13:55:11+00:00)
Title: Python Simple Action Server Deadlock Test

As discussed in ros/actionlib#4, this pull request contains a Python unit test to check for deadlocks during `simple_action_server.py`'s execution. It fails with groovy-devel and hydro-devel, but passes with ros/actionlib#6 (which is the expected behaviour).

The patch is composed of three files (plus an extra line in `CMakeLists.txt`)
* `test_simple_action_server_deadlock.py` which implements the main test using python.unittest. The script: sets up a simple action server; services requests from companions; kills the companion nodes; and checks the last serviced request wasn't too long ago.
* `simple_action_server_deadlock_companion.py` which simply requests many concurrent `TestAction`s.
* `test_simple_action_server_deadlock_python.launch` which launches five companions and the test.

I've identified the following potential issues with this patch:
* Testing for deadlocks is inherently difficult: a proper solution would require overriding python's `RLock()`. Instead these scripts allow the deadlock to happen and then checks whether the actions are being carried out. The disadvantage is that, if deadlocked, this test will terminate only when the test timeouts and `RLTestTimeoutException()` is raised (after ~75 seconds)
* Even when simple action server doesn't deadlock this test takes about 45 seconds to complete. This is because of a deadlock is not a deterministic condition, and thus we must allow sufficient time for it to happen.
* `test_simple_action_server_deadlock.py` imports `rosnode` which I believe is an implicit dependency of `rospy`. I don't know if this dependency should be made explicit, leave as it, or removed (it is not vital for the test, it just makes the output cleaner).

I couldn't come up with a better solution, but suggestions to improve this patch are welcome :)