Skip to content

Commit

Permalink
can compile and use formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
YamasouA committed Dec 15, 2024
1 parent 3b66661 commit 258265f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
7 changes: 4 additions & 3 deletions tests/contest/contest/src/tests/kill/kill_test.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
use anyhow::anyhow;
use anyhow::{anyhow, Context, Result};
use oci_spec::runtime::{ProcessBuilder, Spec, SpecBuilder};
use test_framework::{Test, TestGroup, TestResult};

use crate::tests::lifecycle::ContainerLifecycle;

fn create_spec(args: &[&str]) -> Result<Spec> {
let args_vec: Vec<String> = args.iter().map(|&a| a.to_string()).collect();
let spec = SpecBuilder::default()
.process(
ProcessBuilder::default()
.args(args.iter().map(|&a| a.to_string()).collect())
.args(args_vec)
.build()
.context("failed to build process spec")?
.context("failed to build process spec")?,
)
.build()
.context("failed to build spec")?;
Expand Down
20 changes: 13 additions & 7 deletions tests/contest/contest/src/tests/lifecycle/container_lifecycle.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use std::string;
use std::thread::sleep;
use std::time::{Duration, Instant};

use anyhow::anyhow;
use oci_spec::runtime::Spec;
use test_framework::{TestResult, TestableGroup};

use super::util::criu_installed;
use super::{checkpoint, create, delete, exec, kill, start, state};
use crate::utils::{generate_uuid, prepare_bundle, get_state};
use crate::utils::{generate_uuid, get_state, prepare_bundle, set_config, State};

// By experimenting, somewhere around 50 is enough for youki process
// to get the kill signal and shut down
Expand Down Expand Up @@ -101,20 +102,25 @@ impl ContainerLifecycle {
)
}

pub fn waiting_for_status(&self, retry_timeout: Duration, poll_interval: Duration, target_status: string) -> TestResult {
pub fn waiting_for_status(
&self,
retry_timeout: Duration,
poll_interval: Duration,
target_status: String,
) -> TestResult {
let start = Instant::now();
while start.elapsed() < retry_timeout {
let (out, err) = get_state(&self.container_id, self.project_path).unwrap();
let (out, err) = get_state(&self.container_id, &self.project_path).unwrap();
if !err.is_empty() {
self.kill();
self.delete();
return TestResult::Failed(anyhow!("error in state : {}", err));
}

let state: State = serde_json::from_str(&out).unwrap();

if state.status == target_status {
return TestResult::Passed
return TestResult::Passed;
}
sleep(poll_interval);
}
Expand Down

0 comments on commit 258265f

Please sign in to comment.