Merge pull request #5216 from estesp/testimage-429

Switch test image to a non rate-limited manifest list
This commit is contained in:
Michael Crosby 2021-03-19 15:02:47 -04:00 committed by GitHub
commit f7bd43c137
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 29 deletions

View File

@ -19,7 +19,6 @@
package containerd package containerd
import ( import (
"runtime"
"testing" "testing"
. "github.com/containerd/containerd" . "github.com/containerd/containerd"
@ -33,28 +32,11 @@ const (
) )
var ( var (
testImage string testImage = "mirror.gcr.io/library/busybox:latest"
shortCommand = withProcessArgs("true") shortCommand = withProcessArgs("true")
longCommand = withProcessArgs("/bin/sh", "-c", "while true; do sleep 1; done") longCommand = withProcessArgs("/bin/sh", "-c", "while true; do sleep 1; done")
) )
func init() {
switch runtime.GOARCH {
case "386":
testImage = "docker.io/i386/alpine:latest"
case "arm":
testImage = "docker.io/arm32v6/alpine:latest"
case "arm64":
testImage = "docker.io/arm64v8/alpine:latest"
case "ppc64le":
testImage = "docker.io/ppc64le/alpine:latest"
case "s390x":
testImage = "docker.io/s390x/alpine:latest"
default:
testImage = "docker.io/library/alpine:latest"
}
}
func TestImagePullSchema1WithEmptyLayers(t *testing.T) { func TestImagePullSchema1WithEmptyLayers(t *testing.T) {
client, err := newClient(t, address) client, err := newClient(t, address)
if err != nil { if err != nil {

View File

@ -887,10 +887,10 @@ func TestContainerUsername(t *testing.T) {
io.Copy(buf, direct.Stdout) io.Copy(buf, direct.Stdout)
}() }()
// squid user in the alpine image has a uid of 31 // the www-data user in the busybox image has a uid of 33
container, err := client.NewContainer(ctx, id, container, err := client.NewContainer(ctx, id,
WithNewSnapshot(id, image), WithNewSnapshot(id, image),
WithNewSpec(oci.WithImageConfig(image), oci.WithUsername("squid"), oci.WithProcessArgs("id", "-u")), WithNewSpec(oci.WithImageConfig(image), oci.WithUsername("www-data"), oci.WithProcessArgs("id", "-u")),
) )
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -916,16 +916,16 @@ func TestContainerUsername(t *testing.T) {
wg.Wait() wg.Wait()
output := strings.TrimSuffix(buf.String(), "\n") output := strings.TrimSuffix(buf.String(), "\n")
if output != "31" { if output != "33" {
t.Errorf("expected squid uid to be 31 but received %q", output) t.Errorf("expected www-data uid to be 33 but received %q", output)
} }
} }
func TestContainerUser(t *testing.T) { func TestContainerUser(t *testing.T) {
t.Parallel() t.Parallel()
t.Run("UserNameAndGroupName", func(t *testing.T) { testContainerUser(t, "squid:squid", "31:31") }) t.Run("UserNameAndGroupName", func(t *testing.T) { testContainerUser(t, "www-data:www-data", "33:33") })
t.Run("UserIDAndGroupName", func(t *testing.T) { testContainerUser(t, "1001:squid", "1001:31") }) t.Run("UserIDAndGroupName", func(t *testing.T) { testContainerUser(t, "1001:www-data", "1001:33") })
t.Run("UserNameAndGroupID", func(t *testing.T) { testContainerUser(t, "squid:1002", "31:1002") }) t.Run("UserNameAndGroupID", func(t *testing.T) { testContainerUser(t, "www-data:1002", "33:1002") })
t.Run("UserIDAndGroupID", func(t *testing.T) { testContainerUser(t, "1001:1002", "1001:1002") }) t.Run("UserIDAndGroupID", func(t *testing.T) { testContainerUser(t, "1001:1002", "1001:1002") })
} }
@ -1225,7 +1225,7 @@ func TestContainerUserID(t *testing.T) {
io.Copy(buf, direct.Stdout) io.Copy(buf, direct.Stdout)
}() }()
// adm user in the alpine image has a uid of 3 and gid of 4. // sys user in the busybox image has a uid and gid of 3.
container, err := client.NewContainer(ctx, id, container, err := client.NewContainer(ctx, id,
WithNewSnapshot(id, image), WithNewSnapshot(id, image),
WithNewSpec(oci.WithImageConfig(image), oci.WithUserID(3), oci.WithProcessArgs("sh", "-c", "echo $(id -u):$(id -g)")), WithNewSpec(oci.WithImageConfig(image), oci.WithUserID(3), oci.WithProcessArgs("sh", "-c", "echo $(id -u):$(id -g)")),
@ -1254,8 +1254,8 @@ func TestContainerUserID(t *testing.T) {
wg.Wait() wg.Wait()
output := strings.TrimSuffix(buf.String(), "\n") output := strings.TrimSuffix(buf.String(), "\n")
if output != "3:4" { if output != "3:3" {
t.Errorf("expected uid:gid to be 3:4, but received %q", output) t.Errorf("expected uid:gid to be 3:3, but received %q", output)
} }
} }