We have some tests that have to assert a certain condition was reached, but this condition being reached is the result of an asynchronous work. Thus we end up adding sleeps before assertions, in order to give that asynchronous work some time to execute. As it happens, our CI is quite slow (and getting slower...), so the timeouts we defined are not enough. This leads to some tests failing unexpectedly, for instance JMS tests. We should try to find a solution that will prevent us to wait too long on quick machines, and degrade gracefully to longer waiting times on slower machines. Something like the step waiting we have in the JGroups tests:
boolean failed = true;
for ( int i = 0; i < MAX_WAITS; i++ ) {
Thread.sleep( NETWORK_WAIT_MILLISECONDS );
if ( result.size() == 1 ) { failed = false;
break; }
}
if ( failed ) {
Assert.fail( "Waited for long and still Peter Pan didn't fly in!" );
}
|