MCPcopy Index your code
hub / github.com/docker/docker-agent / TestSessionReusesAuthAcrossDigestAndImage

Function TestSessionReusesAuthAcrossDigestAndImage

pkg/remote/pull_test.go:288–312  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

286}
287
288func TestSessionReusesAuthAcrossDigestAndImage(t *testing.T) {
289 t.Parallel()
290
291 reg := newTestRegistry(t)
292 server := reg.start(t)
293
294 registry := strings.TrimPrefix(server.URL, "http://")
295 ref, err := name.ParseReference(registry + "/reuse:latest")
296 require.NoError(t, err)
297
298 s := newTestSession(t)
299
300 dig, err := s.digest(t.Context(), ref)
301 require.NoError(t, err)
302 assert.Equal(t, reg.digest, dig)
303
304 img, err := s.image(t.Context(), ref)
305 require.NoError(t, err)
306 _, err = img.Manifest()
307 require.NoError(t, err)
308
309 // digest (HEAD) and image (GET) should share one puller, so the registry
310 // is pinged only once rather than once per crane call.
311 assert.Equal(t, int64(1), reg.pingHits.Load(), "expected a single registry ping for the shared session")
312}
313
314// TestSessionFewerRequestsThanCraneCalls is a head-to-head proof of the
315// optimization: it runs the digest + manifest steps once through the shared

Callers

nothing calls this directly

Calls 8

digestMethod · 0.80
ContextMethod · 0.80
imageMethod · 0.80
ManifestMethod · 0.80
LoadMethod · 0.80
newTestRegistryFunction · 0.70
newTestSessionFunction · 0.70
startMethod · 0.45

Tested by

no test coverage detected