beryllw commented on code in PR #624:
URL: https://github.com/apache/fluss-rust/pull/624#discussion_r3434887413
##########
crates/fluss-test-cluster/src/lib.rs:
##########
@@ -493,22 +560,47 @@ impl FlussTestingCluster {
}
pub fn stop_cluster(name: &str) {
- let prefixes = [
- format!("zookeeper-{}", name),
- format!("coordinator-server-{}", name),
- format!("tablet-server-{}-", name),
- ];
- for prefix in &prefixes {
- if let Ok(output) = std::process::Command::new("docker")
- .args(["ps", "-aq", "--filter", &format!("name={}", prefix)])
- .output()
- {
- let ids = String::from_utf8_lossy(&output.stdout);
- for id in ids.split_whitespace() {
- let _ = std::process::Command::new("docker")
- .args(["rm", "-f", id])
- .output();
- }
+ let name = name.to_string();
+ run_blocking(async move { stop_cluster_async(&name).await });
+}
+
+/// Force-removes every container of cluster `name` (matched by name prefix)
on the
+/// testcontainers daemon — the same daemon `build_detached` started them on.
+async fn stop_cluster_async(name: &str) {
+ let Some(docker) = docker_client().await else {
+ return;
+ };
+
+ // Multiple values for the `name` filter are OR'd by the daemon; these
prefixes
+ // cover zookeeper, coordinator, and any number of tablet servers.
+ let mut filters = HashMap::new();
+ filters.insert(
+ "name".to_string(),
+ vec![
+ format!("zookeeper-{name}"),
+ format!("coordinator-server-{name}"),
+ format!("tablet-server-{name}-"),
+ ],
+ );
+ let options = ListContainersOptionsBuilder::default()
+ .all(true)
+ .filters(&filters)
+ .build();
+
+ let containers = match docker.list_containers(Some(options)).await {
+ Ok(containers) => containers,
+ Err(e) => {
+ eprintln!("warning: failed to list cluster containers: {e}");
+ return;
+ }
+ };
Review Comment:
I left it inline for now since the error handling differs slightly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]