Skip to content

Commit 5881bc4

Browse files
committed
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. #1641
1 parent 7a413e6 commit 5881bc4

File tree

1 file changed

+19
-31
lines changed

1 file changed

+19
-31
lines changed

test/system/211-dbus.bats

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# shellcheck shell=bats
22
#
3-
# Copyright © 2023 – 2024 Red Hat, Inc.
3+
# Copyright © 2023 – 2025 Red Hat, Inc.
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -21,14 +21,30 @@ load 'libs/bats-support/load'
2121
load 'libs/bats-assert/load'
2222
load 'libs/helpers'
2323

24-
setup() {
24+
setup_file() {
2525
bats_require_minimum_version 1.10.0
2626
_setup_environment
2727
cleanup_all
2828
pushd "$HOME" || return 1
29+
30+
if echo "$TOOLBX_TEST_SYSTEM_TAGS" | grep "arch" >/dev/null 2>/dev/null; then
31+
create_distro_container arch latest arch-toolbox-latest
32+
fi
33+
34+
if echo "$TOOLBX_TEST_SYSTEM_TAGS" | grep "fedora" >/dev/null 2>/dev/null; then
35+
create_default_container
36+
create_distro_container fedora 34 fedora-toolbox-34
37+
create_distro_container rhel 8.10 rhel-toolbox-8.10
38+
fi
39+
40+
if echo "$TOOLBX_TEST_SYSTEM_TAGS" | grep "ubuntu" >/dev/null 2>/dev/null; then
41+
create_distro_container ubuntu 16.04 ubuntu-toolbox-16.04
42+
create_distro_container ubuntu 18.04 ubuntu-toolbox-18.04
43+
create_distro_container ubuntu 20.04 ubuntu-toolbox-20.04
44+
fi
2945
}
3046

31-
teardown() {
47+
teardown_file() {
3248
popd || return 1
3349
cleanup_all
3450
}
@@ -42,8 +58,6 @@ teardown() {
4258
--object-path /org/freedesktop/DBus \
4359
--method org.freedesktop.DBus.Peer.Ping)"
4460

45-
create_default_container
46-
4761
run --keep-empty-lines --separate-stderr "$TOOLBX" run gdbus call \
4862
--session \
4963
--dest org.freedesktop.DBus \
@@ -67,8 +81,6 @@ teardown() {
6781
--object-path /org/freedesktop/DBus \
6882
--method org.freedesktop.DBus.Peer.Ping)"
6983

70-
create_distro_container arch latest arch-toolbox-latest
71-
7284
run --keep-empty-lines --separate-stderr "$TOOLBX" run \
7385
--distro arch \
7486
gdbus call \
@@ -94,8 +106,6 @@ teardown() {
94106
--object-path /org/freedesktop/DBus \
95107
--method org.freedesktop.DBus.Peer.Ping)"
96108

97-
create_distro_container fedora 34 fedora-toolbox-34
98-
99109
run --keep-empty-lines --separate-stderr "$TOOLBX" run \
100110
--distro fedora \
101111
--release 34 \
@@ -122,8 +132,6 @@ teardown() {
122132
--object-path /org/freedesktop/DBus \
123133
--method org.freedesktop.DBus.Peer.Ping)"
124134

125-
create_distro_container rhel 8.10 rhel-toolbox-8.10
126-
127135
run --keep-empty-lines --separate-stderr "$TOOLBX" run \
128136
--distro rhel \
129137
--release 8.10 \
@@ -145,8 +153,6 @@ teardown() {
145153
@test "dbus: session bus inside Ubuntu 16.04" {
146154
busctl --user call org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.Peer Ping
147155

148-
create_distro_container ubuntu 16.04 ubuntu-toolbox-16.04
149-
150156
run --keep-empty-lines --separate-stderr "$TOOLBX" run \
151157
--distro ubuntu \
152158
--release 16.04 \
@@ -165,8 +171,6 @@ teardown() {
165171
@test "dbus: session bus inside Ubuntu 18.04" {
166172
busctl --user call org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.Peer Ping
167173

168-
create_distro_container ubuntu 18.04 ubuntu-toolbox-18.04
169-
170174
run --keep-empty-lines --separate-stderr "$TOOLBX" run \
171175
--distro ubuntu \
172176
--release 18.04 \
@@ -185,8 +189,6 @@ teardown() {
185189
@test "dbus: session bus inside Ubuntu 20.04" {
186190
busctl --user call org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.Peer Ping
187191

188-
create_distro_container ubuntu 20.04 ubuntu-toolbox-20.04
189-
190192
run --keep-empty-lines --separate-stderr "$TOOLBX" run \
191193
--distro ubuntu \
192194
--release 20.04 \
@@ -212,8 +214,6 @@ teardown() {
212214
org.freedesktop.systemd1.Manager \
213215
Version)"
214216

215-
create_default_container
216-
217217
run --keep-empty-lines --separate-stderr "$TOOLBX" run gdbus call \
218218
--system \
219219
--dest org.freedesktop.systemd1 \
@@ -241,8 +241,6 @@ teardown() {
241241
org.freedesktop.systemd1.Manager \
242242
Version)"
243243

244-
create_distro_container arch latest arch-toolbox-latest
245-
246244
run --keep-empty-lines --separate-stderr "$TOOLBX" run \
247245
--distro arch \
248246
gdbus call \
@@ -272,8 +270,6 @@ teardown() {
272270
org.freedesktop.systemd1.Manager \
273271
Version)"
274272

275-
create_distro_container fedora 34 fedora-toolbox-34
276-
277273
run --keep-empty-lines --separate-stderr "$TOOLBX" run \
278274
--distro fedora \
279275
--release 34 \
@@ -304,8 +300,6 @@ teardown() {
304300
org.freedesktop.systemd1.Manager \
305301
Version)"
306302

307-
create_distro_container rhel 8.10 rhel-toolbox-8.10
308-
309303
run --keep-empty-lines --separate-stderr "$TOOLBX" run \
310304
--distro rhel \
311305
--release 8.10 \
@@ -334,8 +328,6 @@ teardown() {
334328
org.freedesktop.systemd1.Manager \
335329
Version)"
336330

337-
create_distro_container ubuntu 16.04 ubuntu-toolbox-16.04
338-
339331
run --keep-empty-lines --separate-stderr "$TOOLBX" run \
340332
--distro ubuntu \
341333
--release 16.04 \
@@ -362,8 +354,6 @@ teardown() {
362354
org.freedesktop.systemd1.Manager \
363355
Version)"
364356

365-
create_distro_container ubuntu 18.04 ubuntu-toolbox-18.04
366-
367357
run --keep-empty-lines --separate-stderr "$TOOLBX" run \
368358
--distro ubuntu \
369359
--release 18.04 \
@@ -390,8 +380,6 @@ teardown() {
390380
org.freedesktop.systemd1.Manager \
391381
Version)"
392382

393-
create_distro_container ubuntu 20.04 ubuntu-toolbox-20.04
394-
395383
run --keep-empty-lines --separate-stderr "$TOOLBX" run \
396384
--distro ubuntu \
397385
--release 20.04 \

0 commit comments

Comments
 (0)