Skip to content

Commit 69d6b11

Browse files
committed
test/system: Optimize the help 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 tests for toolbox(1) invocations forwarded to the host, which includes the help tests, are particularly slow because they never skip the I/O. This makes them a good target for optimizations. The help tests for toolbox(1) invocations forwarded to the host use the same default Toolbx container to invoke toolbox(1) from without changing its state. Therefore, a lot of disk I/O can be avoided by creating the default container only once for all those tests. This can reduce the time needed to run the help tests from almost 7 minutes to a few seconds. #1635
1 parent a062224 commit 69d6b11

File tree

1 file changed

+3
-22
lines changed

1 file changed

+3
-22
lines changed

test/system/002-help.bats

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@ load 'libs/bats-support/load'
2121
load 'libs/bats-assert/load'
2222
load 'libs/helpers.bash'
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+
create_default_container
2930
}
3031

31-
teardown() {
32+
teardown_file() {
3233
popd || return 1
3334
cleanup_all
3435
}
@@ -127,8 +128,6 @@ teardown() {
127128
}
128129

129130
@test "help: Try unknown command (forwarded to host)" {
130-
create_default_container
131-
132131
run -1 --keep-empty-lines --separate-stderr "$TOOLBX" run toolbox foo
133132

134133
assert_failure
@@ -151,8 +150,6 @@ teardown() {
151150
}
152151

153152
@test "help: Try unknown flag (forwarded to host)" {
154-
create_default_container
155-
156153
run -1 --keep-empty-lines --separate-stderr "$TOOLBX" run toolbox --foo
157154

158155
assert_failure
@@ -175,8 +172,6 @@ teardown() {
175172
}
176173

177174
@test "help: Try 'create' with unknown flag (forwarded to host)" {
178-
create_default_container
179-
180175
run -1 --keep-empty-lines --separate-stderr "$TOOLBX" run toolbox create --foo
181176

182177
assert_failure
@@ -199,8 +194,6 @@ teardown() {
199194
}
200195

201196
@test "help: Try 'enter' with unknown flag (forwarded to host)" {
202-
create_default_container
203-
204197
run -1 --keep-empty-lines --separate-stderr "$TOOLBX" run toolbox enter --foo
205198

206199
assert_failure
@@ -223,8 +216,6 @@ teardown() {
223216
}
224217

225218
@test "help: Try 'help' with unknown flag (forwarded to host)" {
226-
create_default_container
227-
228219
run -1 --keep-empty-lines --separate-stderr "$TOOLBX" run toolbox help --foo
229220

230221
assert_failure
@@ -247,8 +238,6 @@ teardown() {
247238
}
248239

249240
@test "help: Try 'init-container' with unknown flag (forwarded to host)" {
250-
create_default_container
251-
252241
run -1 --keep-empty-lines --separate-stderr "$TOOLBX" run toolbox init-container --foo
253242

254243
assert_failure
@@ -271,8 +260,6 @@ teardown() {
271260
}
272261

273262
@test "help: Try 'list' with unknown flag (forwarded to host)" {
274-
create_default_container
275-
276263
run -1 --keep-empty-lines --separate-stderr "$TOOLBX" run toolbox list --foo
277264

278265
assert_failure
@@ -295,8 +282,6 @@ teardown() {
295282
}
296283

297284
@test "help: Try 'rm' with unknown flag (forwarded to host)" {
298-
create_default_container
299-
300285
run -1 --keep-empty-lines --separate-stderr "$TOOLBX" run toolbox rm --foo
301286

302287
assert_failure
@@ -319,8 +304,6 @@ teardown() {
319304
}
320305

321306
@test "help: Try 'rmi' with unknown flag (forwarded to host)" {
322-
create_default_container
323-
324307
run -1 --keep-empty-lines --separate-stderr "$TOOLBX" run toolbox rmi --foo
325308

326309
assert_failure
@@ -343,8 +326,6 @@ teardown() {
343326
}
344327

345328
@test "help: Try 'run' with unknown flag (forwarded to host)" {
346-
create_default_container
347-
348329
run -1 --keep-empty-lines --separate-stderr "$TOOLBX" run toolbox run --foo
349330

350331
assert_failure

0 commit comments

Comments
 (0)