Commit Graph

13 Commits

Author SHA1 Message Date
Kir Kolyshkin 19f76b66c1 tests/int/ps: enable for rootless
runc ps requires cgroup, but all the tests but one required root. Let's
fix this.

1. Add rootless cgroup requirement to setup() to avoid repetition.

2. Add set_cgroups_path to setup() for rootless containers because
   there is no default cgroup path.

3. Modify output checks to use $output rather than $lines because in case
   of rootless the first line of output contains the following warning:

> runc ps may fail if you don't have the full access to cgroups

4. While at it, move the common part of every test (creating the
   container and making sure it's running) to setup().

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-07-17 23:16:55 +08:00
Kir Kolyshkin d620a401d7 tests/int: remove $ROOTLESS, use $EUID
The variable $ROOTLESS, as set by helpers.bash and used in many places,
provides the same value as $EUID which is always set by bash. Since we
are using bash, we can rely on $EUID being omnipresent.

Modify all uses accordingly, and since the value is known to be a
number, omit the quoting.

Similarly, replace all uses of $(id -u) to $EUID.

Do some trivial cleanups along the way, such as
 - simplify some if A; then B; to A && B;
 - do not use [[ instead of [ where not necessary.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-03-23 11:12:44 -07:00
Kir Kolyshkin 41670e21f0 tests/int: rework/simplify setup and teardown
1. Get rid of fixed ROOT, *_BUNDLE, and CONSOLE_SOCKET dirs.
   Now they are temporary directories created in setup_bundle.

2. Automate containers cleanup: instead of having to specify all
   containers to be removed, list and destroy everything (which is
   now possible since every test case has its own unique root).

3. Randomize cgroup paths so two tests running in parallel won't
   use the same cgroup.

Now it's theoretically possible to execute tests in parallel.
Practically it's not possible yet because bats uses GNU parallel,
which do not provide a terminal for whatever it executes, and
many runc tests (all those that run containers with terminal:
true) needs a tty. This may possibly be addressed later.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-09 20:05:54 -08:00
Kir Kolyshkin 497661406e tests/int: use wait_for_container where appropriate
... instead of more generic "retry", to simplify code.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-08 12:45:44 -08:00
Kir Kolyshkin 64d5702f02 tests/int: don't depend on BUSYBOX_BUNDLE var
All the tests are run with cd to bundle directory, so
it does not make ense to explicitly specify it.

This relies on the feature of functions like set_cgroups_path
or update_config to use current directory by default.

In those cases where we need to change the directory
(runc create/run -b), save the current one and use it later.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-08 12:45:44 -08:00
Kir Kolyshkin fc8c779704 tests/integration/*.bats: reformat with shfmt
Various bats tests use various types of indentation (about half
is tabs, the rest is 2 spaces, 4 spaces, etc.).

Let's bring it to one style (tabs) using recently added
shfmt support for bats files (see [1]).

This commit is brought to you by

	shfmt -ln bats -w tests/integration/*.bats

[1] https://github.com/mvdan/sh/issues/600

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-10-11 19:15:36 -07:00
Kir Kolyshkin 4ba4baea0e tests/int/*bats: fix shellcheck SC2086, SC2006
Those are pretty simple to allow shellcheck to fix these, so
this commit is courtesy of

> shellcheck -i SC2086 -i SC2006 -f diff *.bats > fix.diff
> patch -p1 < fix.diff

repeated 3 times ;)

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-08-10 07:41:49 -07:00
lifubang 4be5435569 add integration test for ps/kill after the container stopped
Signed-off-by: lifubang <lifubang@acmcoder.com>
2020-06-06 08:57:10 +08:00
Andrei Vagin abd0515816 tests: don't call wait_for_container after synchronous operations
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-05-02 21:48:07 +03:00
Aleksa Sarai ba38383a39 tests: add rootless integration tests
This adds targets for rootless integration tests, as well as all of the
required setup in order to get the tests to run. This includes quite a
few changes, because of a lot of assumptions about things running as
root within the bats scripts (which is not true when setting up rootless
containers).

Signed-off-by: Aleksa Sarai <asarai@suse.de>
2017-03-23 20:46:22 +11:00
Aleksa Sarai 972c176ae4 tests: fix all the things
This fixes all of the tests that were broken as part of the console
rewrite. This includes fixing the integration tests that used TTY
handling inside libcontainer, as well as the bats integration tests that
needed to be rewritten to use recvtty (as they rely on detached
containers that are running).

This patch is part of the console rewrite patchset.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
2016-12-01 15:49:37 +11:00
Qiang Huang 98afb7390a Add integration test for ps command
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2016-09-29 18:33:32 +08:00
Shukui Yang 993126259c Remove the workaround which add a -- flag to runc ps command and add integration for ps -eaf
Signed-off-by: Shukui Yang <yangshukui@huawei.com>
2016-09-24 12:20:52 +08:00