Skip to content

Commit

Permalink
#220 option to reuse containers (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
vasilievip authored Jun 26, 2020
1 parent e306a51 commit 61a4101
Show file tree
Hide file tree
Showing 41 changed files with 55 additions and 14 deletions.
1 change: 1 addition & 0 deletions embedded-aerospike/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
==== Consumes (via `bootstrap.properties`)

* `embedded.aerospike.enabled` `(true|false, default is 'true')`
* `embedded.aerospike.reuseContainer` `(true|false, default is 'false')`
* `embedded.aerospike.dockerImage` `(default is set to 'aerospike/aerospike-server:4.3.0.8')`
** You can pick wanted version on https://hub.docker.com/r/library/aerospike/tags/[dockerhub]
* `embedded.aerospike.waitTimeoutInSeconds` `(default is 60 seconds)`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public GenericContainer aerospike(AerospikeWaitStrategy aerospikeWaitStrategy,
.withEnv("STORAGE_GB", String.valueOf(1))
.withCreateContainerCmdModifier(cmd -> cmd.withCapAdd(Capability.NET_ADMIN))
.waitingFor(waitStrategy)
.withReuse(properties.isReuseContainer())
.withStartupTimeout(properties.getTimeoutDuration());

startAndLogTime(aerospike);
Expand Down
1 change: 1 addition & 0 deletions embedded-couchbase/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
==== Consumes (via `bootstrap.properties`)

* `embedded.couchbase.enabled` `(true|false, default is 'true')`
* `embedded.couchbase.reuseContainer` `(true|false, default is 'false')`
* `embedded.couchbase.services` `(comma separated list, default is 'INDEX,KV,QUERY,SEARCH')`
* `embedded.couchbase.bucketRamMb` `(default is set to '100')`
* `embedded.couchbase.dockerImage` `(default is set to 'couchbase/server:6.5.1')`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public CouchbaseContainer couchbase(ConfigurableEnvironment environment,
.withBucket(bucketDefinition)
.withEnabledServices(properties.getServices())
.withCredentials(properties.getUser(), properties.getPassword())
.withReuse(properties.isReuseContainer())
.withCreateContainerCmdModifier(cmd -> cmd.withCapAdd(Capability.NET_ADMIN));
couchbase.start();

Expand Down
1 change: 1 addition & 0 deletions embedded-dynamodb/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
==== Consumes (via `bootstrap.properties`)

* `embedded.dynamodb.enabled` `(true|false, default is 'true')`
* `embedded.dynamodb.reuseContainer` `(true|false, default is 'false')`
* `embedded.dynamodb.dockerImage` `(default is set to 'amazon/dynamodb-local:latest')`

==== Produces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public GenericContainer dynamoDb(ConfigurableEnvironment environment,
.withLogConsumer(containerLogsConsumer(log))
.withExposedPorts(properties.port)
.waitingFor(new HostPortWaitStrategy())
.withReuse(properties.isReuseContainer())
.withStartupTimeout(properties.getTimeoutDuration());

container.start();
Expand Down
1 change: 1 addition & 0 deletions embedded-elasticsearch/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
==== Consumes (via `bootstrap.properties`)

* `embedded.elasticsearch.enabled` `(true|false, default is 'true')`
* `embedded.elasticsearch.reuseContainer` `(true|false, default is 'false')`
* `embedded.elasticsearch.dockerImage` `(default is set to 'elasticsearch:7.7.0')`
* `embedded.elasticsearch.indices` `(indices to create, no indices are created by default)`
** You can pick wanted version on https://www.docker.elastic.co[docker.elastic.co]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ static ElasticsearchContainer create(ElasticSearchProperties properties, Logger
.withCreateContainerCmdModifier(cmd -> cmd.withCapAdd(Capability.NET_ADMIN))
.withLogConsumer(containerLogsConsumer(containerLogger))
.waitingFor(getCompositeWaitStrategy(properties))
.withReuse(properties.isReuseContainer())
.withStartupTimeout(properties.getTimeoutDuration());
}

Expand Down
1 change: 1 addition & 0 deletions embedded-google-pubsub/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
==== Consumes (via `bootstrap.properties`)

* `embedded.google.pubsub.enabled` `(true|false, default is 'true')`
* `embedded.google.pubsub.reuseContainer` `(true|false, default is 'false')`
* `embedded.google.pubsub.dockerImage` `(default is set to 'google/cloud-sdk:257.0.0')`
** You can pick wanted version on https://hub.docker.com/r/google/cloud-sdk/[dockerhub]
* `embedded.google.pubsub.host` `(default is 0.0.0.0)`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public GenericContainer pubsub(ConfigurableEnvironment environment,
)
)
.waitingFor(new LogMessageWaitStrategy().withRegEx("(?s).*started.*$"))
.withReuse(properties.isReuseContainer())
.withStartupTimeout(properties.getTimeoutDuration());

container.start();
Expand Down
1 change: 1 addition & 0 deletions embedded-influxdb/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
==== Consumes (via `bootstrap.properties`)

* `embedded.influxdb.enabled` `(boolean, true|false, default is 'true')`
* `embedded.influxdb.reuseContainer` `(boolean, true|false, default is 'false')`
* `embedded.influxdb.dockerImage` `(String, default is set to 'influxdb:1.5-alpine')`
** You can pick wanted version on dockerhub
* `embedded.influxdb.admin-user` `(String, default is 'admin')`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public ConcreteInfluxDbContainer influxdb(ConfigurableEnvironment environment,
.withDatabase(properties.getDatabase())
.withExposedPorts(properties.getPort())
.withLogConsumer(containerLogsConsumer(log))
.withReuse(properties.isReuseContainer())
.withStartupTimeout(properties.getTimeoutDuration());

influxDBContainer.waitingFor(getInfluxWaitStrategy(properties.getUser(), properties.getPassword()));
Expand Down
1 change: 1 addition & 0 deletions embedded-keycloak/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
==== Consumes (via `bootstrap.properties`)

* `embedded.keycloak.enabled` `(boolean, true|false, default is 'true')`
* `embedded.keycloak.reuseContainer` `(boolean, true|false, default is 'false')`
* `embedded.keycloak.dockerImage` `(String, default is set to 'jboss/keycloak:8.0.1')`
** You can pick wanted version on dockerhub.
* `embedded.keycloak.command` `(String[], default is '["-c", "standalone.xml", "-Dkeycloak.profile.feature.upload_scripts=enabled"]')`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public class KeycloakContainerFactory {
public KeycloakContainer newKeycloakContainer() {
log.info("Starting Keycloak server. Docker image: {}", properties.getDockerImage());

KeycloakContainer keycloak = new KeycloakContainer(properties, resourceLoader);
KeycloakContainer keycloak = new KeycloakContainer(properties, resourceLoader)
.withReuse(properties.isReuseContainer());
keycloak.start();

registerKeycloakEnvironment(keycloak);
Expand Down
1 change: 1 addition & 0 deletions embedded-localstack/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

==== Consumes (via `bootstrap.properties`)
* `embedded.localstack.enabled` `(true|false, default is 'true')`
* `embedded.localstack.reuseContainer` `(true|false, default is 'false')`
* `embedded.localstack.services` `(comma separated list of AWS services (S3, SQS, DYNAMODB, etc. Should be non empty)`
** You can choose available services on localstack
* `embedded.localstack.defaultRegion` `(default is 'us-east-1')`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public EmbeddedLocalStackContainer localStack(ConfigurableEnvironment environmen
.withEnv("DEFAULT_REGION", properties.getDefaultRegion())
.withEnv("HOSTNAME", properties.getHostname())
.withEnv("HOSTNAME_EXTERNAL", properties.getHostnameExternal())
.withEnv("USE_SSL", String.valueOf(properties.isUseSsl()));
.withEnv("USE_SSL", String.valueOf(properties.isUseSsl()))
.withReuse(properties.isReuseContainer());

for (LocalStackContainer.Service service : properties.services) {
localStackContainer.withServices(service);
Expand Down
1 change: 1 addition & 0 deletions embedded-mariadb/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
==== Consumes (via `bootstrap.properties`)

* `embedded.mariadb.enabled` `(true|false, default is 'true')`
* `embedded.mariadb.reuseContainer` `(true|false, default is 'false')`
* `embedded.mariadb.encoding` `(default is 'utf8mb4')`
* `embedded.mariadb.collation` `(default is 'utf8mb4_unicode_ci')`
* `embedded.mariadb.dockerImage` `(default is set to 'mariadb:10.3.2')`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public MariaDBContainer mariadb(ConfigurableEnvironment environment,
.withExposedPorts(properties.port)
.withCreateContainerCmdModifier(cmd -> cmd.withCapAdd(Capability.NET_ADMIN))
.withStartupTimeout(properties.getTimeoutDuration())
.withInitScript(properties.initScriptPath);
.withInitScript(properties.initScriptPath)
.withReuse(properties.isReuseContainer());
startAndLogTime(mariadb);
registerMariadbEnvironment(mariadb, environment, properties);
return mariadb;
Expand Down
1 change: 1 addition & 0 deletions embedded-memsql/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
==== Consumes (via `bootstrap.properties`)

* `embedded.memsql.enabled` `(true|false, default is 'true')`
* `embedded.memsql.reuseContainer` `(true|false, default is 'false')`
* `embedded.memsql.dockerImage` `(default is set to 'memsql/quickstart:minimal-6.0.8')`
** You can pick wanted version on https://hub.docker.com/r/memsql/quickstart/tags/[dockerhub]
* `embedded.memsql.waitTimeoutInSeconds` `(default is 60 seconds)`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public GenericContainer memsql(ConfigurableEnvironment environment,
.withCopyFileToContainer(MountableFile.forClasspathResource("mem.sql"), "/schema.sql")
.withCreateContainerCmdModifier(cmd -> cmd.withCapAdd(Capability.NET_ADMIN))
.waitingFor(memSqlStatusCheck)
.withStartupTimeout(properties.getTimeoutDuration());
.withStartupTimeout(properties.getTimeoutDuration())
.withReuse(properties.isReuseContainer());
memsql.start();
registerMemSqlEnvironment(memsql, environment, properties);
return memsql;
Expand Down
1 change: 1 addition & 0 deletions embedded-minio/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

==== Consumes (via `bootstrap.properties`)
* `embedded.minio.enabled` `(true|false, default is 'true')`
* `embedded.minio.reuseContainer` `(true|false, default is 'false')`
* `embedded.minio.dockerImage` `(default is set to 'minio/minio')`
** You can pick wanted version on https://hub.docker.com/r/minio/minio/tags[dockerhub]
* `embedded.minio.accessKey` `(default is set to 'AKIAIOSFODNN7EXAMPLE")`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public GenericContainer minio(MinioWaitStrategy minioWaitStrategy,
.withCommand("server", properties.directory)
.withCreateContainerCmdModifier(cmd -> cmd.withCapAdd(Capability.NET_ADMIN))
.waitingFor(minioWaitStrategy)
.withStartupTimeout(properties.getTimeoutDuration());
.withStartupTimeout(properties.getTimeoutDuration())
.withReuse(properties.isReuseContainer());

startAndLogTime(minio);
registerEnvironment(minio, environment, properties);
Expand Down
1 change: 1 addition & 0 deletions embedded-mongodb/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
==== Consumes (via `bootstrap.properties`)

* `embedded.mongodb.enabled` `(true|false, default is 'true')`
* `embedded.mongodb.reuseContainer` `(true|false, default is 'false')`
* `embedded.mongodb.dockerImage` `(default is set to 'mongo:4.2.0-bionic')`
** You can pick wanted version on https://hub.docker.com/_/mongo?tab=tags[dockerhub]
* `embedded.mongodb.host` `(default is localhost)`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ public GenericContainer mongodb(
.withExposedPorts(properties.getPort())
.withCreateContainerCmdModifier(cmd -> cmd.withCapAdd(Capability.NET_ADMIN))
.waitingFor(mongodbStatusCheck)
.withStartupTimeout(properties.getTimeoutDuration());
.withStartupTimeout(properties.getTimeoutDuration())
.withReuse(properties.isReuseContainer());

mongodb.start();
registerMongodbEnvironment(mongodb, environment, properties);
Expand Down
1 change: 1 addition & 0 deletions embedded-mysql/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
==== Consumes (via `bootstrap.properties`)

* `embedded.mysql.enabled` `(true|false, default is 'true')`
* `embedded.mysql.reuseContainer` `(true|false, default is 'false')`
* `embedded.mysql.encoding` `(default is 'utf8mb4')`
* `embedded.mysql.collation` `(default is 'utf8mb4_unicode_ci')`
* `embedded.mysql.dockerImage` `(default is set to 'mysql:5.7.22')`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ public MySQLContainer mysql(ConfigurableEnvironment environment,
.withExposedPorts(properties.port)
.withCreateContainerCmdModifier(cmd -> cmd.withCapAdd(Capability.NET_ADMIN))
.withStartupTimeout(properties.getTimeoutDuration())
.withInitScript(properties.initScriptPath);
.withInitScript(properties.initScriptPath)
.withReuse(properties.isReuseContainer());
startAndLogTime(mysql);
registerMySQLEnvironment(mysql, environment, properties);
return mysql;
Expand Down
1 change: 1 addition & 0 deletions embedded-neo4j/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
==== Consumes (via `bootstrap.properties`)

* `embedded.neo4j.enabled` `(true|false, default is 'true')`
* `embedded.neo4j.reuseContainer` `(true|false, default is 'false')`
* `embedded.neo4j.dockerImage` `(default is set to 'neo4j:3.2.7')`
** You can pick wanted version on https://hub.docker.com/r/library/neo4j/tags/[dockerhub]
* `embedded.neo4j.waitTimeoutInSeconds` `(default is 60 seconds)`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public Neo4jContainer neo4j(ConfigurableEnvironment environment,
.withAdminPassword(properties.password)
.withLogConsumer(containerLogsConsumer(log))
.withCreateContainerCmdModifier(cmd -> cmd.withCapAdd(Capability.NET_ADMIN))
.withStartupTimeout(properties.getTimeoutDuration());
.withStartupTimeout(properties.getTimeoutDuration())
.withReuse(properties.isReuseContainer());
neo4j.start();
registerNeo4jEnvironment(neo4j, environment, properties);
return neo4j;
Expand Down
1 change: 1 addition & 0 deletions embedded-oracle-xe/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
==== Consumes (via `bootstrap.properties`)

* `embedded.oracle.enabled` `(boolean, true|false, default is 'true')`
* `embedded.oracle.reuseContainer` `(boolean, true|false, default is 'false')`
* `embedded.oracle.waitTimeoutInSeconds` `(default is 60 seconds)`
* `embedded.oracle.dockerImage` `(String, default is set to 'oracleinanutshell/oracle-xe-11g')`
** You can pick wanted image on https://hub.docker.com/search?q=oracle-xe&type=image[dockerhub]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public OracleContainer oracle(ConfigurableEnvironment environment,
.withPassword(properties.getPassword())
.withLogConsumer(containerLogsConsumer(log))
.withStartupTimeout(properties.getTimeoutDuration())
.withInitScript(properties.initScriptPath);
.withInitScript(properties.initScriptPath)
.withReuse(properties.isReuseContainer());
oracle.start();
registerOracleEnvironment(oracle, environment, properties);
return oracle;
Expand Down
1 change: 1 addition & 0 deletions embedded-postgresql/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
==== Consumes (via `bootstrap.properties`)

* `embedded.postgresql.enabled` `(true|false, default is 'true')`
* `embedded.postgresql.reuseContainer` `(true|false, default is 'false')`
* `embedded.postgresql.dockerImage` `(default is set to 'postgres:9.6.8')`
** You can pick wanted version on https://hub.docker.com/r/library/postgres/tags/[dockerhub]
* `embedded.postgresql.waitTimeoutInSeconds` `(default is 60 seconds)`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public ConcretePostgreSQLContainer postgresql(ConfigurableEnvironment environmen
.withDatabaseName(properties.getDatabase())
.withLogConsumer(containerLogsConsumer(log))
.withStartupTimeout(properties.getTimeoutDuration())
.withInitScript(properties.initScriptPath);
.withInitScript(properties.initScriptPath)
.withReuse(properties.isReuseContainer());
postgresql.start();
registerPostgresqlEnvironment(postgresql, environment, properties);
return postgresql;
Expand Down
1 change: 1 addition & 0 deletions embedded-rabbitmq/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
==== Consumes (via `bootstrap.properties`)

* `embedded.rabbitmq.enabled` `(true|false, default is 'true')`
* `embedded.rabbitmq.reuseContainer` `(true|false, default is 'false')`
* `embedded.rabbitmq.password` `(default : rabbitmq)`
* `embedded.rabbitmq.vhost` `(virtual host, default: '/')`
* `embedded.rabbitmq.dockerImage` `(default: rabbitmq/3-management)`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public RabbitMQContainer rabbitmq(
.withEnv("RABBITMQ_DEFAULT_VHOST", properties.getVhost())
.withLogConsumer(containerLogsConsumer(log))
.withExposedPorts(properties.getPort())
.withStartupTimeout(properties.getTimeoutDuration());
.withStartupTimeout(properties.getTimeoutDuration())
.withReuse(properties.isReuseContainer());
rabbitMQ.start();
registerRabbitMQEnvironment(rabbitMQ, environment, properties);
return rabbitMQ;
Expand Down
1 change: 1 addition & 0 deletions embedded-redis/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
==== Consumes (via `bootstrap.properties`)

* `embedded.redis.enabled` `(true|false, default is 'true')`
* `embedded.redis.reuseContainer` `(true|false, default is 'false')`
* `embedded.redis.dockerImage` `(default is set to 'redis:4.0.12')`
** You can pick wanted version on https://hub.docker.com/r/library/redis/tags/[dockerhub]
* `embedded.redis.waitTimeoutInSeconds` `(default is 60 seconds)`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ public GenericContainer redis(ConfigurableEnvironment environment,
.withCopyFileToContainer(MountableFile.forClasspathResource("nodes.conf"), "/data/nodes.conf")
.withCommand("redis-server", "/data/redis.conf")
.waitingFor(redisStartupCheckStrategy)
.withStartupTimeout(properties.getTimeoutDuration());
.withStartupTimeout(properties.getTimeoutDuration())
.withReuse(properties.isReuseContainer());
startAndLogTime(redis);
Map<String, Object> redisEnv = registerRedisEnvironment(environment, redis, properties, properties.port);
log.info("Started Redis cluster. Connection details: {}", redisEnv);
Expand Down
1 change: 1 addition & 0 deletions embedded-vault/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
==== Consumes (via `bootstrap.properties`)

* `embedded.vault.enabled` `(boolean, true|false, default is 'true')`
* `embedded.vault.reuseContainer` `(boolean, true|false, default is 'false')`
* `embedded.vault.dockerImage` `(String, default is set to 'vault:1.4.0')`
** You can pick wanted version on dockerhub
* `embedded.vault.host` `(String, default is 'localhost')`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public VaultContainer vault(ConfigurableEnvironment environment, VaultProperties
.withVaultToken(properties.getToken())
.withLogConsumer(containerLogsConsumer(log))
.withExposedPorts(properties.getPort())
.withStartupTimeout(properties.getTimeoutDuration());
.withStartupTimeout(properties.getTimeoutDuration())
.withReuse(properties.isReuseContainer());

String[] secrets = properties.getSecrets().entrySet().stream()
.map(entry -> String.format("%s=%s", entry.getKey(), entry.getValue()))
Expand Down
1 change: 1 addition & 0 deletions embedded-voltdb/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
==== Consumes (via `bootstrap.properties`)

* `embedded.voltdb.enabled` `(true|false, default is 'true')`
* `embedded.voltdb.reuseContainer` `(true|false, default is 'false')`
* `embedded.voltdb.dockerImage` `(default is set to 'voltdb/voltdb-community:8.3.3')`
** You can pick wanted version on https://hub.docker.com/r/voltdb/voltdb-community/tags/[dockerhub]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ public GenericContainer voltDB(ConfigurableEnvironment environment,
.withLogConsumer(containerLogsConsumer(log))
.withExposedPorts(properties.port)
.waitingFor(voltDbStatusCheck)
.withStartupTimeout(properties.getTimeoutDuration());
.withStartupTimeout(properties.getTimeoutDuration())
.withReuse(properties.isReuseContainer());
voltDB.start();
registerVoltDBEnvironment(voltDB, environment, properties);
return voltDB;
Expand Down
Loading

0 comments on commit 61a4101

Please sign in to comment.