testcontainers / testcontainers/testcontainers-java

Testcontainer interacting with a java class that depeneds on the product

Aperta
#3,517 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Java
Stelle
8.7k
Fork
1.9k
Merge medio
2g 17h
PR unite (30g)
9

Descrizione

Hi,

I am working on Call Home Client (SSH) for our product.

src/main/java
src/test/java
src/test/resources
  /call-home-ssh-client/Dockerfile
  /netopeer2/Dockerfile

I want to use the excellent testcontainer to test with a server (netopeer2). So I have created a test client ( src/test/java) that depends on our product ( src/main/java).

So I want to start call-home-ssh-client from docker image in a unit test. Then create the netopeer2 server from the other image and trigger call-home from it.

So for the call-home-ssh-client I need to build the src tree of my project and create a jar. Then I would run the specific test client inside the container.
Problem I am facing is that when I call the call-home-ssh-client from unit test with this part:

 
          final ImageFromDockerfile callHomeSshImage = new ImageFromDockerfile(
                "ssh-client", false)
                        .withFileFromClasspath(".", "call-home-ssh-client");
        return new GenericContainer<>(callHomeSshImage)
                .withExposedPorts(new Integer[] { 4334 })
                .withLogConsumer(logConsumer)
                .waitingFor(new LogMessageWaitStrategy().withRegEx(".*Call Home  listening on port [4334]*"));

and using this part of my call-home-ssh-client Dockerfile

FROM maven:3.6.1-jdk-8-alpine AS MAVEN_BUILD
WORKDIR /app
# copy the pom and src code to the container 
COPY ../src ./

RUN mvn clean package 

Could not build image: COPY failed: Forbidden path outside the build context: ../src

Do I need to create my GenericContainer in another way to support this?

The other option I was thinking of would be to create the call-home-ssh-client as a java thread and have it running while
I start my server ( netopeer2 ) also as Docker container. Could they talk to eachother?

I would appreciate if you could tell me what is possible to do with testcontainers since I could not figure it out from documentation.

br,

//mike

Ps. Testcontainers is a really neat feature!

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Iniziare esaminando la configurazione dei container in src/test/java e call-home-ssh-client/Dockerfile, in particolare gli entry point ImageFromDockerfile e withFileFromClasspath. Riprodurre l'errore Forbidden path outside the build context, quindi determinare se il comportamento supportato o la documentazione debba spiegare come fornire i file sorgente e JAR richiesti. Il lavoro è completato quando la configurazione di integration-test dispone di un modo documentato o verificato per creare ed eseguire entrambi i container.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
docker, java
Ambito
devops, testing
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.