IMPALA-2007: Fix flaky statestore test
IMPALA-2007: Fix flaky statestore test

This patch fixes two issues with test_statestore.py.

1. One path in the wait_for_* methods would return None, rather than
self, which breaks the 'fluent' interface for the test object.

2. A race condition in the wait_for_* methods could lead to (for
example) after an update was received, self.heartbeat_count being
read *before* the event that indicated its change was fired. Then the
client would wait on that event, read the same value as before, and
incorrectly conclude that a timeout had happened. The fix is to use
condition variables, rather by than the lightweight Event objects, as
the former allow us to lock the state that's shared between consumer and
producer to prevent these kind of races.

Change-Id: Idb546f93c3542a165d170e0a835aaa9368eb152d
Reviewed-on: http://gerrit.cloudera.org:8080/466
Tested-by: Internal Jenkins
Reviewed-by: Henry Robinson <3eca10f30041813f045165784e24b5a950a6cc7e@cloudera.com>

ibmsoe/ImpalaPPC,ibmsoe/ImpalaPPC,ibmsoe/ImpalaPPC,ibmsoe/ImpalaPPC,ibmsoe/ImpalaPPC,ibmsoe/ImpalaPPC,ibmsoe/ImpalaPPC