Skip to content

Commit

Permalink
use waiting_for_status
Browse files Browse the repository at this point in the history
  • Loading branch information
YamasouA committed Dec 15, 2024
1 parent 258265f commit 7ef3f5a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions tests/contest/contest/src/tests/kill/kill_test.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::time::Duration;

use anyhow::{anyhow, Context, Result};
use oci_spec::runtime::{ProcessBuilder, Spec, SpecBuilder};
use test_framework::{Test, TestGroup, TestResult};
Expand Down Expand Up @@ -79,6 +81,7 @@ fn kill_stopped_container_test() -> TestResult {
TestResult::Passed => {}
_ => return TestResult::Failed(anyhow!("Failed to start container")),
}
container.waiting_for_status(Duration::from_secs(10), Duration::from_secs(1), "stopped");
let result = match container.kill() {
TestResult::Failed(_) => TestResult::Passed,
TestResult::Passed => TestResult::Failed(anyhow!("Expected failure but got success")),
Expand All @@ -105,6 +108,7 @@ fn kill_start_container_test() -> TestResult {
}
_ => unreachable!(),
}
container.waiting_for_status(Duration::from_secs(10), Duration::from_secs(1), "running");
let result = container.kill();
container.delete();
result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl ContainerLifecycle {
&self,
retry_timeout: Duration,
poll_interval: Duration,
target_status: String,
target_status: &str,
) -> TestResult {
let start = Instant::now();
while start.elapsed() < retry_timeout {
Expand All @@ -124,7 +124,7 @@ impl ContainerLifecycle {
}
sleep(poll_interval);
}
return TestResult::Failed(anyhow!("error pod status is not update"));
TestResult::Failed(anyhow!("error pod status is not update"))
}
}

Expand Down

0 comments on commit 7ef3f5a

Please sign in to comment.