testcontainers / testcontainers/testcontainers-java
Use Executor in AbstractWaitStrategy
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 8.7k
- Forks
- 1.9k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 9
Description
I am trying to bridge to a suspend version of waitUntilReady in AbstractWaitStrategy with something along the lines of:
suspend fun strategy(waitingStrategyTarget: WaitingStrategyTarget): Unit {
// run your strategy
}
class MyWaitStrategy : AbstractWaitStrategy() {
override fun waitUntilReady() {
val executor: ExecutorService = EXECUTOR // executor from AbstractWaitStrategy
runBlocking(executor.asCoroutineDispatcher()) {
strategy(waitingStrategyTarget)
}
}
}
or in a TestScope with JUnit this may look like:
@Test
fun testWithSuspendedWaitStrategy() =
runTest {
val strategy =
waitStrategy { target ->
// run my strategy
}
// MyContainer.waitUntil(strategy, ....)
}
fun TestScope.waitStrategy(
f: CoroutineScope.(target: WaitStrategyTarget) -> Unit
): AbstractWaitStrategy =
object : AbstractWaitStrategy() {
override fun waitUntilReady() {
launch(EXECUTOR.asCoroutineDispatcher()) {
f(this, waitStrategyTarget)
}
}
}
Is there a way how to implement this with EXECUTOR, being public instead of package private, or with another Executor, ExecutorService or something.
Any Feedback is welcome :D
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading core/src/main/java/org/testcontainers/containers/wait/strategy/AbstractWaitStrategy.java, especially the EXECUTOR declaration and waitUntilReady integration. The issue provides Kotlin coroutine examples but no named tests or acceptance criteria; a completed change would need an agreed approach for exposing or replacing the executor and a defined way to verify suspended wait strategies.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, kotlin
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100