test/system: Optimize the D-Bus tests
The system tests can be very I/O intensive, because many of them copy OCI images from the test suite's image cache directory to its local container/storage store, create containers, and then delete everything to run the next test with a clean slate. This makes them slow. The runtime environment tests, which includes the D-Bus tests, are particularly slow because they don't skip the I/O even when testing error handling. This makes them a good target for optimizations. The D-Bus tests check if methods can be called across the user or session and system D-Bus instances from different containers without changing their state. Therefore, a lot of disk I/O can be avoided by reating these containers only once for all the tests. This can reduce the time needed to run the D-Bus tests from almost 10 minutes to almost 5 minutes. https://github.com/containers/toolbox/pull/1641
This commit is contained in:
parent
7a413e66b9
commit
5881bc43f3
|
|
@ -1,6 +1,6 @@
|
|||
# shellcheck shell=bats
|
||||
#
|
||||
# Copyright © 2023 – 2024 Red Hat, Inc.
|
||||
# Copyright © 2023 – 2025 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
|
@ -21,14 +21,30 @@ load 'libs/bats-support/load'
|
|||
load 'libs/bats-assert/load'
|
||||
load 'libs/helpers'
|
||||
|
||||
setup() {
|
||||
setup_file() {
|
||||
bats_require_minimum_version 1.10.0
|
||||
_setup_environment
|
||||
cleanup_all
|
||||
pushd "$HOME" || return 1
|
||||
|
||||
if echo "$TOOLBX_TEST_SYSTEM_TAGS" | grep "arch" >/dev/null 2>/dev/null; then
|
||||
create_distro_container arch latest arch-toolbox-latest
|
||||
fi
|
||||
|
||||
if echo "$TOOLBX_TEST_SYSTEM_TAGS" | grep "fedora" >/dev/null 2>/dev/null; then
|
||||
create_default_container
|
||||
create_distro_container fedora 34 fedora-toolbox-34
|
||||
create_distro_container rhel 8.10 rhel-toolbox-8.10
|
||||
fi
|
||||
|
||||
if echo "$TOOLBX_TEST_SYSTEM_TAGS" | grep "ubuntu" >/dev/null 2>/dev/null; then
|
||||
create_distro_container ubuntu 16.04 ubuntu-toolbox-16.04
|
||||
create_distro_container ubuntu 18.04 ubuntu-toolbox-18.04
|
||||
create_distro_container ubuntu 20.04 ubuntu-toolbox-20.04
|
||||
fi
|
||||
}
|
||||
|
||||
teardown() {
|
||||
teardown_file() {
|
||||
popd || return 1
|
||||
cleanup_all
|
||||
}
|
||||
|
|
@ -42,8 +58,6 @@ teardown() {
|
|||
--object-path /org/freedesktop/DBus \
|
||||
--method org.freedesktop.DBus.Peer.Ping)"
|
||||
|
||||
create_default_container
|
||||
|
||||
run --keep-empty-lines --separate-stderr "$TOOLBX" run gdbus call \
|
||||
--session \
|
||||
--dest org.freedesktop.DBus \
|
||||
|
|
@ -67,8 +81,6 @@ teardown() {
|
|||
--object-path /org/freedesktop/DBus \
|
||||
--method org.freedesktop.DBus.Peer.Ping)"
|
||||
|
||||
create_distro_container arch latest arch-toolbox-latest
|
||||
|
||||
run --keep-empty-lines --separate-stderr "$TOOLBX" run \
|
||||
--distro arch \
|
||||
gdbus call \
|
||||
|
|
@ -94,8 +106,6 @@ teardown() {
|
|||
--object-path /org/freedesktop/DBus \
|
||||
--method org.freedesktop.DBus.Peer.Ping)"
|
||||
|
||||
create_distro_container fedora 34 fedora-toolbox-34
|
||||
|
||||
run --keep-empty-lines --separate-stderr "$TOOLBX" run \
|
||||
--distro fedora \
|
||||
--release 34 \
|
||||
|
|
@ -122,8 +132,6 @@ teardown() {
|
|||
--object-path /org/freedesktop/DBus \
|
||||
--method org.freedesktop.DBus.Peer.Ping)"
|
||||
|
||||
create_distro_container rhel 8.10 rhel-toolbox-8.10
|
||||
|
||||
run --keep-empty-lines --separate-stderr "$TOOLBX" run \
|
||||
--distro rhel \
|
||||
--release 8.10 \
|
||||
|
|
@ -145,8 +153,6 @@ teardown() {
|
|||
@test "dbus: session bus inside Ubuntu 16.04" {
|
||||
busctl --user call org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.Peer Ping
|
||||
|
||||
create_distro_container ubuntu 16.04 ubuntu-toolbox-16.04
|
||||
|
||||
run --keep-empty-lines --separate-stderr "$TOOLBX" run \
|
||||
--distro ubuntu \
|
||||
--release 16.04 \
|
||||
|
|
@ -165,8 +171,6 @@ teardown() {
|
|||
@test "dbus: session bus inside Ubuntu 18.04" {
|
||||
busctl --user call org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.Peer Ping
|
||||
|
||||
create_distro_container ubuntu 18.04 ubuntu-toolbox-18.04
|
||||
|
||||
run --keep-empty-lines --separate-stderr "$TOOLBX" run \
|
||||
--distro ubuntu \
|
||||
--release 18.04 \
|
||||
|
|
@ -185,8 +189,6 @@ teardown() {
|
|||
@test "dbus: session bus inside Ubuntu 20.04" {
|
||||
busctl --user call org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.Peer Ping
|
||||
|
||||
create_distro_container ubuntu 20.04 ubuntu-toolbox-20.04
|
||||
|
||||
run --keep-empty-lines --separate-stderr "$TOOLBX" run \
|
||||
--distro ubuntu \
|
||||
--release 20.04 \
|
||||
|
|
@ -212,8 +214,6 @@ teardown() {
|
|||
org.freedesktop.systemd1.Manager \
|
||||
Version)"
|
||||
|
||||
create_default_container
|
||||
|
||||
run --keep-empty-lines --separate-stderr "$TOOLBX" run gdbus call \
|
||||
--system \
|
||||
--dest org.freedesktop.systemd1 \
|
||||
|
|
@ -241,8 +241,6 @@ teardown() {
|
|||
org.freedesktop.systemd1.Manager \
|
||||
Version)"
|
||||
|
||||
create_distro_container arch latest arch-toolbox-latest
|
||||
|
||||
run --keep-empty-lines --separate-stderr "$TOOLBX" run \
|
||||
--distro arch \
|
||||
gdbus call \
|
||||
|
|
@ -272,8 +270,6 @@ teardown() {
|
|||
org.freedesktop.systemd1.Manager \
|
||||
Version)"
|
||||
|
||||
create_distro_container fedora 34 fedora-toolbox-34
|
||||
|
||||
run --keep-empty-lines --separate-stderr "$TOOLBX" run \
|
||||
--distro fedora \
|
||||
--release 34 \
|
||||
|
|
@ -304,8 +300,6 @@ teardown() {
|
|||
org.freedesktop.systemd1.Manager \
|
||||
Version)"
|
||||
|
||||
create_distro_container rhel 8.10 rhel-toolbox-8.10
|
||||
|
||||
run --keep-empty-lines --separate-stderr "$TOOLBX" run \
|
||||
--distro rhel \
|
||||
--release 8.10 \
|
||||
|
|
@ -334,8 +328,6 @@ teardown() {
|
|||
org.freedesktop.systemd1.Manager \
|
||||
Version)"
|
||||
|
||||
create_distro_container ubuntu 16.04 ubuntu-toolbox-16.04
|
||||
|
||||
run --keep-empty-lines --separate-stderr "$TOOLBX" run \
|
||||
--distro ubuntu \
|
||||
--release 16.04 \
|
||||
|
|
@ -362,8 +354,6 @@ teardown() {
|
|||
org.freedesktop.systemd1.Manager \
|
||||
Version)"
|
||||
|
||||
create_distro_container ubuntu 18.04 ubuntu-toolbox-18.04
|
||||
|
||||
run --keep-empty-lines --separate-stderr "$TOOLBX" run \
|
||||
--distro ubuntu \
|
||||
--release 18.04 \
|
||||
|
|
@ -390,8 +380,6 @@ teardown() {
|
|||
org.freedesktop.systemd1.Manager \
|
||||
Version)"
|
||||
|
||||
create_distro_container ubuntu 20.04 ubuntu-toolbox-20.04
|
||||
|
||||
run --keep-empty-lines --separate-stderr "$TOOLBX" run \
|
||||
--distro ubuntu \
|
||||
--release 20.04 \
|
||||
|
|
|
|||
Loading…
Reference in New Issue