From: Luke Kanies Date: 2005-08-16T01:26:14+09:00 Subject: Re: Unit testing servers On Mon, 15 Aug 2005, Adam Keys wrote: > I'm doing something pretty similar to this. I've got a class that > knows how to start and stop Web Services servers (XMLRPC, SOAP, > etc.) in their own thread. I start a fresh server in TestCase#setup > and kill it in TestCase#teardown. I riffed off the soap4r test cases > [1]. I'd be happy to go into more detail if you'd like. You know, I had a test that looked a lot like that and worked for small transfers but failed for transfers above about 20k, but now it doesn't even work for small transfers (even as small as one byte). I had the server in a separate thread and the client in the main process, and it worked. When I tried using the same process for passing large files around, though, I got a deadlock every time. I really am assuming that I'm just retarded and there's something weird going on with my code, but if everything works fine in a separate process (which it does) then it's not worth spending days figuring out how to use threads purely for testing. I did finally get a forked process to work for testing, as long as I use the fork with a block, rather than a pure fork, and I'll stick with that unless I can find some clear failure in my threading code. Incidentally, here's my current thread test code: http://reductivelabs.com/cgi-bin/puppet.cgi/file/language/trunk/test/server/tc_server.rb The threading test is disabled, because, well, it deadlocks (and the timeouts don't seem to work with deadlocks, which I suppose makes sense). I've also tried it with the client in the main thread, not in a separate thread, but it doesn't seem to make a difference. -- Zeilinger's Fundamental Law: There is no Fundamental Law. --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://config.sage.org