MCPcopy Index your code
hub / github.com/containerd/containerd / TestImagePullSomePlatforms

Function TestImagePullSomePlatforms

integration/client/client_test.go:351–423  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

349}
350
351func TestImagePullSomePlatforms(t *testing.T) {
352 client, err := newClient(t, address)
353 if err != nil {
354 t.Fatal(err)
355 }
356 defer client.Close()
357 ctx, cancel := testContext(t)
358 defer cancel()
359
360 cs := client.ContentStore()
361 platformList := []string{"linux/amd64", "linux/arm64/v8", "linux/s390x"}
362 m := make(map[string]platforms.Matcher)
363 var opts []RemoteOpt
364
365 for _, platform := range platformList {
366 p, err := platforms.Parse(platform)
367 if err != nil {
368 t.Fatal(err)
369 }
370 m[platform] = platforms.NewMatcher(p)
371 opts = append(opts, WithPlatform(platform))
372 }
373
374 // Note: Must be different to the image used in TestImagePullAllPlatforms
375 // or it will see the content pulled by that, and fail.
376 img, err := client.Fetch(ctx, "registry.k8s.io/e2e-test-images/busybox:1.29-2", opts...)
377 if err != nil {
378 t.Fatal(err)
379 }
380
381 index := img.Target
382 manifests, err := images.Children(ctx, cs, index)
383 if err != nil {
384 t.Fatal(err)
385 }
386
387 count := 0
388 for _, manifest := range manifests {
389 children, err := images.Children(ctx, cs, manifest)
390
391 found := false
392 for _, matcher := range m {
393 if manifest.Platform == nil {
394 t.Fatal("manifest should have proper platform")
395 }
396 if matcher.Match(*manifest.Platform) {
397 count++
398 found = true
399 }
400 }
401
402 if found {
403 if len(children) == 0 {
404 t.Fatal("manifest should have pulled children content")
405 }
406
407 // check if childless data type has blob in content store
408 for _, desc := range children {

Callers

nothing calls this directly

Calls 9

newClientFunction · 0.85
testContextFunction · 0.85
FatalMethod · 0.80
CloseMethod · 0.65
ContentStoreMethod · 0.65
FetchMethod · 0.65
MatchMethod · 0.65
ReaderAtMethod · 0.65
WithPlatformFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…