-
Notifications
You must be signed in to change notification settings - Fork 354
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
Combine test_framework and add README and guide for integration tests #360
Conversation
I have also created #361 which is a tracking issue for rest of the test. |
youki_integration_test/Cargo.toml
Outdated
[dependencies] | ||
uuid = "0.8" | ||
rand = "0.8.0" | ||
tar = "0.4" | ||
flate2 = "1.0" | ||
test_framework = { version = "0.1.0", path = "../test_framework"} | ||
test_framework = { version = "0.1.0", path = "./test_framework"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to specify the version of test_framework?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I will remove it in the update
youki_integration_test/README.md
Outdated
@@ -19,6 +19,65 @@ This provides following commandline options : | |||
- --runtime (-r) : Required. Takes path of runtime executable to be tested. If the path is not valid, the program exits. | |||
- --tests (-t) : Optional. Takes list of tests to be run, and runs only those tests. Format for it is : `test-grp-1::test-1,test-2 <space> test-grp-2 <space> test-grp-3::test-3 ...`. The test groups with no specific tests specified, (test-grp-2 in the example) , will run all of its tests, and in other cases, only selected tests will be run. Test groups not mentioned will be ignored. | |||
|
|||
## For adding tests | |||
|
|||
To create and tun tests, we use the custom test_framework, which resides in the youki_integration_test/test_framework/ . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To create and tun tests, we use the custom test_framework, which resides in the youki_integration_test/test_framework/ . | |
To create and run tests, we use the custom test_framework, which resides in the youki_integration_test/test_framework/ . |
youki_integration_test/README.md
Outdated
This also has some test utils, meant to help doing common functions in tests, which should be used whenever possible, and should be extended when some common function can be extracted. Some notable function provided are : | ||
|
||
- generate_uuid : generates a unique id for the container | ||
- prepare_bundle : creates a temp directory, and sets up the bundle and default config.json. THis folder is automatically deleted when dropped. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- prepare_bundle : creates a temp directory, and sets up the bundle and default config.json. THis folder is automatically deleted when dropped. | |
- prepare_bundle : creates a temp directory, and sets up the bundle and default config.json. This folder is automatically deleted when dropped. |
youki_integration_test/README.md
Outdated
5. Create a function which will create the custom/ default tests, Cerate a TestGroup/custom impl TestableGroup out of it, and return that. Make this function public, and `pub use` it from the mod.rs . | ||
6. In the src/main.rs, import your function, and run it to get instance of your test group, for example see lines 58-60 ish, where lifecycle, create and huge_tlb structs are created. | ||
7. Add the reference of this to the test_manager in the main function. | ||
8. Run you tests individually, run your test group individually and the run the whole suite against youki and some other production level runtime, such as runc. As said before, the important thing is to make sure runc passes it as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
8. Run you tests individually, run your test group individually and the run the whole suite against youki and some other production level runtime, such as runc. As said before, the important thing is to make sure runc passes it as well. | |
8. Run your tests individually, run your test group individually and run the whole suite against youki and some other production level runtime, such as runc. As said before, the important thing is to make sure runc passes it as well. |
youki_integration_test/README.md
Outdated
|
||
This lists some of the things that can be tricky, and can cause issues in running tests. **In case you encounter something, please update this list**. | ||
|
||
- The create commond should always have its stdout and stderror as null, and should always be waited by `wait`, and not `wait_with_output` on it after spawning. The reason is, runtime process forks itself to create the container, and then keeps running to start, get state etc for the container. Thus if we try to `wait_with_output` on it, it hangs until that process keeps running. Trying to kill tests by `Ctrl+c` will cause the system to stay in modified state ( /tmp directories, cgroup directories etc). In case you do this, and need to end tests, open a new terminal and send kill signal to the runtime process, that way it will exit, and tests will continue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The create commond should always have its stdout and stderror as null, and should always be waited by `wait`, and not `wait_with_output` on it after spawning. The reason is, runtime process forks itself to create the container, and then keeps running to start, get state etc for the container. Thus if we try to `wait_with_output` on it, it hangs until that process keeps running. Trying to kill tests by `Ctrl+c` will cause the system to stay in modified state ( /tmp directories, cgroup directories etc). In case you do this, and need to end tests, open a new terminal and send kill signal to the runtime process, that way it will exit, and tests will continue. | |
- The create command should always have its stdout and stderror as null, and should always be waited by `wait`, and not `wait_with_output` on it after spawning. The reason is, runtime process forks itself to create the container, and then keeps running to start, get state etc for the container. Thus if we try to `wait_with_output` on it, it hangs until that process keeps running. Trying to kill tests by `Ctrl+c` will cause the system to stay in modified state ( /tmp directories, cgroup directories etc). In case you do this, and need to end tests, open a new terminal and send kill signal to the runtime process, that way it will exit, and tests will continue. |
@@ -4,6 +4,8 @@ This is a simple test framework which provides various structs to setup and run | |||
|
|||
## Docs | |||
|
|||
One important thins to note here, is that all structs provided by default, TestGroup and TestManager run the individual test cases, and test groups , respectively, in parallel. Also the default Test, ConditionalTest and TestGroup structs are meant for stateless tests. For stateful tests, or for tests which need to be run in serial, please implement respective traits on custom structs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One important thins to note here, is that all structs provided by default, TestGroup and TestManager run the individual test cases, and test groups , respectively, in parallel. Also the default Test, ConditionalTest and TestGroup structs are meant for stateless tests. For stateful tests, or for tests which need to be run in serial, please implement respective traits on custom structs. | |
One important thing to note here, is that all structs provided by default, TestGroup and TestManager run the individual test cases, and test groups, respectively, in parallel. Also the default Test, ConditionalTest and TestGroup structs are meant for stateless tests. For stateful tests, or for tests which need to be run in serial, please implement respective traits on custom structs. |
Hey, so sorry for all the typos 😓 😓 I have updated the PR |
no problem :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
This moves test_framework to the youki_intergation_tests folder.
This also adds a guide for test writers as a help to add integration tests.