2 releases
0.1.1 | Nov 15, 2023 |
---|---|
0.1.0 | Nov 15, 2023 |
#285 in Testing
8KB
85 lines
Unofficial Rust Test Container For Redpanda
Unofficial testcontainer for Redpanda.
Add dependency:
testcontainers-redpanda-rs = "0.1"
Create and run redpanda container:
use testcontainers::clients;
use testcontainers_redpanda_rs::*;
let docker = clients::Cli::default();
let container = Redpanda::latest();
let redpanda_node = docker.run(container);
// Auto create topic is enabled by default,
// use this if you need to create a topic with
// specific number of partitions.
redpanda_node.exec(Redpanda::cmd_create_topic("new_topic", 3));
let redpanda_server_address = format!("localhost:{}", redpanda_node.get_host_port_ipv4(REDPANDA_PORT));
println!("Redpanda server: {}", redpanda_server_address);
Current limitations:
- It will use default kafka ports and only one test can at any time on given host. It was too complicated getting it right.
Dependencies
~3–4MB
~86K SLoC