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 2 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
11 changes: 9 additions & 2 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 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,14 @@ 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(|| match std::env::var("RUNTIME_KIND") {
Err(_) => true,
Ok(s) => s != "runc",
}),
Box::new(set_domainname_test),
);
tg.add(vec![Box::new(set_domainname_test)]);

tg
Expand Down
24 changes: 18 additions & 6 deletions tests/contest/contest/src/tests/scheduler/scheduler_policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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;

Expand Down Expand Up @@ -46,11 +46,23 @@ 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(|| match std::env::var("RUNTIME_KIND") {
Err(_) => true,
Ok(s) => s != "runc",
}),
Copy link
Member

Choose a reason for hiding this comment

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

How about turn into a function and putting others together?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done, please take a look!

Box::new(scheduler_policy_other_test),
);
let policy_rr_test = ConditionalTest::new(
"policy_batch",
Box::new(|| match std::env::var("RUNTIME_KIND") {
Err(_) => true,
Ok(s) => s != "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
}
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
Loading