Open hantsy opened 5 months ago
Those annotations will not work in all cases. For example, in WildFly there is the ability to implement a ServerSetupTask
which allows for configuration of WildFly before the deployment is done. You cannot inject the same instance of the Testcontainer in the ServerSetupTask
without Arquillian managing the lifecyle of the Testcontainer
.
Testcontainers have wait strategies, can the Wildfly/Glassfishs test deployment step wait for testconainters be ready for deployment?
@hantsy Yes, that should be possible AFAIK. If you have an example of what it would look like without Arquillian, I can confirm.
What should happen though is the Testcontainer is started before the class. The class should then be created and the deployment done. Once the class is complete, the Testcontainer should stop.
I tried this way in an example before: https://github.com/hantsy/arquillian-testcontainers-example/blob/autodeployment/src/test/java/com/example/it/GreetingResourceTest.java#L51
(ignore this example in autodeployment branch, I was trying to use AutoDeployment
provided in Arquillian, but not sure why the deployment was not started)
The @Container
and @Deployment
archives can be ready before running tests, Arquillian can utilize the wait strategy provided by Testcontainers, etc. to check the startup status of the application server and setup Arqullian properties for application servers, and decide to deploy.
That could be done by extending the testcontainer. Note that the @Testcontainer
annotation for JUnit 5 in the Testcontainer project is different than this. This project is for injecting a GenericContainer<?>
as an @ArquillianResource
.
I found there is a new annotation
@TestContainer
added to control testcontainer Container. https://github.com/arquillian/arquillian-testcontainers/blob/main/src/main/java/org/jboss/arquillian/testcontainers/TestContainersObserver.java#L28The basic support of Spring Boot testcontiners just adds a
@ServiceConnection
to the container declarations to setup the connection properties automatically.If possible, reuse the testcontainers existing
@Testcontainers
and@Container
to controll the container lifecycle, and ensure Arquillian sets up the application server adapter's properties after the successful waiting strategy. Then perform the deployment that is defined by@Deployment
.