MCPcopy
hub / github.com/containerd/containerd / TestImagePullWithDiscardContent

Function TestImagePullWithDiscardContent

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

Source from the content-addressed store, hash-verified

235}
236
237func TestImagePullWithDiscardContent(t *testing.T) {
238 client, err := newClient(t, address)
239 if err != nil {
240 t.Fatal(err)
241 }
242 defer client.Close()
243
244 ctx, cancel := testContext(t)
245 defer cancel()
246
247 err = client.ImageService().Delete(ctx, testImage, images.SynchronousDelete())
248 if err != nil {
249 t.Fatal(err)
250 }
251
252 ls := client.LeasesService()
253 l, err := ls.Create(ctx, leases.WithRandomID(), leases.WithExpiration(24*time.Hour))
254 if err != nil {
255 t.Fatal(err)
256 }
257 ctx = leases.WithLease(ctx, l.ID)
258 img, err := client.Pull(ctx, testImage,
259 WithPlatformMatcher(platforms.Default()),
260 WithPullUnpack,
261 WithChildLabelMap(images.ChildGCLabelsFilterLayers),
262 )
263 // Synchronously garbage collect contents
264 if errL := ls.Delete(ctx, l, leases.SynchronousDelete); errL != nil {
265 t.Fatal(errL)
266 }
267 if err != nil {
268 t.Fatal(err)
269 }
270
271 // Check if all layer contents have been unpacked and aren't preserved
272 var (
273 diffIDs []digest.Digest
274 layers []digest.Digest
275 )
276 cs := client.ContentStore()
277 manifest, err := images.Manifest(ctx, cs, img.Target(), platforms.Default())
278 if err != nil {
279 t.Fatal(err)
280 }
281 if len(manifest.Layers) == 0 {
282 t.Fatalf("failed to get children from %v", img.Target())
283 }
284 for _, l := range manifest.Layers {
285 layers = append(layers, l.Digest)
286 }
287 config, err := images.Config(ctx, cs, img.Target(), platforms.Default())
288 if err != nil {
289 t.Fatal(err)
290 }
291 diffIDs, err = images.RootFS(ctx, cs, config)
292 if err != nil {
293 t.Fatal(err)
294 }

Callers

nothing calls this directly

Calls 15

WithRandomIDFunction · 0.92
WithExpirationFunction · 0.92
WithLeaseFunction · 0.92
newClientFunction · 0.85
testContextFunction · 0.85
WithPlatformMatcherFunction · 0.85
WithChildLabelMapFunction · 0.85
FatalMethod · 0.80
LeasesServiceMethod · 0.80
ManifestMethod · 0.80
CloseMethod · 0.65
DeleteMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…