78 questions
58
votes
8
answers
68k
views
How to reuse Testcontainers between multiple SpringBootTests?
I'm using TestContainers with Spring Boot to run unit tests for repositories like this:
@Testcontainers
@ExtendWith(SpringExtension.class)
@ActiveProfiles("itest")
@SpringBootTest(classes = ...
1
vote
1
answer
8k
views
Testcontainers SchemaRegistry can't connect to Kafka container
I want to run integration tests that test my kafka listener and avro serialization. this requires a Kafka and a Schema regsitry (transitively also a Zookeeper).
When testing I currently have to a ...
14
votes
3
answers
30k
views
Localstack throws The security token included in the request is invalid
I use Localstack with Testcontainers((testcontainers:localstack:1.15.2 )) for integration tests and set up the secret in the test setup like this:
Code sample
import com.amazonaws.services....
25
votes
6
answers
8k
views
testcontainers, hikari and Failed to validate connection org.postgresql.jdbc.PgConnection
I have a spring boot app. I'm testing it with testcontainers to ensure that the DB (postgres) and the Repository implementation do what they are supposed to do.
I initialise the container with the ...
10
votes
5
answers
8k
views
Integration testing with Testcontainers + Quarkus + MongoDB
Trying out testcontainers for integration testing. I am testing rest api endpoint. Here is the technology stack -
quarkus, RESTEasy and mongodb-client
I am able to see MongoDB container is started ...
5
votes
3
answers
4k
views
How do I get Java testcontainers to work in Docker Multistage builds?
I have a problem similar to Run (Docker) Test Container in gitlab with Maven. The difference is that rather than my script running mvn directly it runs a docker multistage build that runs the test ...
1
vote
1
answer
2k
views
Reading a file from resources not working in gitlab CI
I am getting an error while running tests on gitlab CI using the command:
./gradlew clean test
I am using test containers to run my tests: https://www.testcontainers.org/modules/docker_compose/
...
18
votes
1
answer
10k
views
GitHub Actions: How can I cache the Docker images for Testcontainers?
I execute some tests in GitHub Actions using Testcontainers.
Testcontainers pulls the images which are used in my tests. Unfortunately the images are pulled again at every build.
How can I cache the ...
12
votes
4
answers
11k
views
@DynamicPropertySource not being invoked (Kotlin, Spring Boot and TestContainers)
I'm trying to define a @TestConfiguration class that is executed once before all integration tests to run a MongoDB TestContainer in Kotlin in a Spring Boot project.
Here is the code:
import org....
11
votes
1
answer
16k
views
How can I set the port for Postgresql when using Testcontainers?
Sometimes I need to install a port for Postgresql, which I run for tests in a container. But the Test container the developer command ofTestcontainers removed this feature. But somewhere there is a ...
9
votes
2
answers
18k
views
Testcontainer's Redis container connects to a different container then the one defined in the test
I'm doing integration tests in my Spring Boot app. The app needs a Redis to work with.
During development phase, I have a local container of Redis that the app connects to.
For the integration tests,...
7
votes
1
answer
4k
views
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 ...
6
votes
2
answers
20k
views
Mongo in testcontainers
I started playing with testcontainers and at the beginning of my journey I faced some issue (below). I did similar thing for mysql db and it worked fine. Do I miss some mongo specific config? ...
6
votes
2
answers
5k
views
Testcontainers for .NET error Auto discovery did not detect a Docker host configuration
I use Testcontainers.MsSql 3.0.0 for integration tests in asp.net project. Integration tests run successfully in visual studio test runner. But when I run tests in docker desktop version 20.10.7 by ...
5
votes
4
answers
4k
views
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;
...
5
votes
3
answers
17k
views
java.lang.IllegalStateException: Could not find a valid Docker environment. Please see logs and check configuration on M1 MAC
I'm trying to run Integration Tests on my local. I'm trying to pull mongo 3.6.0 image, I'm getting following errrors. The same thing is working on non-m1 mac.
ERROR org.testcontainers.dockerclient....
4
votes
3
answers
5k
views
Ryuk container that is started by Test container store don't stop the singleton container
I have several test nodes, but I run the container as a singleton.
@ActiveProfiles("test")
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@...
4
votes
1
answer
2k
views
BitBucket pipelines with testcontainer not working
I face this error when try to run bitbucket pipelines with test container
Could not start container java.lang.IllegalStateException: Container
did not start correctly.
There is no another issues but ...
4
votes
1
answer
13k
views
Failed to connect to PostgreSQLContainer: java.io.EOFException
Creating my container as:
public static PostgreSQLContainer<?> container = new PostgreSQLContainer<>("postgres:latest");
static {
container.start();
System.setProperty("driver-...
4
votes
2
answers
5k
views
How to automate DB setup of Entity Framework's Code First in Testcontainers for testing?
In order to setup the Testcontainer's MsSqlTestcontainer for testing, I copied the script emitted by dotnet ef migrations script and planted it in the unit-test's setup (actual code doesn't :
void ...
3
votes
1
answer
3k
views
Testing GCP PubSub with Testcontainer PubSub emulator
I'm trying to create an integration test with PubSub emulator based on the example from this GitHub repo which looks like
@SpringBootTest
@Testcontainers
@ActiveProfiles("test")
public class ...
2
votes
1
answer
3k
views
Use Testcontainers with another Database Driver
I am using Testcontainers (https://www.testcontainers.org/) with the Postgres module in a Spring Boot application with Kotlin and have configured everything as in this tutorial (https://www.wwt.com/...
2
votes
1
answer
2k
views
Overriding Configuration properties with test container in Micronaut not working
Test container configuration
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@Testcontainers
public abstract class TestContainerFixture {
@Container
protected static final GenericContainer ...
2
votes
3
answers
8k
views
Spring boot, ElasticSearch and TestContainers integration tests. Connection refused
I create an integration test for retrieving data from elasticsearch.
I am using default values for the testContainer so my RestHighLevelClient should have access to the test container but all the ...
2
votes
1
answer
2k
views
Testcontainer issue with Bitbucket pipelines
I configured bitbucket-pipelines.yml and used image: gradle:6.3.0-jdk11. My project built on Java11 and Gradle 6.3. Everything was Ok till starting test cases. Because I used Testontainers to test the ...