1
0
Fork 0
mirror of https://github.com/containers/youki synced 2024-05-03 22:26:32 +02:00

Refactor test dir structure (#2421)

* Move individual rust-oci-tests components in the tests dir

We can use several things from test_framework and even integration_test
for additional tests such as podman rootless and wasm tests

Signed-off-by: Yashodhan Joshi <yjdoc2@gmail.com>

* fix scripts and docs for the new dir structure

Signed-off-by: Yashodhan Joshi <yjdoc2@gmail.com>

---------

Signed-off-by: Yashodhan Joshi <yjdoc2@gmail.com>
This commit is contained in:
Yashodhan 2023-10-10 17:30:02 +05:30 committed by GitHub
parent 2cc02491c0
commit 80f1f36ae9
Signed by: GitHub
GPG Key ID: 4AEE18F83AFDEB23
71 changed files with 20 additions and 18 deletions

View File

@ -22,7 +22,9 @@ jobs:
with:
files: |
.github/workflows/integration_tests_validation.yaml
tests/rust-integration-tests/**
tests/runtimetest/**
tests/test_framework/**
tests/integration_test/**
files_ignore: |
**.md
- name: List all changed files

View File

@ -1,6 +1,6 @@
[workspace]
resolver = "2"
members = ["tests/rust-integration-tests/*", "crates/*", "tools/*"]
members = ["tests/runtimetest/","tests/integration_test/","tests/test_framework/","crates/*", "tools/*"]
[profile.release]
lto = true

View File

@ -1,6 +1,6 @@
# integration_test
**Note** that these tests resides in `/tests/rust-integration-tests/integration_test/` at the time of writing.
**Note** that these tests resides in `/tests/integration_test/` at the time of writing.
This crate contains the Rust port of OCI-runtime tools integration tests, which are used to test if the runtime works as per the OCI spec or not. Initially youki used the original implementation of these test provided in the OCI repository [here](https://github.com/opencontainers/runtime-tools/tree/master/validation). But those tests are written in Go, which made the developers depend on two language environments Rust and Go to compile youki and test it. The Validation tests themselves also have an optional dependency on node js to parse their output, which can make it a third language dependency.

View File

@ -1,6 +1,6 @@
# Runtime Test
**Note** that these tests resides in /tests/rust-integration-tests/runtimetest at the time of writing.
**Note** that these tests resides in /tests/runtimetest at the time of writing.
This crate provides a binary which is used by integration tests to verify that the restrictions and constraints applied to the container are upheld by the container process, from inside the container process. This runs the tests one-by-one, and the failing test prints the error to the stderr.

View File

@ -19,7 +19,7 @@ We will not go into detail here, but will explain how to write and add a new tes
<p>
```rust,no_run,noplayground
{{#include ../../../../tests/rust-integration-tests/integration_test/src/tests/example/hello_world.rs}}
{{#include ../../../../tests/integration_test/src/tests/example/hello_world.rs}}
```
</p>
@ -33,31 +33,31 @@ We will not go into detail here, but will explain how to write and add a new tes
Therefore, it is common practice here to write an OCI Runtime Spec that executes `runtimetest`.
```rust,no_run,noplayground
{{#include ../../../../tests/rust-integration-tests/integration_test/src/tests/example/hello_world.rs:get_example_spec}}
{{#include ../../../../tests/integration_test/src/tests/example/hello_world.rs:get_example_spec}}
```
2. Prepare a function that returns a `TestResult`, which represents the result of the test.
```rust,no_run,noplayground
{{#include ../../../../tests/rust-integration-tests/integration_test/src/tests/example/hello_world.rs:example_test}}
{{#include ../../../../tests/integration_test/src/tests/example/hello_world.rs:example_test}}
```
3. Create a `TestGroup` and register a test case you created
```rust,no_run,noplayground
{{#include ../../../../tests/rust-integration-tests/integration_test/src/tests/example/hello_world.rs:get_example_test}}
{{#include ../../../../tests/integration_test/src/tests/example/hello_world.rs:get_example_test}}
```
4. Register the `TestGroup` you created to a `TestManager`
```rust,no_run,noplayground
{{#include ../../../../tests/rust-integration-tests/integration_test/src/main.rs:register_example_test}}
{{#include ../../../../tests/integration_test/src/main.rs:register_example_test}}
```
5. Write the validation you want to run within a test container
```rust,no_run,noplayground
{{#include ../../../../tests/rust-integration-tests/runtimetest/src/main.rs:example_runtimetest_main}}
{{#include ../../../../tests/runtimetest/src/main.rs:example_runtimetest_main}}
```
```rust,no_run,noplayground
{{#include ../../../../tests/rust-integration-tests/runtimetest/src/tests.rs:example_hello_world}}
{{#include ../../../../tests/runtimetest/src/tests.rs:example_hello_world}}
```

View File

@ -1,6 +1,6 @@
# test_framework
**Note** that these tests resides in /tests/rust-integration-tests/test_framework at the time of writing.
**Note** that these tests resides in /tests/test_framework at the time of writing.
This crate contains the testing framework specifically developed for porting the OCI integration test to rust. This contains structs to represent the individual tests, group of tests and a test manager that has responsibility to run tests. This Also exposes traits which can be used to implement custom test structs or test group structs if needed.

View File

@ -1,6 +1,6 @@
# Runtime Test
**Note** that these tests resides in /tests/rust-integration-tests/runtimetest at the time of writing.
**Note** that these tests resides in /tests/runtimetest at the time of writing.
This crate provides a binary which is used by integration tests to verify that the restrictions and constraints applied to the container are upheld by the container process, from inside the container process. This runs the tests one-by-one, and the failing test prints the error to the stderr.

View File

@ -20,7 +20,7 @@ ROOT=${2-$(git rev-parse --show-toplevel)}
LOGFILE="${ROOT}/test.log"
if [ ! -f ${ROOT}/bundle.tar.gz ]; then
cp ${ROOT}/tests/rust-integration-tests/integration_test/bundle.tar.gz ${ROOT}/bundle.tar.gz
cp ${ROOT}/tests/integration_test/bundle.tar.gz ${ROOT}/bundle.tar.gz
fi
touch ${LOGFILE}

View File

@ -7,8 +7,8 @@ edition = "2021"
anyhow = "1.0"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
flate2 = "1.0"
libcgroups = { path = "../../../crates/libcgroups" }
libcontainer = { path = "../../../crates/libcontainer" }
libcgroups = { path = "../../crates/libcgroups" }
libcontainer = { path = "../../crates/libcontainer" }
nix = "0.27.1"
num_cpus = "1.16"
oci-spec = { version = "0.6.1", features = ["runtime"] }

View File

@ -605,9 +605,9 @@ fn check_recursive_rsymfollow() -> TestResult {
/// this mount test how to work?
/// 1. Create mount_options based on the mount properties of the test
/// 2. Create OCI.Spec content, container one process is runtimetest,(runtimetest is cargo model, file path `tests/rust-integration-tests/runtimetest/`)
/// 2. Create OCI.Spec content, container one process is runtimetest,(runtimetest is cargo model, file path `tests/runtimetest/`)
/// 3. inside container to check if the actual mount matches the spec, (spec https://man7.org/linux/man-pages/man2/mount_setattr.2.html),
/// eg. tests/rust-integration-tests/runtimetest/src/tests.rs
/// eg. tests/runtimetest/src/tests.rs
pub fn get_mounts_recursive_test() -> TestGroup {
let rro_test = Test::new("rro_test", Box::new(check_recursive_readonly));
let rnosuid_test = Test::new("rnosuid_test", Box::new(check_recursive_nosuid));