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.
902
questions
0
votes
0
answers
5
views
Test Kafka listener with custom container factory in spring boot
I'm having big troubles trying to test a kafka listener.
The class is the following:
@Component
class KafkaListener(
private val useCase: UseCase
) {
@KafkaListener(
topics = [&...
-1
votes
1
answer
35
views
Getting null from DB while running integration test using TestContainer
I am learning Java, Spring and I came across the TestContainers library for writing (unit/integration) tests. I tried to write a sample application, made a RabbitMQ producer, consumer, then I wrote a ...
0
votes
2
answers
22
views
MassTransit Kafka Consumer Console App fails to connect to Kafka Topic Endpoint repeatedly
I am trying to create a Kafka Consumer that consumes data from a topic, using MassTransit. As part of this, I am creating integration tests for it using Testcontainers, in particular a Kafka ...
-1
votes
0
answers
34
views
Why testcontainer is not reused in spring boot test?
I have following test config:
@Configuration
class MyConfig {
@Bean
fun ldapConnectionPool(): LDAPConnectionPool? {
val connection: LDAPConnection = SambaServerStarter.start()
...
0
votes
0
answers
15
views
Testing custom Kafka Connect SMT using Test Containers
I'm trying to use TestContainers to integration test a Kafka Connect Custom SMT (Simple Message Transformer) which needs to make use of a external library (BouncyCastle encryption).
The test should:
...
1
vote
0
answers
46
views
Connecting to Test Container with Postgres Fails
For one of my project, I'm using the Test Containers set up. What I do here is basically create a Postgres image like this:
# To build this Dockerfile run the folloing command
# docker build -t custom-...
0
votes
1
answer
52
views
ORA-01722: invalid number (Only For MacOS PC)
The entity
@Entity
@Table(name = "policy_restriction_bound",
uniqueConstraints = @UniqueConstraint(columnNames = {"policy_restriction_id", "upperBound", "...
-1
votes
2
answers
49
views
Cannot find Docker environment for Test Container (Mysql) in Spring Boot
I have a problem to run docker-compose up -d to run Spring Boot on Docker. I have a MySQL database connection issue when the app tries to run integration test with test container.
As I cannot connect ...
1
vote
0
answers
36
views
Running jooq from testcontainers with a flyway migration via SBT
I've seen some guides on how to achieve this in java (gradle/maven) but I can't seem to get it to work with an SBT project.
The goal is for my current setup to not require an available postgres ...
0
votes
0
answers
12
views
How do you configure the logging driver for container using testcontainers?
When I write a docker-compose file I can insert a logging section like so:
logging:
options:
max-size: 10m
max-file: "3"
How can I congfigure my GenericContainer to have a logging ...
0
votes
0
answers
24
views
Error using test containers for Oracle on the Apple Silicon Mac
There is a need to add the use of test container to a project written with spring 1.5.9.RELEASE. Oracle is used as the image, but at the time of initialization I get an error:
exception is org....
0
votes
0
answers
33
views
How to create a PostgresQL extension inside a testcontainer started by Junit5 and configured by Spring Boot
I have a Spring Boot 3 project where I write integration tests that use test containers to run the PostgreSQL database.
I'd like to introduce fuzzy matching in one endpoint, and thus require the ...
0
votes
0
answers
19
views
How to inject connection details of java testcontainer into Spring bean?
I have a bean that when the Spring container starts and this bean is created will connect to a mqtt broker in @PostConstruct.
The problem is that the testcontainer starts after the bean is created. So ...
0
votes
0
answers
24
views
Spring Boot 3 Postgres TestContainers SQL Exception
I am using Spring Boot 3.1.3 and Java 17
test application.yml
spring:
sql:
init:
mode: always
r2dbc:
url: r2dbc:tc:postgresql:///test_tc_db?TC_IMAGE_TAG=13.3
my test
@SpringBootTest
...
0
votes
2
answers
31
views
Exclude from logs in Java - DEBUG com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.wire
Have a Spring Boot project and while running integration tests I get plenty of these debug messages. Which library is generating them and how to exclude them properly?
13:41:03.966 [ducttape-1] DEBUG ...
0
votes
0
answers
41
views
TestConteiners+Windows10+WSL2+Docker+Idea: Could not find a valid Docker environment
I use Win 10 and Docker on WSL2.
WSL Docker settings
docker --version
Docker version 24.0.5, build 24.0.5-0ubuntu1~20.04.1
I added "hosts": ["unix:///var/run/docker.sock", "...
1
vote
1
answer
35
views
Spring Boot 3.1 with compose and postgres dependencies fails running contextLoad test
I just created a Spring Boot 3.1.3 project with dependencies as below:
Web
Data JPA
Test
Docker compose
Postgres
Testcontainers
It includes a compose.yml file with initial settings for postgres ...
0
votes
1
answer
22
views
Spring Boot Testcontainers Gradle Multi-module Project
I have a multi-module Spring Boot project and I’m attempting to use Testcontainers at development time following this documentation.
The problem I'm running into is when running the main method, ...
0
votes
1
answer
74
views
Use Testcontainer SQS with spring-cloud-aws-starter-sqs 3.0.2
After moving to spring boot 3 and spring-cloud-aws-starter-sqs 3.0.2 I am now trying to create an integrationtest with SQS.
I try to find an example, but so far none of the examples I found are this ...
0
votes
1
answer
10k
views
Docker API respond with status code conflict, container xxxxxx is not running
When running dotnet test inside a gitlab cicd pipeline with the package testcontainer, containers are started but this error appears :
Error Message:
Docker.DotNet.DockerApiException : Docker API ...
0
votes
1
answer
34
views
Creating a Container from ImageFromDockerfileBuilder with TestContainers .NET C#
I'm taking a stab at using the TestContainers package for my .NET application. I have a Dockerfile authored for building the image that I need for my application. I followed the instructions on the ...
0
votes
1
answer
45
views
TestContainers GenericContainer start() never finishes
I'm using TestContainers for some acceptance-testing in a kotlin spring-boot project.
I start all the docker containers successfully except a particular one, for which the start() method never ...
0
votes
1
answer
42
views
mariadb testcontainer not exposed to localhost
I have created the following mariadb testcontainer
@Container
private static final @NotNull MariaDBContainer<?> mariadb = getMariaDBTestContainer(network);
private static MariaDBContainer<?&...
0
votes
0
answers
21
views
Create Integration Test on call external API using API project with TestContainer and xUnit project
After much time crawling on internet for solution, so finally I post this question.
public Client(IOptions<Options> options, HttpClient httpClient)
{
_options = options?.Value ?? ...
0
votes
0
answers
48
views
Docker on WSL and Testcontainers instead of Docker Desktop: docker-machine executable was not found on PATH
I installed WSL on Windows 10 and installed Docker on it like this
wsl
sudo apt update
sudo apt install docker.io -y
wsl docker
doskey docker=wsl docker
wsl docker -v
Docker version 24.0.5, build 24....
1
vote
2
answers
41
views
LocalStack TestContainer unable to match logs using WaitForLog
I'm trying to start a localstack container, this container launches a script at startup to initialize an S3 bucket, a SQS queue and a DynamoDB Table with a GSI.
Here I'm using a waitStrategy Wait....
0
votes
0
answers
40
views
SQL Server test container docker image appears to start but fails with deadlock during setup
I am using test containers to deploy a SQL Server locally for dev, its created using following:
new MSSQLServerContainer(DockerImageName
.parse(sqlImageName)
....
1
vote
0
answers
48
views
How can I configure SpringBoot TestContainers to use containerd instead of docker
DockerDesktop allows you to enable the use of containerd. Doing this appears to disable the docker daemon or prevent TestContainers from accessing the host.
I would actually like to use containerd in ...
0
votes
1
answer
41
views
localstack testcontainer startup script
I'm trying to use localstack testContainer to create an S3 and SQS localy.
Here is my code to create the test container :
@Container
static LocalStackContainer localStack =
new ...
-1
votes
0
answers
42
views
Connection to node -1 (localhost/127.0.0.1:32929) terminated during authentication
I am using Kafka TestContainer to write the Integration test
@ClassRule
public static KafkaContainer kafkaContainer =
new KafkaContainer(DockerImageName.parse(KAFKA_CONTAINER_IMAGE_NAME))
...
0
votes
2
answers
81
views
Lambda function running on localstack Testcontainers not able to connect to redis Testcontainers
I am writing integration tests for AWS lambda function that is invoked with KinesisEvent and then writes some data to Redis and Kafka.
I am using LocalStack and Testcontainers to achieve the same.
I ...
0
votes
1
answer
50
views
How do I migrate reusable containers approach from 2.4.0 to 3.4.0?
This used to work back in Testcontainers 2.4.0. However, the image it used is now gone and I'm forced to upgrade to the newest one which is 3.4.0. The problem is new ContainerBuilder<T> is no ...
0
votes
0
answers
43
views
How do I immediately throw a DataAccessException when testing a 5xx response using MongoTemplate and Testcontainers without waiting for the timeout?
I'm trying to write tests that cover MongoDB being unavailable. In my code, to handle this event, I catch a DataAccessException and throw my own custom ServiceUnavailableException returning a 503 ...
0
votes
1
answer
50
views
Liquibase executes migration after tests execution
I have very strange (for me) problem with testing my application, receiving this exception:
Caused by: liquibase.exception.MigrationFailedException: Migration failed for changeset db/changelog/inserts/...
1
vote
1
answer
188
views
How to run docker-compose file using testContainers in spring boot tests?
I have following docker-compose file for local development:
version: '3.4'
services:
samba:
image: instantlinux/samba-dc:latest
hostname: my.org
environment:
DOMAIN_ACTION: ...
5
votes
1
answer
169
views
How to pass secrets to testContainers?
I have following docker-compose file for local development:
version: '3.4'
networks:
mynetwork:
services:
samba:
image: instantlinux/samba-dc:latest
container_name: samba-dc
cap_add:
...
0
votes
1
answer
28
views
Testcontainers' shaded dependencies [closed]
Testcontainers bundles several dependencies that are useful and that I would otherwise add to my pom.xml explicitly. They are labeled as "shaded", like e.g. org.testcontainers.shaded.org....
0
votes
2
answers
51
views
How to run samba server in testContainers based on existing docker-compose
I have following docker-compose file for local development:
version: '3.4'
networks:
mynetwork:
services:
samba:
image: instantlinux/samba-dc:latest
container_name: samba-dc
cap_add:
...
0
votes
0
answers
32
views
Replacing H2 in the entire Spring Boot app
I have a Spring Boot app which appears to use H2 when building to run Liquibase commands on. It also appears that Unit Tests run against H2.
I'm digging into whatever makes this work behind the scenes....
0
votes
0
answers
58
views
Is there anyway to test Athena integration in test containers
I have a spring boot application and i want to test AWS Athena, I know that its possible to use local-stack (paid for).
https://docs.localstack.cloud/user-guide/aws/athena/
But i wanted to know is ...
0
votes
0
answers
65
views
How to get debug output from Testcontainers during unit tests in .net
When something goes wrong creating the container the test results and exception thrown give no clue to what the actual problem is. I am looking for a way to get output similar to what you get when ...
0
votes
1
answer
137
views
How to use @ServiceConnection with GenericContainer and custom ConnectionDetails
I am using new @ServiceConnection annotation to manage KafkaContainer in my tests and it works as expected - KafkaContainerConnectionDetails is used during auto configuration to override bootstrap ...
0
votes
1
answer
78
views
Run testContainers inside kuberenetes pod
I have to run integration tests inside a container which is inside a kuberenetes POD.
I have the folowing jenkinsfile:
!groovy
pipeline {
agent {
kubernetes {
yaml libraryResource('podTemplates/pod....
1
vote
1
answer
140
views
Can't start Testcontainers Docker in Mac M1
I have a M1 Pro chip and I'm trying to run some integration tests via Testcontainers.
For this, I've installed Docker desktop, and every time I try to run the test containers container, almost ...
1
vote
1
answer
64
views
How to use aerospike with testcontainers on github actions
I am trying to run aerospike on testcontainers with github actions,
I am sometimes getting an error and sometimes not when I run this on github actions, the error i got is below,
integration_test.go:...
0
votes
0
answers
15
views
get TestContainer to find local docker containers
I'd like to use TestContainers to get JUnit integration tests going with local docker containers that are either started already, in which case I need to hook into the running containers, or that may ...
0
votes
1
answer
216
views
test containers not working in spring boot and getting following exception org.junit.jupiter.api.extension.ParameterResolutionException:
I have implemented test containers in kotlin spring boot project but when I run project I am getting following exception
org.junit.jupiter.api.extension.ParameterResolutionException: Failed to resolve ...
0
votes
1
answer
95
views
testcontainers-java postgresql with podman
TLDR: org.testcontainers:postgresql:jar:1.18.3 seems to ignore certain settings.
I'm trying to use testcontainers postgresql for unit tests in my java app. I've read a bunch of articles/questions ...
0
votes
1
answer
55
views
Testcontainers start before Spring app and shut down after Spring App
I have this integration test:
@RunWith(SpringRunner.class)
@SpringBootTest(classes = MySpringApplication.class, webEnvironment = DEFINED_PORT)
public class UspControllerIT {
@Test
public void ...
0
votes
2
answers
121
views
Exception encountered during spring context initialization BeanCreationException: Error creating bean with name 'flywayInitializer'
Receiving the below error on running integration tests after migrating spring boot and it's related packages(including spring-boot-starter-test) from 2.2.4.RELEASE to 3.1.1.
Error creating bean with ...