2727import org .testcontainers .utility .DockerImageName ;
2828
2929import java .util .Arrays ;
30+ import java .util .HashMap ;
3031import java .util .HashSet ;
32+ import java .util .Map ;
3133import java .util .stream .Collectors ;
3234import java .util .stream .Stream ;
3335
@@ -51,6 +53,10 @@ public class MicrocksContainersEnsemble implements Startable {
5153 private MicrocksAsyncMinionContainer asyncMinion ;
5254 private final MicrocksContainer microcks ;
5355
56+ private final Map <String , String > postmanEnvVars = new HashMap ();
57+ private final Map <String , String > asyncMinionEnvVars = new HashMap ();
58+ private final Map <String , String > microcksEnvVars = new HashMap ();
59+
5460 /**
5561 * Build a new MicrocksContainersEnsemble with its base container image name as string. This image must
5662 * be compatible with quay.io/microcks/microcks-uber image.
@@ -94,6 +100,17 @@ public MicrocksContainersEnsemble(Network network, DockerImageName image) {
94100 + ":" + MicrocksAsyncMinionContainer .MICROCKS_ASYNC_MINION_HTTP_PORT );
95101 }
96102
103+ /**
104+ * Add an environment variable to Postman runtime container.
105+ * @param key The env var name
106+ * @param value The env var value
107+ * @return self
108+ */
109+ public MicrocksContainersEnsemble withMicrocksEnv (String key , String value ) {
110+ microcksEnvVars .put (key , value );
111+ return this ;
112+ }
113+
97114 /**
98115 * Enable the Postman runtime container with default container image.
99116 * @return self
@@ -128,6 +145,17 @@ public MicrocksContainersEnsemble withPostman(DockerImageName image) {
128145 return this ;
129146 }
130147
148+ /**
149+ * Add an environment variable to Postman runtime container.
150+ * @param key The env var name
151+ * @param value The env var value
152+ * @return self
153+ */
154+ public MicrocksContainersEnsemble withPostmanEnv (String key , String value ) {
155+ postmanEnvVars .put (key , value );
156+ return this ;
157+ }
158+
131159 /**
132160 * Enable the Async Feature container with default container image (deduced from Microcks main one).
133161 * @return self
@@ -160,6 +188,18 @@ public MicrocksContainersEnsemble withAsyncFeature(DockerImageName image) {
160188 return this ;
161189 }
162190
191+ /**
192+ * Add an environment variable to Async Minion container.
193+ * @param key The env var name
194+ * @param value The env var value
195+ * @return self
196+ */
197+ public MicrocksContainersEnsemble withAsyncMinionEnv (String key , String value ) {
198+ ensureAsyncFeatureIsEnabled ();
199+ asyncMinionEnvVars .put (key , value );
200+ return this ;
201+ }
202+
163203 /**
164204 * Once the Async Feature is enabled, connects to a Kafka broker.
165205 * @param connection Connection details to a Kafka broker.
@@ -355,11 +395,14 @@ public MicrocksAsyncMinionContainer getAsyncMinionContainer() {
355395 @ Override
356396 public void start () {
357397 // Sequential start to avoid resource contention on CI systems with weaker hardware.
398+ microcksEnvVars .forEach (microcks ::withEnv );
358399 microcks .start ();
359400 if (postman != null ) {
401+ postmanEnvVars .forEach (postman ::withEnv );
360402 postman .start ();
361403 }
362404 if (asyncMinion != null ) {
405+ asyncMinionEnvVars .forEach (asyncMinion ::withEnv );
363406 asyncMinion .start ();
364407 }
365408 }
0 commit comments