Skip to content

Commit cfb5a16

Browse files
committed
Add support for external embed test image list
Signed-off-by: apostasie <[email protected]>
1 parent 87a6ab9 commit cfb5a16

14 files changed

+172
-87
lines changed

pkg/testutil/images.yaml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Current schema (defined in images_linux.go) allows for ref, tag, (index) digest and platform variants.
2+
# Right now, digest and variants are not used for anything, but they should / could be in the future.
3+
# Also note that changing the schema should be easy and straight-forward for now, so,
4+
# this might evolve in the near future.
5+
alpine:
6+
ref: "ghcr.io/stargz-containers/alpine"
7+
tag: "3.13-org"
8+
digest: "sha256:ec14c7992a97fc11425907e908340c6c3d6ff602f5f13d899e6b7027c9b4133a"
9+
variants: ["linux/amd64", "linux/arm64"]
10+
11+
busybox:
12+
ref: "ghcr.io/containerd/busybox"
13+
tag: "1.36"
14+
15+
docker_auth:
16+
ref: "ghcr.io/stargz-containers/cesanta/docker_auth"
17+
tag: "1.7-org"
18+
19+
fluentd:
20+
ref: "fluentd"
21+
tag: "v1.18.0-debian-1.0"
22+
23+
golang:
24+
ref: "golang"
25+
tag: "1.23.8-bookworm"
26+
27+
kubo:
28+
ref: "ghcr.io/stargz-containers/ipfs/kubo"
29+
tag: "v0.16.0-org"
30+
31+
mariadb:
32+
ref: "ghcr.io/stargz-containers/mariadb"
33+
tag: "10.5-org"
34+
35+
nanoserver:
36+
ref: "mcr.microsoft.com/windows/nanoserver"
37+
tag: "ltsc2022"
38+
39+
nginx:
40+
ref: "ghcr.io/stargz-containers/nginx"
41+
tag: "1.19-alpine-org"
42+
43+
registry:
44+
ref: "ghcr.io/stargz-containers/registry"
45+
tag: "2-org"
46+
47+
stargz:
48+
ref: "ghcr.io/containerd/stargz-snapshotter"
49+
tag: "0.15.1-kind"
50+
51+
wordpress:
52+
ref: "ghcr.io/stargz-containers/wordpress"
53+
tag: "5.7-org"
54+
55+
fedora_esgz:
56+
ref: "ghcr.io/stargz-containers/fedora"
57+
tag: "30-esgz"
58+
59+
ffmpeg_soci:
60+
ref: "public.ecr.aws/soci-workshop-examples/ffmpeg"
61+
tag: "latest"
62+
63+
# Large enough for testing soci index creation
64+
ubuntu:
65+
ref: "public.ecr.aws/docker/library/ubuntu"
66+
tag: "23.10"
67+
68+
# Future: images to add or update soon.
69+
# busybox:1.37.0@sha256:37f7b378a29ceb4c551b1b5582e27747b855bbfaa73fa11914fe0df028dc581f
70+
# debian:bookworm-slim@sha256:b1211f6d19afd012477bd34fdcabb6b663d680e0f4b0537da6e6b0fd057a3ec3
71+
# gitlab/gitlab-ee:17.11.0-ee.0@sha256:e0d9d5e0d0068f4b4bac3e15eb48313b5c3bb508425645f421bf2773a964c4ae
72+
# bitnami/harbor-portal:v2.13.0@sha256:636f39610b359369aeeddd7859cb56274d9a1bc3e467e21d74ea89e1516c1a0c
73+
# mariadb:11.7.2@sha256:81e893032978c4bf8ad43710b7a979774ed90787fa32d199162148ce28fe3b76
74+
# nginx:alpine3.21@sha256:65645c7bb6a0661892a8b03b89d0743208a18dd2f3f17a54ef4b76fb8e2f2a10
75+
# wordpress:6.8.0-php8.4-fpm-alpine@sha256:309b64fa4266d8a3fe6f0973ae3172fec1023c9b18242ccf1dffbff5dc8b81a8
76+
# Right now, v3 is breaking tests.
77+
# ghcr.io/distribution/distribution:3.0.0@sha256:4ba3adf47f5c866e9a29288c758c5328ef03396cb8f5f6454463655fa8bc83e2

