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
5
votes
1 answer

SpringBootTest, Testcontainers, container start up - Mapped port can only be obtained after the container is started

I am using docker/testcontainers to run a postgresql db for testing. I have effectively done this for unit testing that is just testing the database access. However, I have now brought springboot testing into the mix so I can test with an embedded…
springcorn
  • 611
  • 2
  • 15
  • 28
5
votes
1 answer

Seeding a mysql db with testcontainers

I have a very simple situation: an existing mysql database in AWS that I want to test against using testcontainers. I have followed the official guideline (https://www.testcontainers.org/modules/databases/) and its examples…
user3727540
  • 922
  • 3
  • 11
  • 30
5
votes
1 answer

Migrating schemas in docker testcontainers environment using Flyway and Spring boot

I'm trying to set up testing environment with testcontainers and flyway in spring boot application. All this supposed to run via DinD scheme. Current test example as follows: import com.testapp.testapp.entity.TestEntity import…
im_infamous
  • 972
  • 1
  • 17
  • 29
5
votes
3 answers

Start test container of ElasticSearch with plugin

I'm using testcontainers.org using docker.elastic.co/elasticsearch/elasticsearch-oss:7.3.2 and I want to use it to test the plugin I'm updating, but I can't find a way to install it inside test environment. I can try to copy file inside and install…
GotoFinal
  • 3,585
  • 2
  • 18
  • 33
5
votes
1 answer

Localstack module of testcontainers is not running for integration tests

I am trying to come up with some integartion tests for a Spring boot service. Since the service is using AWS SQS and DynamoDB, I tend to take advantage of the Localstack module of testcontainers for the integartion tests. But although I think I have…
dunfa
  • 509
  • 1
  • 10
  • 19
5
votes
0 answers

Run java tests with sudo in intellij

Context I've just found about testContainers, a library which can start docker containers and I wanted to test it writing a simple test inside Intellij. Problem The problem is that when i run the configuration in Intellij, the code throws Exception…
thmmy95
  • 361
  • 2
  • 18
5
votes
2 answers

Error Can not connect to Ryuk in CircleCi

There is config for CircleCI. On the local machine, when you run CircleCI, everything passes. In this case, the server is a lot of mistakes, one of them is java.lang.IllegalStateException: Can not connect to Ryuk At the same time in the future there…
5
votes
1 answer

"linkablecontainer not found" when using testcontainers

I want to use testcontainers (https://www.testcontainers.org/usage.html) So I imported the corresponding Maven dependencies: org.testcontainers testcontainers
ka3ak
  • 2,435
  • 2
  • 30
  • 57
5
votes
0 answers

TestContainers: reuse network from DockerComposeContainer to use in other GenericContainer?

There is a method: org.testcontainers.containers.GenericContainer#withNetwork which I can use to spawn containers with a same network using TestContainers lib. But what about DockerComposeContainer, first I start it, then I want to get a network out…
Nikolay Kuznetsov
  • 9,467
  • 12
  • 55
  • 101
5
votes
2 answers

Starting only one service from a compose file with DockerComposeContainer

Is that possible somehow to run only specific services in a Testcontainers DockerComposeContainer? Using the example in the official documentation, could we start only Redis? For me all the services start all the time (and it doesn't matter whether…
beatrice
  • 3,684
  • 5
  • 22
  • 49
5
votes
2 answers

object instatiation for java class returning SELF is not working kotlin

I have a java class public class CouchbaseContainer> when i try to create object for this in kotlin val couchbase = CouchbaseContainer() Kotlin is throwing error Type inference failed: Not enough…
4
votes
1 answer

docker.sock: permission denied when using testContainers with Podman on Windows

My Java & Spring Boot application integration tests use testContainers and I'm using Podman on my Windows machine. When trying to run the integration tests, I'm getting this permission error: Failed to load ApplicationContext …
riorio
  • 6,500
  • 7
  • 47
  • 100
4
votes
1 answer

TestContainer what is the difference between withStartupTimeout and waitingFor(Wait.forListeningPort())?

TestContainers doc states Ordinarily Testcontainers will wait for up to 60 seconds for the container's first mapped network port to start listening. This simple measure provides a basic check whether a container is ready for use. If I am starting…
tuk
  • 5,941
  • 14
  • 79
  • 162
4
votes
1 answer

Spring Boot + Flyway + Testcontainers(mariaDB): Table "xxxx" doesn't exist

I use Testcontainers with mariaDB database in a Spring Boot project for unit testing. I recently upgraded Spring Boot from 2.4.4 to 2.6.6 and found out that the unit test started to fail. The Testcontainers was created again (?) after the Flyway…
4
votes
2 answers

AmazonsS3Client throws UnknownHostException if attempting to connect to a local service (MinIO)

In Short: Using AmazonS3Client to connect to a local instance of MinIO results in a UnknownHostException thrown because the url is resolved to http://{bucket_name}.localhost:port. Detailed description of the problem: I'm creating an integration…
João Matos
  • 6,102
  • 5
  • 41
  • 76