testcontainers / testcontainers/testcontainers-java

Testcontainer interacting with a java class that depeneds on the product

Offen
#3,517 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Java
Sterne
8.7k
Forks
1.9k
Ø Merge
2 T. 17 Std.
Gemergte PRs (30 T.)
9

Beschreibung

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!

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginnen Sie mit der Überprüfung des Container-Setups unter src/test/java und von call-home-ssh-client/Dockerfile, insbesondere der Einstiegspunkte ImageFromDockerfile und withFileFromClasspath. Reproduzieren Sie den Fehler Forbidden path outside the build context und ermitteln Sie anschließend, ob das unterstützte Verhalten oder die Dokumentation erklären sollte, wie die erforderlichen Quell- und JAR-Dateien bereitgestellt werden. Als abgeschlossen gilt die Aufgabe, wenn das Integrationstest-Setup eine dokumentierte oder verifizierte Möglichkeit bietet, beide Container zu erstellen und auszuführen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
docker, java
Bereich
devops, testing
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.