pkg/testutil/images_linux.go

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
Copyright The containerd Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package testutil
18+
19+
import (
20+
_ "embed"
21+
"fmt"
22+
"sync"
23+
24+
"gopkg.in/yaml.v3"
25+
)
26+
27+
//go:embed images.yaml
28+
var rawImagesList string
29+
30+
var testImagesOnce sync.Once
31+
32+
type TestImage struct {
33+
Ref string `yaml:"ref"`
34+
Tag string `yaml:"tag,omitempty"`
35+
Digest string `yaml:"digest,omitempty"`
36+
Variants []string `yaml:"variants,omitempty"`
37+
}
38+
39+
var testImages map[string]TestImage
40+
41+
func getImage(key string) string {
42+
testImagesOnce.Do(func() {
43+
if err := yaml.Unmarshal([]byte(rawImagesList), &testImages); err != nil {
44+
fmt.Printf("Error unmarshaling test images YAML file: %v\n", err)
45+
panic("testing is broken")
46+
}
47+
})
48+
49+
var im TestImage
50+
var ok bool
51+
52+
if im, ok = testImages[key]; !ok {
53+
fmt.Printf("Image %s was not found in images list\n", key)
54+
panic("testing is broken")
55+
}
56+
57+
return im.Ref + ":" + im.Tag
58+
}

