I apologize in advance if this is an already answered question. I
couldn't find a reference to it, but you can never tell.
I am testing ElasticSearch from a grails application. Its just a
simple way to test my indexing and searching using the Java API.
Periodically I will also use the GXContentBuilder as well. I am
trying to keep a steady state in my tests. Meaning, I blow out any
existing indices and reindex before running my tests. Not before each
individual test mind you, but before running the 'search integration
My problem is this: I can't find a reliable way to determine when the
indexes are ready. At first I thought a cluster health
'waitForYellow' check might work, but it doesn't. The following
search will show no results. Neither will an IndicesStatusRequest
show any documents in the index as well. I also tried a waitForGreen,
which did work. Until I realized that it was just timing out. Since
it's only one node it can't really 'go green'. So, what I ultimately
determined was that doing a Thread.currentThread().sleep(1000) would
do the trick. But its the cardinal sin of integration testing. I
have an awesome workstation with an SSD and new 'Sandy Bridge'
processor, so what seems to work on my machine will inevitably
breakdown when it's run on a CI server that's also running other
builds, etc. But only every once in awhile.
So, what I would really like is some type of blocking call I can make
that will tell me when the index is ready. Or at a minimum, some type
of argument to my IndexRequest that will make it block until the
document is ready to be searched. Of course, that isn't something I
would do in production, as having the call return a future is exactly
what I want on a save/update operation. But it would help a lot in
making some reliable integration tests.
Thanks in advance,