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/int: cleanups #2757

Merged
merged 12 commits into from
Feb 24, 2021
Merged

Conversation

kolyshkin
Copy link
Contributor

@kolyshkin kolyshkin commented Jan 21, 2021

The ultimate idea is to parallelize running the integration tests.

So far just some preliminary cleanups, mostly resulting in simpler setup/cleanup
and laying the ground for parallel tests (every test is run in its own set of dirs and cgroups).

@kolyshkin kolyshkin force-pushed the test-int-cleanups branch 2 times, most recently from 747d49c to 1dd1051 Compare January 21, 2021 20:44
@kolyshkin kolyshkin changed the title [WIP] tests/int: cleanups tests/int: cleanups Jan 21, 2021
@kolyshkin kolyshkin marked this pull request as ready for review January 21, 2021 23:02
@kolyshkin
Copy link
Contributor Author

OK I guess I reached the point where I need this one and #2741 to move forward (to enable parallel bats tests execution).

@AkihiroSuda
Copy link
Member

BATS_RUN_TMPDIR (available since bats 1.2.1) is $BATS_TMPDIR/bats-run-$$
(i.e. it is per bats run and includes PID), and it is cleaned up after
the test (unless --no-tmpdir-cleanup is given).

Maybe we should error out if $BATS_RUN_TMPDIR is not set? (Does it already fail?)

@kolyshkin
Copy link
Contributor Author

Maybe we should error out if $BATS_RUN_TMPDIR is not set? (Does it already fail?)

Excellent point! Added a check.

AkihiroSuda
AkihiroSuda previously approved these changes Feb 5, 2021
@cyphar
Copy link
Member

cyphar commented Feb 5, 2021

Needs rebase.

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>
Since commit abd0515 it is no longed used.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
It is only used in a couple of places and is easy to replace
with ROOT=xxx teardown_running_container.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
All tests are run with cd to bundle directory, so
let's just use $(pwd).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
... by using retry, to avoid code duplication.

While at it, make it check the number of arguments and error out on
invalid usage.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
... instead of more generic "retry", to simplify code.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Overloading $HELLO_BUNDLE with a second purpose of having an alternative
runc root is confusing.

Instead, let's create a temp directory in setup() and clean it up in
teardown().

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
It's a little known fact, but BATS_TMPDIR is just /tmp, and it is not
being cleaned by bats after the test.

BATS_RUN_TMPDIR (available since bats 1.2.1) is $BATS_TMPDIR/bats-run-$$
(i.e. it is per bats run and includes PID), and it is cleaned up after
the test (unless --no-tmpdir-cleanup is given).

Use BATS_RUN_TMPDIR for better isolation and cleanup.

[v2: check for BATS_RUN_TMPDIR, effectively requiring bats >= 1.2.1]

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Use the value of $(pwd) as we cd to bundle dir before running a test.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
1. Do not depend on $DEBIAN_BUNDLE, instead use the current directory.

2. Simplify setup() by calling teardown().

3. In teardown(), check that LIBPATH is set.

4. Move global variables into setup.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
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>
@kolyshkin
Copy link
Contributor Author

Rebased, improved last commit description. I think this one is ready to go in.

@kolyshkin
Copy link
Contributor Author

@cyphar @mrunalp PTAL

@kolyshkin
Copy link
Contributor Author

@opencontainers/runc-maintainers can someone please merge this one (I can't merge my own PRs)

@AkihiroSuda
Copy link
Member

GitHub refusing clicking the merge button: Required statuses must pass before merging

Probably needs rebase to retrigger Go 1.16.x tests.

@AkihiroSuda AkihiroSuda reopened this Feb 24, 2021
@kolyshkin kolyshkin merged commit 6511671 into opencontainers:master Feb 24, 2021
@kolyshkin kolyshkin deleted the test-int-cleanups branch February 24, 2021 04:50
@kolyshkin
Copy link
Contributor Author

Wow, apparently I can merge my own PR if someone closes and reopens it 🤡

@AkihiroSuda
Copy link
Member

Is it a vulnerability? 😄

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