forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use testcontainers networking capabilities when using @QuarkusIntegra…
…tionTest + DevServices This is done in order to get us off of host networking (which only works on Linux). The way this works is that when @QuarkusIntegrationTest is meant to launch a container and DevServices are needed, a build item is pushed into the build that forces the DevServices to launch in TestContainers' SHARED Network. The id of network is then used when launching the application as a container. Fixes: quarkusio#18194
- Loading branch information
Showing
85 changed files
with
2,526 additions
and
139 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...ment/src/main/java/io/quarkus/deployment/builditem/DevServicesSharedNetworkBuildItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package io.quarkus.deployment.builditem; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.function.Consumer; | ||
import java.util.function.Function; | ||
|
||
import io.quarkus.builder.BuildChainBuilder; | ||
import io.quarkus.builder.BuildStepBuilder; | ||
import io.quarkus.builder.item.SimpleBuildItem; | ||
import io.quarkus.deployment.pkg.builditem.ProcessInheritIODisabled; | ||
|
||
/** | ||
* A marker build item that if present during the build, then the containers started by DevServices | ||
* will use a shared network. | ||
* This is mainly useful in integration tests where the application container needs to be able | ||
* to communicate with the services containers | ||
*/ | ||
public final class DevServicesSharedNetworkBuildItem extends SimpleBuildItem { | ||
|
||
/** | ||
* Generates a {@link List<Consumer<BuildChainBuilder>> build chain builder} which creates a build step | ||
* producing the {@link ProcessInheritIODisabled} build item | ||
*/ | ||
public static final class Factory implements Function<Map<String, Object>, List<Consumer<BuildChainBuilder>>> { | ||
|
||
@Override | ||
public List<Consumer<BuildChainBuilder>> apply(final Map<String, Object> props) { | ||
return Collections.singletonList((builder) -> { | ||
BuildStepBuilder stepBuilder = builder.addBuildStep((ctx) -> { | ||
ctx.produce(new DevServicesSharedNetworkBuildItem()); | ||
}); | ||
stepBuilder.produces(DevServicesSharedNetworkBuildItem.class).build(); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.