tests/integration: rm excessive run use; fix exec --preserve-fds test#2658
Merged
AkihiroSuda merged 3 commits intoopencontainers:masterfrom Nov 6, 2020
Merged
tests/integration: rm excessive run use; fix exec --preserve-fds test#2658AkihiroSuda merged 3 commits intoopencontainers:masterfrom
AkihiroSuda merged 3 commits intoopencontainers:masterfrom
Conversation
20222d9 to
fe04872
Compare
giuseppe
previously approved these changes
Oct 22, 2020
fe04872 to
c30dd3f
Compare
mrunalp
previously approved these changes
Oct 22, 2020
8573f2b to
ac8e585
Compare
1. Fix the check, mostly by changing `cat hello` to `echo hello`, and checking for "hello" rather than *"hello"*. Previously, `cat hello` generated `cat: hello: no such file or directory` error message, which `run` added to `$output` and so the check for $output containing `hello` worked! 2. Simplify the test by not using the subshell and the `run`. The only catch is, fd 3 is used by bats itself, so we have to use fd 4 and thus --preserve-fds 2. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
In its current form, it is complicated, unreliable, and error prone. Using runc delete -f will kill and remove any container, running or not, and it won't error if a container with a given name does not exist. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Bats' run should only be used when we want to check both the command output and its non-zero exit status. Otherwise, we can rely on implicit exit code check (as the tests are run with set -e), or use if, etc. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
ac8e585 to
2ceb971
Compare
Contributor
Author
|
Rebased on top of #2666 to fix CI |
Contributor
Author
Hmm I think I've seen it before... Update: this is another time we see #2425 |
Contributor
Author
|
restarted CI |
Contributor
Author
|
@AkihiroSuda @mrunalp PTAL |
mrunalp
approved these changes
Nov 6, 2020
Contributor
Author
|
@AkihiroSuda PTAL |
AkihiroSuda
approved these changes
Nov 6, 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.
1. rm excessive
runuseBats' run should only be used when we want to check both the command
output and its non-zero exit status.
Otherwise, we can rely on implicit exit code check (as the tests are
run with set -e), or use if, etc.
2. fix "runc exec --preserve-fds" test case
Fix the check, mostly by changing
cat hellotoecho hello,and checking for
"hello"(whole string) rather than*"hello"*(substring).Previously,
cat hellogeneratedcat: hello: no such file or directoryerror message, which
runadded to$outputandso the check for $output containing
helloworked!Simplify the test by not using the subshell and the
run.The only catch is, fd 3 is used by bats itself, so we have to use
fd 4 and thus --preserve-fds 2.
3. simplify
teardown_running_containerIn its current form, it is complicated, unreliable, and error prone (TOCTOU etc)
Using
runc delete -fwill kill and remove any container, running or not,and it won't error if a container with a given name does not exist.