testcontainers / testcontainers/testcontainers-java

[Enhancement]: Reduce exceptions caused by Unreliables.retryUntilTrue

Open
#6,833 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type/enhancement
Dominant language
Java
Stars
8.7k
Forks
1.9k
Avg merge
2d 17h
Merged PRs (30d)
9

Description

Module

Core

Proposal

Hi 👋

I've been profiling test pipelines in our in-house projects and noticed on several Spring-Boot related projects that use DockerComposeContainer that a large amount of exceptions is thrown when waiting for the containers to start.
image

Throwing RuntimeExceptions with the message "Not ready yet" is not really exceptional here - on the contrary. It's rather the norm. I can't imagine this to be super efficient. It would be great if an alternative solution could be implemented that isn't based on exceptions. Or short-term alternative: throwing a dedicate exception with fillInStackTrace overridden to at least avoid the overhead of generating the stacktrace.

	class NotReadyYetException extends RuntimeException {

		public NotReadyYetException() {
			super("Not ready yet");
		}

		@Override
		public synchronized Throwable fillInStackTrace() {
			return this;
		}

	}

Or caching the exception....

Because duct-tape seems to be read only, I hope this is the correct place for this report. Please lead me to the correct place if not. I'm also open to provide the short term solution somewhere if you want me to and you think this is worthwhile.

Let me know what you think.

Cheers,
Christoph

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the Unreliables.retryUntilTrue entry point and its use by DockerComposeContainer when waiting for containers. Compare the current exception-based retry behavior with the proposed non-exception path or stacktrace-free exception, then define and test a measurable reduction in exception overhead without changing readiness behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, docker-compose, java
Domain
testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.