Skip to content

Commit

Permalink
libimage tests: try to avoid docker.io images
Browse files Browse the repository at this point in the history
These images can and will change at any time and thus can break our CI
without any external changes which is very bad. The TestPush test is
failing because it expects two not one image as it converts from docker
to oci on push. However the upstream docker.io/library/alpine was
switched to an oci image thus the test started failing as the local
storage now has the same id and just stores two different tags for the
same image.

Switch to our own controlled quay.io images where possible. This is
neither complete nor do I fully understand the tests here. I did a quick
search and replace and will see what works or not.

Signed-off-by: Paul Holzinger <[email protected]>
(cherry picked from commit 97d2614)
  • Loading branch information
Luap99 committed Dec 9, 2024
1 parent 8d156f7 commit c846f02
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion libimage/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ func TestUntag(t *testing.T) {
func getImageAndRuntime(t *testing.T) (*Runtime, *Image) {
// Note: this will resolve pull from the GCR registry (see
// testdata/registries.conf).
busyboxLatest := "docker.io/library/busybox:latest"
busyboxLatest := "quay.io/libpod/busybox:latest"

runtime := testNewRuntime(t)
ctx := context.Background()
Expand Down
2 changes: 1 addition & 1 deletion libimage/pull_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func TestPullOCINoReference(t *testing.T) {
// Exercise pulling from the OCI transport and make sure that a
// specified reference is preserved in the image name.

busybox := "docker.io/library/busybox:latest"
busybox := "quay.io/libpod/busybox:latest"
runtime := testNewRuntime(t)
ctx := context.Background()
pullOptions := &PullOptions{}
Expand Down
16 changes: 8 additions & 8 deletions libimage/push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestPush(t *testing.T) {
// Prefetch alpine.
pullOptions := &PullOptions{}
pullOptions.Writer = os.Stdout
_, err := runtime.Pull(ctx, "docker.io/library/alpine:latest", config.PullPolicyAlways, pullOptions)
_, err := runtime.Pull(ctx, "quay.io/libpod/alpine:latest", config.PullPolicyAlways, pullOptions)
require.NoError(t, err)

pushOptions := &PushOptions{}
Expand Down Expand Up @@ -81,7 +81,7 @@ func TestPushOtherPlatform(t *testing.T) {
pullOptions := &PullOptions{}
pullOptions.Writer = os.Stdout
pullOptions.Architecture = "arm64"
pulledImages, err := runtime.Pull(ctx, "docker.io/library/alpine:latest", config.PullPolicyAlways, pullOptions)
pulledImages, err := runtime.Pull(ctx, "quay.io/libpod/alpine:latest", config.PullPolicyAlways, pullOptions)
require.NoError(t, err)
require.Len(t, pulledImages, 1)

Expand All @@ -95,7 +95,7 @@ func TestPushOtherPlatform(t *testing.T) {
require.NoError(t, err)
tmp.Close()
defer os.Remove(tmp.Name())
_, err = runtime.Push(ctx, "docker.io/library/alpine:latest", "docker-archive:"+tmp.Name(), pushOptions)
_, err = runtime.Push(ctx, "quay.io/libpod/alpine:latest", "docker-archive:"+tmp.Name(), pushOptions)
require.NoError(t, err)
}

Expand All @@ -107,7 +107,7 @@ func TestPushWithForceCompression(t *testing.T) {
pullOptions := &PullOptions{}
pullOptions.Writer = os.Stdout
pullOptions.Architecture = "arm64"
pulledImages, err := runtime.Pull(ctx, "docker.io/library/alpine:latest", config.PullPolicyAlways, pullOptions)
pulledImages, err := runtime.Pull(ctx, "quay.io/libpod/alpine:latest", config.PullPolicyAlways, pullOptions)
require.NoError(t, err)
require.Len(t, pulledImages, 1)

Expand All @@ -121,7 +121,7 @@ func TestPushWithForceCompression(t *testing.T) {
pushOptions.SystemContext.DirForceDecompress = true
pushOptions.Writer = os.Stdout
dirDest := t.TempDir()
_, err = runtime.Push(ctx, "docker.io/library/alpine:latest", "dir:"+dirDest, pushOptions)
_, err = runtime.Push(ctx, "quay.io/libpod/alpine:latest", "dir:"+dirDest, pushOptions)
require.NoError(t, err)

// Pull uncompressed alpine from `dir:dirDest` as source.
Expand All @@ -137,7 +137,7 @@ func TestPushWithForceCompression(t *testing.T) {
pushOptions.OciAcceptUncompressedLayers = true
pushOptions.Writer = os.Stdout
ociDest := t.TempDir()
_, err = runtime.Push(ctx, "docker.io/library/alpine:latest", "oci:"+ociDest, pushOptions)
_, err = runtime.Push(ctx, "quay.io/libpod/alpine:latest", "oci:"+ociDest, pushOptions)
require.NoError(t, err)

// blobs from first push
Expand All @@ -154,7 +154,7 @@ func TestPushWithForceCompression(t *testing.T) {
pushOptions.Writer = os.Stdout
pushOptions.CompressionFormat = &compression.Gzip
pushOptions.ForceCompressionFormat = false
_, err = runtime.Push(ctx, "docker.io/library/alpine:latest", "oci:"+ociDest, pushOptions)
_, err = runtime.Push(ctx, "quay.io/libpod/alpine:latest", "oci:"+ociDest, pushOptions)
require.NoError(t, err)

// blobs from second push
Expand All @@ -175,7 +175,7 @@ func TestPushWithForceCompression(t *testing.T) {
pushOptions.Writer = os.Stdout
pushOptions.CompressionFormat = &compression.Gzip
pushOptions.ForceCompressionFormat = true
_, err = runtime.Push(ctx, "docker.io/library/alpine:latest", "oci:"+ociDest, pushOptions)
_, err = runtime.Push(ctx, "quay.io/libpod/alpine:latest", "oci:"+ociDest, pushOptions)
require.NoError(t, err)

// collect blobs from third push
Expand Down
2 changes: 1 addition & 1 deletion libimage/remove_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
func TestRemoveImages(t *testing.T) {
// Note: this will resolve pull from the GCR registry (see
// testdata/registries.conf).
busyboxLatest := "docker.io/library/busybox:latest"
busyboxLatest := "quay.io/libpod/busybox:latest"

runtime := testNewRuntime(t)
ctx := context.Background()
Expand Down
14 changes: 7 additions & 7 deletions libimage/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ func TestRuntimeListImagesAllImages(t *testing.T) {
ctx := context.Background()

// Prefetch alpine, busybox.
testRuntimePullImage(t, runtime, ctx, "docker.io/library/alpine:latest")
testRuntimePullImage(t, runtime, ctx, "docker.io/library/busybox:latest")
testRuntimePullImage(t, runtime, ctx, "quay.io/libpod/alpine:latest")
testRuntimePullImage(t, runtime, ctx, "quay.io/libpod/busybox:latest")

images, err := runtime.ListImages(ctx, nil)
require.NoError(t, err)
Expand All @@ -122,7 +122,7 @@ func TestRuntimeListImagesAllImages(t *testing.T) {
}
assert.ElementsMatch(t,
image_names,
[]string{"docker.io/library/alpine:latest", "docker.io/library/busybox:latest"},
[]string{"quay.io/libpod/alpine:latest", "quay.io/libpod/busybox:latest"},
)
}

Expand All @@ -131,15 +131,15 @@ func TestRuntimeListImagesByNames(t *testing.T) {
ctx := context.Background()

// Prefetch alpine, busybox.
testRuntimePullImage(t, runtime, ctx, "docker.io/library/alpine:latest")
testRuntimePullImage(t, runtime, ctx, "docker.io/library/busybox:latest")
testRuntimePullImage(t, runtime, ctx, "quay.io/libpod/alpine:latest")
testRuntimePullImage(t, runtime, ctx, "quay.io/libpod/busybox:latest")

for _, test := range []struct {
name string
fullName string
}{
{"alpine", "docker.io/library/alpine:latest"},
{"busybox", "docker.io/library/busybox:latest"},
{"alpine", "quay.io/libpod/alpine:latest"},
{"busybox", "quay.io/libpod/busybox:latest"},
} {
images, err := runtime.ListImagesByNames([]string{test.name})
require.NoError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions libimage/save_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ func TestSave(t *testing.T) {
// Prefetch alpine, busybox.
pullOptions := &PullOptions{}
pullOptions.Writer = os.Stdout
_, err := runtime.Pull(ctx, "docker.io/library/alpine:latest", config.PullPolicyAlways, pullOptions)
_, err := runtime.Pull(ctx, "quay.io/libpod/alpine:latest", config.PullPolicyAlways, pullOptions)
require.NoError(t, err)
_, err = runtime.Pull(ctx, "docker.io/library/busybox:latest", config.PullPolicyAlways, pullOptions)
_, err = runtime.Pull(ctx, "quay.io/libpod/busybox:latest", config.PullPolicyAlways, pullOptions)
require.NoError(t, err)

// Save the two images into a multi-image archive. This way, we can
Expand Down

0 comments on commit c846f02

Please sign in to comment.