Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,6 @@ test-integration-%-cleanup:

test-integration-%:
$(VDEV) --verbose integration test $*
ifeq ($(AUTODESPAWN), true)
make test-integration-$*-cleanup
endif

.PHONY: test-e2e-kubernetes
test-e2e-kubernetes: ## Runs Kubernetes E2E tests
Expand Down
2 changes: 1 addition & 1 deletion vdev/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "vdev"
version = "0.3.35"
version = "0.3.36"
edition = "2024"
authors = ["Vector Contributors <vector@datadoghq.com>"]
license = "MPL-2.0"
Expand Down
27 changes: 27 additions & 0 deletions vdev/src/testing/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,31 @@ pub(crate) fn collect_compose_logs(
ComposeTest::generate(local_config, test_name, environment, 0, false)?.logs()
}

/// RAII guard that triggers test cleanup on drop unless disabled
/// by `AUTODESPAWN` or `AUTOSPAWN` environment variables.
struct AutoDespawnGuard<'a> {
test: &'a ComposeTest,
auto_despawn: bool,
}

impl<'a> AutoDespawnGuard<'a> {
pub fn new(test: &'a ComposeTest) -> Self {
let auto_despawn = std::env::var("AUTODESPAWN")
.or_else(|_| std::env::var("AUTOSPAWN"))
.map_or(true, |v| v.eq_ignore_ascii_case("true"));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kept the env parsing straightforward. If the team prefers stricter parsing (e.g., explicitly matching "1" / "0", or treating invalid strings as errors), I'm happy to adjust it to project conventions.


Self { test, auto_despawn }
}
}

impl Drop for AutoDespawnGuard<'_> {
fn drop(&mut self) {
if self.auto_despawn {
let _ = self.test.stop();
Comment thread
Captain1653 marked this conversation as resolved.
Outdated
Comment thread
Captain1653 marked this conversation as resolved.
Outdated
}
}
}

#[derive(Debug)]
pub(crate) struct ComposeTest {
local_config: ComposeTestLocalConfig,
Expand Down Expand Up @@ -240,6 +265,8 @@ impl ComposeTest {
args.push(self.retries.to_string());
}

let _auto_despawn_guard = AutoDespawnGuard::new(self);
Comment thread
Captain1653 marked this conversation as resolved.
Outdated

self.runner.test(
&env_vars,
&self.config.runner.env,
Expand Down
Loading