Ejemplo n.º 1
0
        public async Task TestPullAsync()
        {
            // Pulls the busybox image.
            localRegistry.PullAndPushToLocal("busybox", "busybox");
            RegistryClient registryClient =
                RegistryClient.CreateFactory(EventHandlers.NONE, "localhost:5000", "busybox")
                .SetAllowInsecureRegistries(true)
                .NewRegistryClient();
            V21ManifestTemplate manifestTemplate =
                await registryClient.PullManifestAsync <V21ManifestTemplate>("latest").ConfigureAwait(false);

            DescriptorDigest realDigest = manifestTemplate.GetLayerDigests().First();

            // Pulls a layer BLOB of the busybox image.
            LongAdder totalByteCount = new LongAdder();
            LongAdder expectedSize   = new LongAdder();
            IBlob     pulledBlob     =
                registryClient.PullBlob(
                    realDigest,
                    size =>
            {
                Assert.AreEqual(0, expectedSize.Sum());
                expectedSize.Add(size);
            },
                    totalByteCount.Add);
            BlobDescriptor blobDescriptor = await pulledBlob.WriteToAsync(Stream.Null).ConfigureAwait(false);

            Assert.AreEqual(realDigest, blobDescriptor.GetDigest());
            Assert.IsTrue(expectedSize.Sum() > 0);
            Assert.AreEqual(expectedSize.Sum(), totalByteCount.Sum());
        }