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:
@@ -135,11 +135,7 @@ func TestContainerdRestart(t *testing.T) {
|
||||
|
||||
t.Logf("Pull test images")
|
||||
for _, image := range []string{GetImage(BusyBox), GetImage(Alpine)} {
|
||||
img, err := imageService.PullImage(&runtime.ImageSpec{Image: image}, nil, nil)
|
||||
require.NoError(t, err)
|
||||
defer func() {
|
||||
assert.NoError(t, imageService.RemoveImage(&runtime.ImageSpec{Image: img}))
|
||||
}()
|
||||
EnsureImageExists(t, image)
|
||||
}
|
||||
imagesBeforeRestart, err := imageService.ListImages(nil)
|
||||
assert.NoError(t, err)
|
||||
|
Reference in New Issue
Block a user