https://kotlinlang.org logo
#kotest
Title
# kotest
a

Ashish Kumar Joy

10/08/2021, 1:27 AM
I am currently using Eventually but still with that, there are times when test fails, the Code under test schedule some task on a separate thread pool, which is supposed to completed with 2-3 seconds yet depending upon the load on CI agent where these test are running they can take say 7-8 second to complete resulting in test failure, one option is to increase timeout duration in eventually above 8 second, but depending upon the number of such test this will increase the overall build time.
j

Jim

10/08/2021, 2:13 AM
Those tests with the long delay should yield resources to the other tests that are actively doing things, right @sam?
s

sam

10/08/2021, 2:14 AM
The whole point of eventually is that it won't take any longer that necessary
As soon as the test passes, it will yield
j

Jim

10/08/2021, 2:15 AM
That too, but
delay
should give up the coroutine while it's delaying too I think
s

sam

10/08/2021, 2:16 AM
Yes
Give up the thread
The coroutine suspends
j

Jim

10/08/2021, 2:20 AM
Yeah so personally I don't see the problem with a long timeout and a reasonable interval 😂😅
t

thanksforallthefish

10/08/2021, 6:03 AM
we had a similar problem and settled down changing the executor of async tasks in test to sync. however our stack trace does not include coroutines and uses spring, so we just slapped a bean
Copy code
@Bean
  @Primary
  fun asyncExecutor(): ExecutorService {
    return com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService()
  }
and lived happily ever after. we tried increasing the timeout on
eventually
but after the 3rd or 4th time we patched flaking tests that way we want a more stable solution
3 Views