Crate testcontainers_modules

Source
Expand description

§testcontainers-modules

Continuous Integration Crates.io Docs.rs

Community maintained modules for testcontainers

Provides modules to use for testing components in accordance with testcontainers-rs. Every module is treated as a feature inside this crate.

§Usage

  1. Depend on testcontainers-modules with necessary features (e.g postgres, minio and etc)
    • Enable blocking feature if you want to use modules within synchronous tests (feature-gate for SyncRunner)
  2. Then start using the modules inside your tests with either AsyncRunner or SyncRunner

Simple example of using postgres module with SyncRunner (blocking and postgres features enabled):

use testcontainers_modules::{postgres, testcontainers::runners::SyncRunner};

#[test]
fn test_with_postgres() {
    let container = postgres::Postgres::default().start().unwrap();
    let host_ip = container.get_host().unwrap();
    let host_port = container.get_host_port_ipv4(5432).unwrap();
}

Note: you don’t need to explicitly depend on testcontainers as it’s re-exported dependency of testcontainers-modules with aligned version between these crates. For example:

use testcontainers_modules::testcontainers::ImageExt;

You can also see examples for more details.

§How to override module defaults (version, tag, ENV-variables)

Just use RunnableImage:

use testcontainers_modules::{
    redis::Redis,
    testcontainers::{ContainerRequest, ImageExt}
};


/// Create a Redis module with `6.2-alpine` tag and custom password
fn create_redis() -> ContainerRequest<Redis> {
    Redis::default()
        .with_tag("6.2-alpine")
        .with_env_var("REDIS_PASSWORD", "my_secret_password")
}

§License

Please have a look at the documentation of the separate modules for examples on how to use the module.

Re-exports§

pub use testcontainers;

Modules§

anvilanvil
Anvil (local blockchain emulator for EVM-compatible development) testcontainer
azuriteazurite
Azurite (azure storage emulator) testcontainer
clickhouseclickhouse
Clickhouse (analytics database) testcontainer
cncf_distributioncncf_distribution
CNCF Distribution (container registry) testcontainer
cockroach_dbcockroach_db
CockroachDB (distributed database) testcontainer
consulconsul
Consul (identity-based networking) testcontainer
databenddatabend
Databend (analytics database) testcontainer
dexdex
Dex (OIDC provider) testcontainer
dynamodb_localdynamodb
DynamoDB (NoSQL database) testcontainer
elastic_searchelastic_search
Elasticsearch (distributed search engine) testcontainer
elasticmqelasticmq
ElasticMQ (message queue) testcontainer
giteagitea
Gitea (self-hosted Git service) testcontainer
google_cloud_sdk_emulatorsgoogle_cloud_sdk_emulators
googles cloud sdk emulator testcontainer
hashicorp_vaulthashicorp_vault
HashiCorp Vault (secrets management) testcontainer
k3sk3s
K3s (lightweight kubernetes) testcontainer
kafkakafka
Apache Kafka (data streaming) testcontainer
kwokkwok
KWOK Cluster (Kubernetes WithOut Kubelet) testcontainer
localstacklocalstack
LocalStack (local AWS emulation) testcontainer
mariadbmariadb
MariaDB (relational database) testcontainer
meilisearchmeilisearch
Meilisearch (search engine) testcontainer
miniominio
minio (object storage) testcontainer
mongomongo
MongoDB (NoSql database) testcontainer
mosquittomosquitto
mosquitto (mqtt message broker) testcontainer
mssql_servermssql_server
Microsoft SQL Server (relational database) testcontainer
mysqlmysql
MySQL (relational database) testcontainer
natsnats
Nats (message oriented middleware) testcontainer
neo4jneo4j
Neo4j (graph database) testcontainer
openldapopenldap
Openldap (ldap authentification) testcontainer
oracleoracle
oracle (relational database) testcontainer
orientdborientdb
orientdb (nosql database) testcontainer
parity_parityparity
parity_parity (etherium client) testcontainer
postgrespostgres
Postgres (relational database) testcontainer
pulsarpulsar
Apache Pulsar (Cloud-Native, Distributed Messaging and Streaming) testcontainer
rabbitmqrabbitmq
rabbitmq (message broker) testcontainer
redisredis
redis (in memory nosql database) testcontainer
rqliterqlite
RQLite (lightweight, user-friendly, distributed relational database) testcontainer
solrsolr
Apache Solr (distributed search engine) testcontainer
surrealdbsurrealdb
surrealdb (mutli model database) testcontainer
trufflesuite_ganacheclitrufflesuite_ganachecli
Trufflesuite Ganache CLI (ethereum simulator) testcontainer
valkeyvalkey
Valkey (in memory nosql database) testcontainer
victoria_metricsvictoria_metrics
VictoriaMetrics (monitoring and time series metrics database) testcontainer
weaviateweaviate
Weaviate (Vector database) testcontainer
zitadelzitadel
Zitadel (identity and access management) testcontainer
zookeeperzookeeper
Apache ZooKeeper (locking and configuration management) testcontainer