We're updating the issue view to help you get more done. 

Improve timeout handling in tests

Description

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:

1 2 3 4 5 6 7 8 9 10 11 12 13 boolean failed = true; for ( int i = 0; i < MAX_WAITS; i++ ) { //need to sleep for the message consumption Thread.sleep( NETWORK_WAIT_MILLISECONDS ); if ( result.size() == 1 ) { //the condition we're waiting for failed = false; break; //enough time wasted } } if ( failed ) { Assert.fail( "Waited for long and still Peter Pan didn't fly in!" ); }

Environment

None

Status

Assignee

Yoann Rodière

Reporter

Yoann Rodière

Labels

None

Suitable for new contributors

None

Feedback Requested

None

Components

Fix versions

Priority

Major