4 releases
0.2.1 | Apr 30, 2024 |
---|---|
0.2.0 | Apr 29, 2024 |
0.1.1 | Nov 15, 2023 |
0.1.0 | Nov 15, 2023 |
#314 in Testing
298 downloads per month
9KB
99 lines
Unofficial Rust Test Container For Redpanda
Unofficial testcontainer for Redpanda.
Note:
- version
0.2.x
supportstestcontainer
0.16
- version
0.1.x
supportstestcontainer
0.15
Add dependency:
testcontainers-redpanda-rs = { version = "0.2" }
testcontainers = { version = "0.16" }
Create and run redpanda container:
use testcontainers_redpanda_rs::*;
#[tokio::main]
async fn main() {
let container = Redpanda::latest();
let server_node = container.start().await;
let bootstrap_servers = format!("localhost:{}", server_node.get_host_port_ipv4(REDPANDA_PORT).await);
// if topic has only one partition this part is optional
// it will be automatically created when client connects
let test_topic_name = "test_topic";
server_node.exec(Redpanda::cmd_create_topic(test_topic_name, 3)).await;
println!("Redpanda server: {}", bootstrap_servers);
}
Limitations:
- It will use default kafka ports and only single test can run on given host.
Dependencies
~21–36MB
~633K SLoC