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§

Modules§

  • 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
  • DynamoDB (NoSQL database) testcontainer
  • elastic_searchelastic_search
    Elasticsearch (distributed search engine) testcontainer
  • elasticmqelasticmq
    ElasticMQ (message queue) 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
    Apache Kafka (data streaming) 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 orineted middleware) testcontainer
  • neo4jneo4j
    Neo4j (graph database) testcontainer
  • openldapopenldap
    Openldap (ldap authentification) testcontainer
  • oracleoracle
    oracle (relational database) testcontainer
  • orientdborientdb
    orientdb (nosql database) testcontainer
  • 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
  • solrsolr
    Apache Solr (distributed search engine) testcontainer
  • surrealdbsurrealdb
    surrealdb (mutli model database) testcontainer
  • trufflesuite_ganacheclitrufflesuite_ganachecli
    Trufflesuite Ganache CLI (etherium simulator) testcontainer
  • victoria_metricsvictoria_metrics
    VictoriaMetrics (monitoring and time series metrics database) testcontainer
  • zookeeperzookeeper
    Apache ZooKeeper (locking and configuratin management) testcontainer