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

Fix running cargo test in parallel for Jailer #4412

Open
Tracked by #1569
sudanl0 opened this issue Jan 29, 2024 · 2 comments · May be fixed by #4438
Open
Tracked by #1569

Fix running cargo test in parallel for Jailer #4412

sudanl0 opened this issue Jan 29, 2024 · 2 comments · May be fixed by #4438
Assignees
Labels
Good first issue Indicates a good issue for first-time contributors

Comments

@sudanl0
Copy link
Contributor

sudanl0 commented Jan 29, 2024

Description:

The unit tests in jailer fail when run in parallel, the result of cargo test --package jailer is as below:

failures:

---- env::tests::test_copy_cache_info stdout ----
thread 'env::tests::test_copy_cache_info' panicked at src/jailer/src/env.rs:860:31:
called `Result::unwrap()` on an `Err` value: CgroupHierarchyMissing("No hierarchy found for this cgroup version.")

---- cgroup::tests::test_cgroup_builder_v1 stdout ----
thread 'cgroup::tests::test_cgroup_builder_v1' panicked at src/jailer/src/cgroup.rs:580:17:
called `Result::unwrap()` on an `Err` value: CgroupHierarchyMissing("No hierarchy found for this cgroup version.")

---- cgroup::tests::test_cgroup_builder_v2 stdout ----
thread 'cgroup::tests::test_cgroup_builder_v2' panicked at src/jailer/src/cgroup.rs:588:17:
called `Result::unwrap()` on an `Err` value: CgroupHierarchyMissing("No hierarchy found for this cgroup version.")

---- cgroup::tests::test_cgroup_v2_write_value stdout ----
thread 'cgroup::tests::test_cgroup_v2_write_value' panicked at src/jailer/src/cgroup.rs:649:17:
called `Result::unwrap()` on an `Err` value: CgroupHierarchyMissing("No hierarchy found for this cgroup version.")

---- cgroup::tests::test_cgroup_build stdout ----
thread 'cgroup::tests::test_cgroup_build' panicked at src/jailer/src/cgroup.rs:614:54:
called `Result::unwrap()` on an `Err` value: CgroupHierarchyMissing("No hierarchy found for this cgroup version.")
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- env::tests::test_new_env stdout ----
thread 'env::tests::test_new_env' panicked at src/jailer/src/env.rs:874:35:
This new environment should be created successfully.: FileOpen("/tmp/firecracker/test/jailer/proc/mounts", Os { code: 2, kind: NotFound, message: "No such file or directory" })

---- cgroup::tests::test_cgroup_build_invalid stdout ----
thread 'cgroup::tests::test_cgroup_build_invalid' panicked at src/jailer/src/cgroup.rs:633:54:
called `Result::unwrap()` on an `Err` value: FileOpen("/tmp/firecracker/test/jailer/proc/mounts", Os { code: 2, kind: NotFound, message: "No such file or directory" })

---- env::tests::test_save_exec_file_pid stdout ----
thread 'env::tests::test_save_exec_file_pid' panicked at src/jailer/src/env.rs:860:31:
called `Result::unwrap()` on an `Err` value: FileOpen("/tmp/firecracker/test/jailer/proc/mounts", Os { code: 2, kind: NotFound, message: "No such file or directory" })

---- env::tests::test_userfaultfd_dev stdout ----
thread 'env::tests::test_userfaultfd_dev' panicked at src/jailer/src/env.rs:860:31:
called `Result::unwrap()` on an `Err` value: FileOpen("/tmp/firecracker/test/jailer/proc/mounts", Os { code: 2, kind: NotFound, message: "No such file or directory" })

---- env::tests::test_mknod_and_own_dev stdout ----
thread 'env::tests::test_mknod_and_own_dev' panicked at src/jailer/src/env.rs:860:31:
called `Result::unwrap()` on an `Err` value: FileOpen("/tmp/firecracker/test/jailer/proc/mounts", Os { code: 2, kind: NotFound, message: "No such file or directory" })

---- env::tests::test_setup_jailed_folder stdout ----
thread 'env::tests::test_setup_jailed_folder' panicked at src/jailer/src/env.rs:860:31:
called `Result::unwrap()` on an `Err` value: FileOpen("/tmp/firecracker/test/jailer/proc/mounts", Os { code: 2, kind: NotFound, message: "No such file or directory" })

---- env::tests::test_copy_exec_to_chroot stdout ----
thread 'env::tests::test_copy_exec_to_chroot' panicked at src/jailer/src/env.rs:1215:9:
assertion `left == right` failed
  left: []
 right: [115, 111, 109, 101, 95, 99, 111, 110, 116, 101, 110, 116]

---- env::tests::test_cgroups_parsing stdout ----
thread 'env::tests::test_cgroups_parsing' panicked at src/jailer/src/env.rs:1298:31:
called `Result::unwrap()` on an `Err` value: FileOpen("/tmp/firecracker/test/jailer/proc/mounts", Os { code: 2, kind: NotFound, message: "No such file or directory" })

