testcontainers / testcontainers/testcontainers-java

Container restart retried without waiting

Aperta
#942 11 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

modules/jdbc resolution/acknowledged type/bug
Lingua principale
Java
Stelle
8.7k
Fork
1.9k
Merge medio
2g 17h
PR unite (30g)
9

Descrizione

Hi, I started using TestContainers today. It simplifies the work a lot! 🎉

However, I'm facing a problem with version 1.9.1 with MySQLContainer.

When I run the tests locally it works like a charm. However, in another computer it is trying to spawn 3 instances of the container without waiting between attempts. This is happening because an exception happened before the wait strategy could be invoked.

The exception in my case is the following:

java.lang.IllegalStateException: copyFileToContainer can only be used with created / running container
	at org.testcontainers.containers.GenericContainer.copyFileToContainer(GenericContainer.java:1075)
	at org.testcontainers.containers.GenericContainer.copyFileToContainer(GenericContainer.java:1067)
	at java.util.HashMap.forEach(HashMap.java:1289)
	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:262)
	at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:237)
	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:76)
	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:235)
	at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:220)
	at org.testcontainers.containers.GenericContainer.starting(GenericContainer.java:738)
	at org.testcontainers.containers.FailureDetectingExternalResource$1.evaluate(FailureDetectingExternalResource.java:29)
	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
	at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:379)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:340)
	at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:125)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:413)

As you can see, it is thrown, from GenericContainer#tryStart, before reaching the invocation of the retry strategy.

It looks like it might be caused by the container not being started yet. So maybe it is taking some milliseconds more in that computer. So maybe executing the wait strategy before the copy operation starts might help.

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

Inizia da GenericContainer#tryStart e usa lo stack trace per esaminare il percorso dei tentativi intorno a copyFileToContainer e alla strategia di attesa. Conferma il comportamento dei tentativi quando l’avvio genera un’eccezione prima che venga invocata la strategia di attesa; il lavoro è completato quando i tentativi non avviano più container senza attendere.

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

Valutazione

Stack tecnologico
docker, java
Ambito
devops, testing
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.