Questions tagged [testcontainers]

TestContainers is a Java library that supports (JUnit) tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.

Testcontainers is an open source framework for providing throwaway, lightweight instances of databases, message brokers, web browsers, or just about anything that can run in a Docker container.

Define your test dependencies as code, then simply run your tests and containers will be created and then deleted.

https://www.testcontainers.org/

881 questions
4
votes
3 answers

"message":"Head \"https://registry-1.docker.io/v2/testcontainers/ryuk/manifests/0.3.0\": unauthorized: incorrect username or password" when run test

I have added testcontainer in spring boot app import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @SpringBootTest @Testcontainers @AutoConfigureMockMvc class ProductServiceApplicationTests { @Container …
Gopal
  • 71
  • 1
  • 6
4
votes
0 answers

TestContainer can't start due to error: Timed out waiting for log output matching

I got "ContainerLaunchException: Timed out waiting for log output matching" when starting testcontainer for elasticserach. How should I fix this issue? container = new ElasticsearchContainer(ELASTICSEARCH_IMAGE) …
4
votes
0 answers

How to pull a private docker image from AWS ECR to use with the Testcontainers library in Java/Kotlin?

I am trying to programmatically create and spin up a Testcontainers GenericContainer from a docker image hosted in a private AWS ECR repository. This will be used for automated integration tests, will be run locally and within CICD pipelines. I know…
4
votes
5 answers

testContainers and Rancher

I have a Spring Boot application with integration tests that are using testContainers. Till recently, I used Docker Desktop and was able to easily run the test from within Intellij or from CLI. Recently I changed my Windows machine to Rancher…
riorio
  • 6,500
  • 7
  • 47
  • 100
4
votes
1 answer

Data from test with @Transactional are persisting between tests

I have a small problem. I have started writing tests for my small project. The project uses SpringBoot, standard JpaRepository from Spring, as a testing framework I am using Spock and for testing the database, I'm using PostgreSQL container from…
4
votes
3 answers

Uploading a file to testcontainer FTP server fails with Connection refused after being connected

I'm working with FTPClient against an FTP server using Testcontainers. A reproducible code sample is here: import org.apache.commons.net.PrintCommandListener; import org.apache.commons.net.ftp.FTP; import org.apache.commons.net.ftp.FTPClient; import…
orirab
  • 2,915
  • 1
  • 24
  • 48
4
votes
1 answer

testing kafka and spark with testcontainers

I am trying to check with testcontainers a streaming pipeline as a integration test but I don´t know how get bootstrapServers, at least in last testcontainers version and create a specific topic there. How can I use 'containerDef' to extract…
4
votes
1 answer

com.playtika.testcontainers vs org.testcontainers

I'm have a bit of confusion as I am trying to mock up some container dbs and looking around at whats available many refer to both of these libs such as this…
Will
  • 8,246
  • 16
  • 60
  • 92
4
votes
1 answer

Kafka TestContainer tries to connect to wrong address

I am learning ho to test Spring Boot Kafka application with TestContainers. The test passes. However, in the beginning there are a lot of such messages: 2021-04-05 09:00:13.927 WARN 1864 --- [| adminclient-1] org.apache.kafka.clients.NetworkClient …
Aleksei
  • 137
  • 1
  • 12
4
votes
1 answer

Test containers: ignore parent `EXPOSE` instruction from Dockerfile

I'm trying to run Couchbase v.5.1.1 docker container for test purposes via Test container with fixed exposed ports, like: trait CouchbaseTestEnvironment extends ForAllTestContainer { this: Suite => def couchbaseContainer:…
Ivan Kurchenko
  • 4,043
  • 1
  • 11
  • 28
4
votes
1 answer

Spring Data Elasticsearch integration test using Testcontainers in SpringBoot

I am trying out to write an integration test for Spring Data Elastisearch repository in SpringBoot using Testcontainers and junit5. But the test fails with org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with…
4
votes
0 answers

Making Testcontainers restartable with Kotlin, JUnit, and Spring Boot

I'm trying to integrate restartable Testcontainers into an application that uses JUnit and Kotlin. The way I do it currently, is to have a companion class in every test suite where I set up the container and the Spring Boot properties, like so: …
Cube.
  • 483
  • 6
  • 15
4
votes
2 answers

TestContainers and Error : "Failed to validate connection org.postgresql.jdbc.PgConnection" (raising a single container for all test classes)

I have a problem when I try to run the tests one by one. The database connection is closed. According to the documentation (Containers declared as static fields ...), I tried to make sure that my container was raised once for all tests. I…
skyho
  • 1,438
  • 2
  • 20
  • 47
4
votes
0 answers

Can Testcontainers join existing network?

I wish to create a network via docker-compose (via DockerComposeContainer) and have another container (created via ImageFromDockerfile) join that same network. Is this possible? Asked another way, can ImageFromDockerfile join an existing…
Damo
  • 1,449
  • 3
  • 16
  • 29
4
votes
3 answers

One testcontainers for multiple tests

I'm on scala, and I have multiple test files for different classes (testsuites), each of them uses testcontainers (init from the same script). When I launch all tests in the project, all tests failed (problem connection with database due to…
FTK
  • 43
  • 4