-
Notifications
You must be signed in to change notification settings - Fork 352
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
add kill test #2996
base: main
Are you sure you want to change the base?
add kill test #2996
Conversation
@YamasouA please sign your commits. The instructions can be found at https://github.com/youki-dev/youki/pull/2996/checks?check_run_id=33094881373 |
@YJDoc2 |
let kill_test = ConditionalTest::new( | ||
"test_kill_container", | ||
Box::new(|| true), | ||
Box::new(run_kill_test_cases), | ||
); |
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.
You can use normal test instead of ConditionalTest here, that will not require a conditional function.
Hey @YamasouA , thanks for the PR. I have taken a basic look, and want to request a change - Can I request you to change this code to split each test condition into its own testcase? So it will be one function for testing kill without id, one for kill non-existing container and so on. |
69d3901
to
8db2447
Compare
Signed-off-by: Akiyama <[email protected]>
Signed-off-by: Akiyama <[email protected]>
Signed-off-by: Yusuke Sakurai <[email protected]> Signed-off-by: Akiyama <[email protected]>
Signed-off-by: Akiyama <[email protected]>
Signed-off-by: Akiyama <[email protected]>
Signed-off-by: Yusuke Sakurai <[email protected]> Signed-off-by: Akiyama <[email protected]>
@YJDoc2 |
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.
overall looks ok, two things I'd request you to fix, Then I'll do the final review.
TestResult::Passed => TestResult::Failed(anyhow!("Expected failure but got success")), | ||
_ => TestResult::Failed(anyhow!("Unexpected test result")), |
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.
TestResult::Passed => TestResult::Failed(anyhow!("Expected failure but got success")), | |
_ => TestResult::Failed(anyhow!("Unexpected test result")), | |
TestResult::Passed => TestResult::Failed(anyhow!("Expected killing container with empty id to fail, but was successful")), | |
_ => TestResult::Failed(anyhow!("Unexpected test result")), |
Similarly update the failed messages in others as well.
match container.create() { | ||
TestResult::Passed => {} | ||
_ => return TestResult::Failed(anyhow!("Failed to create container")), | ||
} | ||
let result = match container.kill() { | ||
TestResult::Passed => TestResult::Passed, | ||
TestResult::Failed(_) => { | ||
TestResult::Failed(anyhow!("Expected success but got failure")) | ||
} | ||
_ => TestResult::Failed(anyhow!("Unexpected test result")), | ||
}; |
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.
I think in both these cases you can use test_result!
macro to directly return the error without having to do manual match. Same for the cases below.
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.
container.kill() return TestResult. type.
So I think we don't have to use test_result macro.
Is it true?
Signed-off-by: Akiyama <[email protected]>
@YJDoc2 |
Signed-off-by: Akiyama <[email protected]>
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.
Hey, so few things need change -
- I have left a couple of comments, please take a look.
- In the original go tests, it uses special config for stopped container and running container :
- It uses a config with command
true
which would immediately exit, and thus we get a stopped container - It uses a config with command
sleep 30
and waits 10 seconds so to make sure container is running and then attempts to kill the container for running container
In our current lifecycle impl, we do not have support for passing custom command, we always use sleep 10. So to get the correct behavior we can either modify the lifecycle impl (maybe with a new fn) to allow customizing the command, or for stopped container test, we sleep 15 seconds, then kill and for running test we sleep ~3 seconds and then kill.
- It uses a config with command
Can you check what would be better and update the test accordingly? Thanks :)
match container.create() { | ||
TestResult::Passed => {} | ||
_ => return TestResult::Failed(anyhow!("Failed to create container")), | ||
} | ||
match container.delete() { | ||
TestResult::Passed => {} | ||
_ => return TestResult::Failed(anyhow!("Failed to delete container")), | ||
} |
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.
I think here you need to call container.start
instead of delete, then wait a little, then call kill and finally delete.
fn kill_start_container_test() -> TestResult { | ||
let container = ContainerLifecycle::new(); | ||
|
||
// kill start container | ||
match container.create() { | ||
TestResult::Passed => {} | ||
_ => return TestResult::Failed(anyhow!("Failed to recreate container")), | ||
} |
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.
Is this supposed to be the last test case from original go test kill a running container
?
Signed-off-by: Akiyama <[email protected]>
Signed-off-by: Akiyama <[email protected]>
Signed-off-by: Akiyama <[email protected]>
@YJDoc2 |
part of #361
I implement kill test case in runtime-tools to youki.