7 unstable releases (3 breaking)

0.4.0 Jun 17, 2024
0.3.1 May 29, 2024
0.2.1 Apr 30, 2024
0.1.1 Nov 15, 2023

#499 in Testing

Download history 7/week @ 2024-03-10 1/week @ 2024-03-17 29/week @ 2024-03-31 22/week @ 2024-04-07 266/week @ 2024-04-28 10/week @ 2024-05-05 306/week @ 2024-05-26 19/week @ 2024-06-02 2/week @ 2024-06-09 124/week @ 2024-06-16 3/week @ 2024-06-23

158 downloads per month

MIT license

9KB
92 lines

Unofficial Rust Test Container For Redpanda

github action Crates.io Crates.io

Unofficial testcontainer for Redpanda. Redpanda is a simple, powerful, and cost-efficient streaming data platform that is compatible with Kafka APIs but much less complex, faster and more affordable.

Note:

  • version 0.4.x supports testcontainer 0.18
  • version 0.3.x supports testcontainer 0.17
  • version 0.2.x supports testcontainer 0.16
  • version 0.1.x supports testcontainer 0.15

Add dependency:

testcontainers-redpanda-rs = { version = "0.4" }
testcontainers = { version = "0.18" }

Create and run redpanda container:

use testcontainers_redpanda_rs::*;

#[tokio::main]
async fn main() {
    let container = Redpanda::latest();

    let server_node = container.start().await.unwrap();
    let bootstrap_servers = format!("localhost:{}", server_node.get_host_port_ipv4(REDPANDA_PORT).await.unwrap());
    // if topic has only one partition this part is optional
    // it will be automatically created when client connects
    server_node.exec(Redpanda::cmd_create_topic("test_topic", 3)).await.unwrap();

    println!("Redpanda server: {}", bootstrap_servers);
}

Limitations:

  • It will use default kafka ports and only single test can run on given host.

Dependencies

~22–41MB
~739K SLoC