---- cgroup::tests::test_cgroup_builder_v2_with_v1_mounts stdout ----
thread 'cgroup::tests::test_cgroup_builder_v2_with_v1_mounts' panicked at src/jailer/src/cgroup.rs:596:17:
called `Result::unwrap_err()` on an `Ok` value: CgroupBuilder { version: 2, hierarchies: {"unified": "/tmp/firecracker/test/jailer/sys_cgroup/unified"}, mount_points: [] }


failures:
    cgroup::tests::test_cgroup_build
    cgroup::tests::test_cgroup_build_invalid
    cgroup::tests::test_cgroup_builder_v1
    cgroup::tests::test_cgroup_builder_v2
    cgroup::tests::test_cgroup_builder_v2_with_v1_mounts
    cgroup::tests::test_cgroup_v2_write_value
    env::tests::test_cgroups_parsing
    env::tests::test_copy_cache_info
    env::tests::test_copy_exec_to_chroot
    env::tests::test_mknod_and_own_dev
    env::tests::test_new_env
    env::tests::test_save_exec_file_pid
    env::tests::test_setup_jailed_folder
    env::tests::test_userfaultfd_dev

test result: FAILED. 17 passed; 14 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.26s

error: test failed, to rerun pass `-p jailer --bin jailer`
root@cff916670245:/firecracker# 

The tests run successfully when run serially with this command : cargo test --package jailer -- --test-threads=1

Action item

To fix the unit tests so they can run in parallel.

Acceptance criteria

PR with the fix to run cargo test --package jailer command without any errors.

@sudanl0 sudanl0 added the Good first issue Indicates a good issue for first-time contributors label Jan 29, 2024
@cm-iwata
Copy link
Contributor

cm-iwata commented Feb 6, 2024

I'm interested in working on this issue.
May I work on it?

@sudanl0
Copy link
Contributor Author

sudanl0 commented Feb 6, 2024

@cm-iwata thank you for sharing your interest on this. Please feel free to work on it and post a PR when you are ready.

cm-iwata added a commit to cm-iwata/firecracker that referenced this issue Feb 9, 2024
Previously, all tests shared `/tmp/firecracker/test/jailer/proc/mounts`,
causing concurrency conflicts when running tests in multi-threaded.

Resolved test concurrency issues by incorporating random strings
into directory names.

Link: firecracker-microvm#4412

Signed-off-by: Tomoya Iwata <iwata.tomoya@classmethod.jp>
cm-iwata added a commit to cm-iwata/firecracker that referenced this issue Feb 9, 2024
Previously, all tests shared same temporary file/directory,
causing concurrency conflicts when running tests in multi-threaded.

Resolved test concurrency issues by incorporating random strings
into file/directory names.

Link: firecracker-microvm#4412

Signed-off-by: Tomoya Iwata <iwata.tomoya@classmethod.jp>
@cm-iwata cm-iwata linked a pull request Feb 9, 2024 that will close this issue
9 tasks
cm-iwata added a commit to cm-iwata/firecracker that referenced this issue Feb 9, 2024
Link: firecracker-microvm#4412

Signed-off-by: Tomoya Iwata <iwata.tomoya@classmethod.jp>
cm-iwata added a commit to cm-iwata/firecracker that referenced this issue Feb 13, 2024
Previously, all tests shared same temporary file/directory,
causing concurrency conflicts when running tests in multi-threaded.

Resolved test concurrency issues by incorporating random strings
into file/directory names.

Link: firecracker-microvm#4412

Signed-off-by: Tomoya Iwata <iwata.tomoya@classmethod.jp>
cm-iwata added a commit to cm-iwata/firecracker that referenced this issue Feb 13, 2024
Previously, all tests shared same temporary file/directory,
causing concurrency conflicts when running tests in multi-threaded.

Resolved test concurrency issues by incorporating random strings
into file/directory names.

Link: firecracker-microvm#4412

Signed-off-by: Tomoya Iwata <iwata.tomoya@classmethod.jp>
cm-iwata added a commit to cm-iwata/firecracker that referenced this issue Feb 13, 2024
Previously, all tests shared same temporary file/directory,
causing concurrency conflicts when running tests in multi-threaded.

Resolved test concurrency issues by incorporating random strings
into file/directory names.

Link: firecracker-microvm#4412

Signed-off-by: Tomoya Iwata <iwata.tomoya@classmethod.jp>
cm-iwata added a commit to cm-iwata/firecracker that referenced this issue Feb 13, 2024
Previously, all tests shared same temporary file/directory,
causing concurrency conflicts when running tests in multi-threaded.

Resolved test concurrency issues by incorporating random strings
into file/directory names.

Link: firecracker-microvm#4412

Signed-off-by: Tomoya Iwata <iwata.tomoya@classmethod.jp>
cm-iwata added a commit to cm-iwata/firecracker that referenced this issue Mar 14, 2024
Previously, all tests shared same temporary file/directory,
causing concurrency conflicts when running tests in multi-threaded.

Resolved test concurrency issues by incorporating random strings
into file/directory names.

Link: firecracker-microvm#4412

Signed-off-by: Tomoya Iwata <iwata.tomoya@classmethod.jp>
@sudanl0 sudanl0 changed the title Fix running cargo test in parallel for vmm Fix running cargo test in parallel for Jailer Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good first issue Indicates a good issue for first-time contributors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants