We are using a modified WOAdaptor to set up a certain kind of clustering environment and as I have thought about how to test this, something came to me. It is difficult to test how the WOAdaptor is going to work because it manages a complex environment, so setting up tests is complex and therefore error-prone. Putting in a trivial test is easy but does not do much. One can just install the WOAdaptor, watch the log and say "Yep, it works", but this is probably not a great testing strategy. And making even trivial changes to the WOAdaptor seems difficult when there is no obvious way to test anything.
It occurred to me to add a "mirror mode" to the adaptor. I can short-circuit a request before it calls tr_open in _run_request in Adaptor/transaction.c. I could then build a response and send it back to the requestor. The response would be a dump of what the WOAdaptor would have done, spitting out such info as the final URL, the selected host, the selected instance and so on. One could hit the web server with hand-crafted requests, or a script could send things, or ab could be used.
There are multiple layers of indirection here, but I think that by the time the code gets to the tr_open call, all the smarts that the WOAdaptor wants to add have been added. I think that this is the last place we can get to before we actually hit the network. So, what I am imagining is this:
- set up the config XML with the number of instances, number of hosts, the application names, the scheduler policy and so on. I believe that one does not actually have to launch any apps or have any hosts actually available at this point, so the setup can be arbitrarily complex or weird.
- change a variable in the WOAdaptor config file to turn on "testing/mirror mode" and re-start the web server.
- Hit the web server with the URL that the user would use.
Obviously there are things this would not help test. How does the WOAdaptor respond when application instances go wonky? What happens when connections are aborted mid-stream? Things like that. But it could help test with some things. Is the scheduling doing the right thing? Are the proper instances being targeted? Are the URLs being re-written correctly. Like that.
Does anyone have any suggestions? Obviously if the "testing/mirror-mode" configuration variable is not set, the adaptor would behave as normal. And are there other things I am not thinking of? Any suggestions?
thanx - ray