Test: index dump on test failure

This changes adds the ability for a test to create an index dump if a search request fails the test. This can be helpful to be able to analyse the index state after the test has failed
I just realized this will probably cause problems with the test security manager? It stops anything being written outside where we expect (ie in temp dirs controlled by the test).  Right now it lets you write anywhere based on the CWD of the test, but I hope to change that in the future.  It would probably be best to create a temp dir?  So it won't be any better than what you have here with the UUID as far as knowing which dir to expect, but you can give it a meaningful prefix, and it means it will be cleaned up easily.