Back to Youki

Contest

docs/src/developer/e2e/rust_oci_test.md

0.6.01.9 KB
Original Source

Contest

This is youki's original integration to verify the behavior of the low-level container runtime.

How to run

console
just test-contest

How to write

We will not go into detail here, but will explain how to write and add a new test case based on an example test.

<details> <summary>Fully the code of the example test</summary> <p>
rust,no_run,noplayground
{{#include ../../../../tests/contest/contest/src/tests/example/hello_world.rs}}
</p> </details>
  1. Build the OCI Runtime Spec you want to verify

    This testing framework automatically places runtimetest in the container. In other words, you can test the processes you want to execute within a container by writing them in runtimetest. Therefore, it is common practice here to write an OCI Runtime Spec that executes runtimetest.

rust,no_run,noplayground
{{#include ../../../../tests/contest/contest/src/tests/example/hello_world.rs:get_example_spec}}
  1. Prepare a function that returns a TestResult, which represents the result of the test.
rust,no_run,noplayground
{{#include ../../../../tests/contest/contest/src/tests/example/hello_world.rs:example_test}}
  1. Create a TestGroup and register a test case you created
rust,no_run,noplayground
{{#include ../../../../tests/contest/contest/src/tests/example/hello_world.rs:get_example_test}}
  1. Register the TestGroup you created to a TestManager
rust,no_run,noplayground
{{#include ../../../../tests/contest/contest/src/main.rs:register_example_test}}
  1. Write the validation you want to run within a test container
rust,no_run,noplayground
{{#include ../../../../tests/contest/runtimetest/src/main.rs:example_runtimetest_main}}
rust,no_run,noplayground
{{#include ../../../../tests/contest/runtimetest/src/tests.rs:example_hello_world}}