Skip to content
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

tests/integration: rm excessive run use; fix exec --preserve-fds test #2658

Merged
merged 3 commits into from
Nov 6, 2020

Conversation

kolyshkin
Copy link
Contributor

@kolyshkin kolyshkin commented Oct 22, 2020

1. rm excessive run use

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.

2. fix "runc exec --preserve-fds" test case

  1. Fix the check, mostly by changing cat hello to echo hello,
    and checking for "hello" (whole string) rather than *"hello"* (substring).

    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.

3. simplify teardown_running_container

In its current form, it is complicated, unreliable, and error prone (TOCTOU etc)

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.

@kolyshkin kolyshkin force-pushed the tests-ex-run branch 2 times, most recently from 20222d9 to fe04872 Compare October 22, 2020 18:25
@kolyshkin kolyshkin changed the title tests/integration: rm excessive run use tests/integration: rm excessive run use; fix exec --preserve-fds test Oct 22, 2020
@kolyshkin kolyshkin marked this pull request as ready for review October 22, 2020 18:26
giuseppe
giuseppe previously approved these changes Oct 22, 2020
Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Not a maintainer but I've introduced the issue fixed by the second commit

mrunalp
mrunalp previously approved these changes Oct 22, 2020
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>
@kolyshkin
Copy link
Contributor Author

Rebased on top of #2666 to fix CI

@kolyshkin
Copy link
Contributor Author

kolyshkin commented Oct 31, 2020

=== RUN   TestExecInTTY
2820    execin_test.go:349: unexpected carriage-return in output
2821--- FAIL: TestExecInTTY (0.10s)

Hmm I think I've seen it before...

Update: this is another time we see #2425

@kolyshkin
Copy link
Contributor Author

restarted CI

@kolyshkin
Copy link
Contributor Author

@AkihiroSuda @mrunalp PTAL

@kolyshkin
Copy link
Contributor Author

@AkihiroSuda PTAL

@AkihiroSuda AkihiroSuda merged commit 8591c33 into opencontainers:master Nov 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants