tests/integration/checkpoint.bats: fix showing errors, rm unused code#2581
Merged
Conversation
This fixes the following issue with the test: not ok 12 checkpoint --lazy-pages and restore # (in test file tests/integration/checkpoint.bats, line 202) # `[ $ret -eq 0 ]' failed ... # grep: ./work-dir/restore.log: No such file or directory One might think that `--work-path ./image-dir` is a mistake, but it's not, since `criu lazy-pages -D ./image-dir` creates a socket in ./image-dir, and then `criu restore --lazy-pages` expects a socket in the workdir. Fixes: e232a71 Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Commit 417f5ff added a code to close fds and kill processes, which should have helped in an event of test case failure. In fact, each test case is executed in a subshell, so - any variables set there can't reach teardown(); - all the fds are closed (as the process is gone). Now, I am not sure about the processes, but the code being removed has never worked anyway, so it does not make sense to keep it. Normally, those are waited for. In case of a test case failure, well, the subsequent cases might fail, too. Fixes: 417f5ff Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
For test cases where we used pipes for container's stdin/stdout/stderr, stderr was redirected to the same pipe as stdout, which practically means it is lost. These redirects to fd is needed not because we check that container is working by writing to its stdin and reading from stdout (see check_pipes), but also because bats redirects test stdout/stderr to a file, which makes c/r impossible (as the file is outside of container). This is why we can't just do something like `2>stderr.log`, and have to do what is done in this commit. Introduce and use another pipe for stdout, to be used for both runc run and runc restore, so it will be shown in case of errors. Since its handling is somewhat complicated and is used from 4 places (2 for run, 2 for restore), separate it into a helper functions. NOTE the code assumes that runc exits with non-zero exit code in case there is anything that needs to be shown to a user from runc's stderr. While at it, add error checking to runc run calls. Hopefully, this will help debug those rare checkpoint failures in CI. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Contributor
Author
|
@adrianreber @avagin PTAL |
Closed
Contributor
|
I cannot really say much about your shell pipe magic, but if it makes the test less flaky: 👍 |
AkihiroSuda
approved these changes
Sep 10, 2020
Contributor
Author
It does not. What it does is it makes print stderr in case the exit code is non-zero. Currently, stderr is appended to stdout and it is never shown, making it impossible to debug occasional CI failures (see #2475). Also, I really hate the complexity of it, but I was unable to come up with something simpler. |
mrunalp
approved these changes
Sep 15, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Another set of fixes to aim in debugging of #2475.
For previous fixes, see #2476, #2509, and #2548.
Individual commits description follows
tests/int/checkpoint: don't hide stderr
For test cases where we used pipes for container's stdin/stdout/stderr,
stderr was redirected to the same pipe as stdout, which practically
means it is lost.
These redirects to fd is needed not because we check that container is
working by writing to its stdin and reading from stdout (see
check_pipes), but also because bats redirects test stdout/stderr to a
file, which makes c/r impossible (as the file is outside of container).
This is why we can't just do something like
2>stderr.log, and haveto do what is done in this commit.
Introduce and use another pipe for stdout, to be used for both runc run
and runc restore, so it will be shown in case of errors.
Since its handling is somewhat complicated and is used from 4 places
(2 for run, 2 for restore), separate it into a helper functions.
NOTE the code assumes that runc exits with non-zero exit code in case
there is anything that needs to be shown to a user from runc's stderr.
While at it, add error checking to runc run calls.
Hopefully, this will help debug those rare checkpoint failures in CI.
tests/int/checkpoint: rm useless code
Commit 417f5ff added a code to close fds and kill processes, which
should have helped in an event of test case failure.
In fact, each test case is executed in a subshell, so
Now, I am not sure about the processes, but the code being removed
has never worked anyway, so it does not make sense to keep it.
Normally, those are waited for. In case of a test case failure,
well, the subsequent cases might fail, too.
Fixes: 417f5ff
tests/int/checkpoint.bats: fix showing logs on fail
This fixes the following issue with the test:
One might think that
--work-path ./image-diris a mistake, but it'snot, since
criu lazy-pages -D ./image-dircreates a socket in./image-dir, and thencriu restore --lazy-pagesexpects a socket inthe work-dir.
Fixes: e232a71