testcontainers / testcontainers/testcontainers-java
NullPointerException in execInContainer for long running commands
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 8.7k
- Forks
- 1.9k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 9
Description
Test case:
@Test
public void testExecInContainer() throws InterruptedException, IOException {
try (GenericContainer<?> c = new GenericContainer<>(DockerImageName.parse("redis:3.0.2"))) {
c.start();
Container.ExecResult r = c.execInContainer("/bin/bash", "-c", "sleep 600");
}
}
After 3 minutes, I've got this exception (tested with testcontainers 1.16.0):
java.lang.NullPointerException
at org.testcontainers.containers.ExecInContainerPattern.execInContainer(ExecInContainerPattern.java:85)
at org.testcontainers.containers.ContainerState.execInContainer(ContainerState.java:235)
at org.testcontainers.containers.ContainerState.execInContainer(ContainerState.java:226)
Note: I'm using DOCKER_HOST to execute on a Linux machine.
My real problem is: how do I execute a command which runs a long time? there seems to be an underlying socket timeout in docker-java, is it possible to increase this timeout?
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 with the failing test case in the issue and inspect ExecInContainerPattern.java:85, then follow the calls through ContainerState.java:226 and :235. Reproduce the long-running /bin/bash sleep command against the DOCKER_HOST setup and determine why it becomes a NullPointerException after three minutes. Done means long-running exec commands handle the timeout without that exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, java
- Domain
- devops, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100