tests: Prepull images used in tests

Most of the tests are pulling and deleting the same test images, which
can be quite inefficient, especially on Windows nodes, where the images
are larger than the Linux ones (a nanoserver Container image is ~250MB
in size). We can instead pull them only once, and reuse them. This will
reduce the test run time on Windows considerably.

Additionally, some of the test images are currently hosted on dockerhub
(busybox image), which has introduced image ratelimiting in November 2020,
which means that test runners could potentially hit that limit faster with
the current implementation. This will reduce that risk.

Some tests are specifically deleting images, so we always have to ensure
that they are pulled.

Signed-off-by: Claudiu Belu <cbelu@cloudbasesolutions.com>
This commit is contained in:
Claudiu Belu
2021-04-19 20:51:42 +00:00
parent feee16e0e3
commit 273c2bb168
12 changed files with 45 additions and 78 deletions

View File

@@ -46,12 +46,8 @@ func TestSharedPidMultiProcessContainerStop(t *testing.T) {
testImage = GetImage(BusyBox)
containerName = "test-container"
)
t.Logf("Pull test image %q", testImage)
img, err := imageService.PullImage(&runtime.ImageSpec{Image: testImage}, nil, sbConfig)
require.NoError(t, err)
defer func() {
assert.NoError(t, imageService.RemoveImage(&runtime.ImageSpec{Image: img}))
}()
EnsureImageExists(t, testImage)
t.Log("Create a multi-process container")
cnConfig := ContainerConfig(
@@ -90,12 +86,8 @@ func TestContainerStopCancellation(t *testing.T) {
testImage = GetImage(BusyBox)
containerName = "test-container"
)
t.Logf("Pull test image %q", testImage)
img, err := imageService.PullImage(&runtime.ImageSpec{Image: testImage}, nil, sbConfig)
require.NoError(t, err)
defer func() {
assert.NoError(t, imageService.RemoveImage(&runtime.ImageSpec{Image: img}))
}()
EnsureImageExists(t, testImage)
t.Log("Create a container which traps sigterm")
cnConfig := ContainerConfig(