pkg/testutil/nerdtest/platform/platform_darwin.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ func DataHome() (string, error) {
2323
var (
2424
// The following are here solely for darwin to compile / lint. They are not used, as the corresponding tests are running only on linux.
2525
RegistryImageStable = "registry:2"
26-
RegistryImageNext = "ghcr.io/distribution/distribution:"
2726
KuboImage = "ipfs/kubo:v0.16.0"
2827
DockerAuthImage = "cesanta/docker_auth:1.7"
2928
)

pkg/testutil/nerdtest/platform/platform_freebsd.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ func DataHome() (string, error) {
2323
var (
2424
// The following are here solely for freebsd to compile / lint. They are not used, as the corresponding tests are running only on linux.
2525
RegistryImageStable = "registry:2"
26-
RegistryImageNext = "ghcr.io/distribution/distribution:"
2726
KuboImage = "ipfs/kubo:v0.16.0"
2827
DockerAuthImage = "cesanta/docker_auth:1.7"
2928
)

pkg/testutil/nerdtest/platform/platform_linux.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ func DataHome() (string, error) {
2727

2828
var (
2929
RegistryImageStable = testutil.RegistryImageStable
30-
RegistryImageNext = testutil.RegistryImageNext
3130
KuboImage = testutil.KuboImage
3231
DockerAuthImage = testutil.DockerAuthImage
3332
)

pkg/testutil/nerdtest/platform/platform_windows.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,12 @@
1616

1717
package platform
1818

19-
import (
20-
"fmt"
21-
)
22-
2319
func DataHome() (string, error) {
2420
panic("not supported")
2521
}
2622

27-
// The following are here solely for windows to compile. They are not used, as the corresponding tests are running only on linux.
28-
func mirrorOf(s string) string {
29-
return fmt.Sprintf("ghcr.io/stargz-containers/%s-org", s)
30-
}
31-
3223
var (
33-
RegistryImageStable = mirrorOf("registry:2")
34-
RegistryImageNext = "ghcr.io/distribution/distribution:"
35-
KuboImage = mirrorOf("ipfs/kubo:v0.16.0")
36-
DockerAuthImage = mirrorOf("cesanta/docker_auth:1.7")
24+
RegistryImageStable = "there-is-no-such-test-on-windows"
25+
KuboImage = "there-is-no-such-test-on-windows"
26+
DockerAuthImage = "there-is-no-such-test-on-windows"
3727
)

pkg/testutil/nerdtest/registry/docker.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package registry
1919
import (
2020
"fmt"
2121
"net"
22-
"os"
2322
"strconv"
2423

2524
"gotest.tools/v3/assert"
@@ -71,15 +70,7 @@ func NewDockerRegistry(data test.Data, helpers test.Helpers, currentCA *testca.C
7170
// Attach authentication params returns by authenticator
7271
args = append(args, auth.Params(data)...)
7372

74-
// Get the right registry version
7573
registryImage := platform.RegistryImageStable
76-
up := os.Getenv("DISTRIBUTION_VERSION")
77-
if up != "" {
78-
if up[0:1] != "v" {
79-
up = "v" + up
80-
}
81-
registryImage = platform.RegistryImageNext + up
82-
}
8374
args = append(args, registryImage)
8475

8576
cleanup := func(data test.Data, helpers test.Helpers) {

pkg/testutil/nerdtest/requirements.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"context"
2121
"encoding/json"
2222
"fmt"
23-
"os"
2423
"os/exec"
2524
"strings"
2625

@@ -277,13 +276,6 @@ var Registry = require.All(
277276
// - when we start a large number of registries in subtests, no need to round-trip to ghcr everytime
278277
// This of course assumes that the subtests are NOT going to prune / rmi images
279278
registryImage := platform.RegistryImageStable
280-
up := os.Getenv("DISTRIBUTION_VERSION")
281-
if up != "" {
282-
if up[0:1] != "v" {
283-
up = "v" + up
284-
}
285-
registryImage = platform.RegistryImageNext + up
286-
}
287279
helpers.Ensure("pull", "--quiet", registryImage)
288280
helpers.Ensure("pull", "--quiet", platform.DockerAuthImage)
289281
helpers.Ensure("pull", "--quiet", platform.KuboImage)

pkg/testutil/testregistry/testregistry_linux.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,6 @@ type TokenAuthServer struct {
5757

5858
func EnsureImages(base *testutil.Base) {
5959
registryImage := platform.RegistryImageStable
60-
up := os.Getenv("DISTRIBUTION_VERSION")
61-
if up != "" {
62-
if up[0:1] != "v" {
63-
up = "v" + up
64-
}
65-
registryImage = platform.RegistryImageNext + up
66-
}
6760
base.Cmd("pull", "--quiet", registryImage).AssertOK()
6861
base.Cmd("pull", "--quiet", platform.DockerAuthImage).AssertOK()
6962
base.Cmd("pull", "--quiet", platform.KuboImage).AssertOK()
@@ -285,14 +278,6 @@ func NewRegistry(base *testutil.Base, ca *testca.CA, port int, auth Auth, boundC
285278

286279
args = append(args, auth.Params(base)...)
287280
registryImage := testutil.RegistryImageStable
288-
289-
up := os.Getenv("DISTRIBUTION_VERSION")
290-
if up != "" {
291-
if up[0:1] != "v" {
292-
up = "v" + up
293-
}
294-
registryImage = testutil.RegistryImageNext + up
295-
}
296281
args = append(args, registryImage)
297282

298283
cleanup := func(err error) {

pkg/testutil/testutil.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -763,8 +763,3 @@ func RegisterBuildCacheCleanup(t *testing.T) {
763763
NewBase(t).Cmd("builder", "prune", "--all", "--force").Run()
764764
})
765765
}
766-
767-
func mirrorOf(s string) string {
768-
// plain mirror, NOT stargz-converted images
769-
return fmt.Sprintf("ghcr.io/stargz-containers/%s-org", s)
770-
}

0 commit comments

Comments
 (0)