On Thu, 2007-09-27 at 15:00 +0200, Arnaud Simon wrote: > We need a way of running a new broker instance before a test. For code > reuse sake I don't want to change all the existing tests and it looks to > me that the current tests don't do the necessary cleanup as they rely on > a in_VM broker that is started before each test. So, we need to start > and stop the broker before and after running a test. > Moreover, the new tests I am adding are relying on crashing and > restarting the server. So, we need a way of doing that from within the > tests and I don't think we can rely on maven for that.
C++ takes two approaches. "Unit" tests use an in-process broker which is started/stopped by the test itself. It's easy enough to simulate stop/restart with the in-process broker, and I have recently added tests that simulate network failures using in-process broker (e.g. by deliberately losing frames etc.) This is all good for unit-like tests focussed on a particular aspect. The "system" tests are all run against a single external broker started before the tests and shut down after. NB: It is *essential* that an external test broker does NOT run on the standard port, or on any fixed port that might be used by some unrelated development or testing on the same host. The C++ broker can be run with --port=0 which causes it to do a bind(0) and then report what port it bound to. As yet we don't have any tests where we shut down and restart an external broker but they'll be coming soon with the work on clustering. I've been using simple shell scripts to start & control multiple brokers.
