Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re enable skipped e2e tests #2647

Merged
merged 3 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ test-oci:

# run rust oci integration tests
test-contest: youki-release contest
{{ cwd }}/scripts/contest.sh {{ cwd }}/youki
sudo {{ cwd }}/scripts/contest.sh {{ cwd }}/youki

# validate rust oci integration tests on runc
validate-contest-runc: contest
{{ cwd }}/scripts/contest.sh runc
sudo RUNTIME_KIND="runc" {{ cwd }}/scripts/contest.sh runc

# test podman rootless works with youki
test-rootless-podman:
Expand Down
2 changes: 1 addition & 1 deletion scripts/contest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if [ ! -f ${ROOT}/bundle.tar.gz ]; then
fi
touch ${LOGFILE}

sudo ${ROOT}/contest run --runtime "$RUNTIME" --runtimetest ${ROOT}/runtimetest > $LOGFILE
${ROOT}/contest run --runtime "$RUNTIME" --runtimetest ${ROOT}/runtimetest > $LOGFILE

if [ 0 -ne $(grep "not ok" $LOGFILE | wc -l ) ]; then
cat $LOGFILE
Expand Down
6 changes: 2 additions & 4 deletions tests/contest/contest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,9 @@ fn main() -> Result<()> {
let ro_paths = get_ro_paths_test();
let hostname = get_hostname_test();
let mounts_recursive = get_mounts_recursive_test();
#[allow(unused_variables)]
let domainname = get_domainname_tests();
let intel_rdt = get_intel_rdt_test();
let sysctl = get_sysctl_test();
#[allow(unused_variables)]
let scheduler = get_scheduler_test();

tm.add_test_group(Box::new(cl));
Expand All @@ -127,10 +125,10 @@ fn main() -> Result<()> {
tm.add_test_group(Box::new(ro_paths));
tm.add_test_group(Box::new(hostname));
tm.add_test_group(Box::new(mounts_recursive));
// tm.add_test_group(Box::new(domainname)); // TODO (YJDoc2) fix in #2616
tm.add_test_group(Box::new(domainname));
tm.add_test_group(Box::new(intel_rdt));
tm.add_test_group(Box::new(sysctl));
// tm.add_test_group(Box::new(scheduler));
tm.add_test_group(Box::new(scheduler));

tm.add_cleanup(Box::new(cgroups::cleanup_v1));
tm.add_cleanup(Box::new(cgroups::cleanup_v2));
Expand Down
10 changes: 7 additions & 3 deletions tests/contest/contest/src/tests/domainname/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::utils::test_inside_container;
use crate::utils::{is_runtime_runc, test_inside_container};
use oci_spec::runtime::{ProcessBuilder, Spec, SpecBuilder};
use test_framework::{Test, TestGroup, TestResult};
use test_framework::{ConditionalTest, TestGroup, TestResult};

fn get_spec(domainname: &str) -> Spec {
SpecBuilder::default()
Expand All @@ -25,7 +25,11 @@ fn set_domainname_test() -> TestResult {

pub fn get_domainname_tests() -> TestGroup {
let mut tg = TestGroup::new("domainname_test");
let set_domainname_test = Test::new("set_domainname_test", Box::new(set_domainname_test));
let set_domainname_test = ConditionalTest::new(
"set_domainname_test",
Box::new(|| !is_runtime_runc()),
Box::new(set_domainname_test),
);
tg.add(vec![Box::new(set_domainname_test)]);

tg
Expand Down
20 changes: 13 additions & 7 deletions tests/contest/contest/src/tests/scheduler/scheduler_policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use anyhow::{Context, Result};
use oci_spec::runtime::{
LinuxSchedulerPolicy, ProcessBuilder, SchedulerBuilder, Spec, SpecBuilder,
};
use test_framework::{test_result, Test, TestGroup, TestResult};
use test_framework::{test_result, ConditionalTest, TestGroup, TestResult};

use crate::utils::test_inside_container;
use crate::utils::{is_runtime_runc, test_inside_container};

fn create_spec(policy: LinuxSchedulerPolicy, execute_test: &str) -> Result<Spec> {
let sc = SchedulerBuilder::default()
Expand Down Expand Up @@ -46,11 +46,17 @@ fn scheduler_policy_batch_test() -> TestResult {

pub fn get_scheduler_test() -> TestGroup {
let mut scheduler_policy_group = TestGroup::new("set_scheduler_policy");
let policy_fifo_test = Test::new("policy_other", Box::new(scheduler_policy_other_test));
let policy_rr_test = Test::new("policy_batch", Box::new(scheduler_policy_batch_test));

scheduler_policy_group.add(vec![Box::new(policy_fifo_test)]);
scheduler_policy_group.add(vec![Box::new(policy_rr_test)]);
let policy_fifo_test = ConditionalTest::new(
"policy_other",
Box::new(|| !is_runtime_runc()),
Box::new(scheduler_policy_other_test),
);
let policy_rr_test = ConditionalTest::new(
"policy_batch",
Box::new(|| !is_runtime_runc()),
Box::new(scheduler_policy_batch_test),
);

scheduler_policy_group.add(vec![Box::new(policy_fifo_test), Box::new(policy_rr_test)]);
scheduler_policy_group
}
4 changes: 2 additions & 2 deletions tests/contest/contest/src/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pub mod support;
pub mod test_utils;
pub use support::{
generate_uuid, get_project_path, get_runtime_path, get_runtimetest_path, prepare_bundle,
set_config, set_runtime_path,
generate_uuid, get_project_path, get_runtime_path, get_runtimetest_path, is_runtime_runc,
prepare_bundle, set_config, set_runtime_path,
};
pub use test_utils::{
create_container, delete_container, get_state, kill_container, test_inside_container,
Expand Down
7 changes: 7 additions & 0 deletions tests/contest/contest/src/utils/support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,10 @@ pub fn set_config<P: AsRef<Path>>(project_path: P, config: &Spec) -> Result<()>
config.save(path)?;
Ok(())
}

pub fn is_runtime_runc() -> bool {
match std::env::var("RUNTIME_KIND") {
Err(_) => false,
Ok(s) => s == "runc",
}
}
23 changes: 5 additions & 18 deletions tests/contest/runtimetest/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use crate::utils::{self, test_read_access, test_write_access};
use anyhow::{bail, Result};
use libc::getdomainname;
use nix::errno::Errno;
use nix::unistd::getcwd;
use nix::{errno::Errno, sys::utsname, unistd::getcwd};
use oci_spec::runtime::{LinuxSchedulerPolicy, Spec};
use std::ffi::CStr;
use std::fs::{self, read_dir};
use std::mem;
use std::path::Path;
Expand Down Expand Up @@ -90,23 +87,13 @@ pub fn validate_domainname(spec: &Spec) {
return;
}

const MAX_DOMAINNAME_SIZE: usize = 254;
let actual_domainname: [i8; MAX_DOMAINNAME_SIZE] = [0; MAX_DOMAINNAME_SIZE];

// TODO (YJDoc2) : libc now has support for getdomainname, update this to use that
let ret =
unsafe { getdomainname(actual_domainname.as_ptr() as *mut i8, MAX_DOMAINNAME_SIZE) };
if ret == -1 {
eprintln!("Failed to get domainname");
}

let actual_domainname_cstr =
unsafe { CStr::from_ptr(actual_domainname.as_ptr() as *mut i8) };
if actual_domainname_cstr.to_str().unwrap() != expected_domainname {
let uname_info = utsname::uname().unwrap();
let actual_domainname = uname_info.domainname();
if actual_domainname.to_str().unwrap() != expected_domainname {
eprintln!(
"Unexpected domainname, expected: {:?} found: {:?}",
expected_domainname,
actual_domainname_cstr.to_str().unwrap()
actual_domainname.to_str().unwrap()
);
}
}
Expand Down