Beispiel #1
0
        public void TestCreation()
        {
            FibContainer container = new FibContainer(digest1, digest2);

            Assert.AreEqual(digest1, container.GetDigest());
            Assert.AreEqual(digest2, container.GetImageId());
        }
Beispiel #2
0
        public void TestEquality()
        {
            FibContainer container1 = new FibContainer(digest1, digest2);
            FibContainer container2 = new FibContainer(digest1, digest2);
            FibContainer container3 = new FibContainer(digest2, digest3);

            Assert.AreEqual(container1, container2);
            Assert.AreEqual(container1.GetHashCode(), container2.GetHashCode());
            Assert.AreNotEqual(container1, container3);
        }
Beispiel #3
0
        public async Task TestBasic_HelloWorldAsync()
        {
            ImageReference targetImageReference =
                ImageReference.Of("localhost:5002", "fibdotnet-core", "basic-helloworld");
            FibContainer fibContainer =
                await FibContainerBuilder.From("busybox")
                .SetEntrypoint("echo", "Hello World")
                .ContainerizeAsync(
                    Containerizer.To(
                        RegistryImage.Named(targetImageReference)
                        .AddCredentialRetriever(
                            () => Maybe.Of(Credential.From("username", "password"))))
                    .SetAllowInsecureRegistries(true)
                    .AddEventHandler <IFibEvent>(e => TestContext.Out.WriteLine(e))).ConfigureAwait(false);

            Assert.AreEqual("Hello World\n", PullAndRunBuiltImage(targetImageReference.ToString()));
            Assert.AreEqual(
                "Hello World\n",
                PullAndRunBuiltImage(
                    targetImageReference.WithTag(fibContainer.GetDigest().ToString()).ToString()));
        }
Beispiel #4
0
        public async Task TestSteps_ForBuildToDockerRegistryAsync()
        {
            Stopwatch    s      = Stopwatch.StartNew();
            FibContainer image1 =
                await BuildRegistryImageAsync(
                    ImageReference.Of("gcr.io", "distroless/java", DISTROLESS_DIGEST),
                    ImageReference.Of("localhost:5000", "testimage", "testtag"),
                    new List <string>()).ConfigureAwait(false);

            progressChecker.CheckCompletion();

            logger.Info("Initial build time: " + s.Elapsed);
            s.Restart();
            FibContainer image2 =
                await BuildRegistryImageAsync(
                    ImageReference.Of("gcr.io", "distroless/java", DISTROLESS_DIGEST),
                    ImageReference.Of("localhost:5000", "testimage", "testtag"),
                    new List <string>()).ConfigureAwait(false);

            logger.Info("Secondary build time: " + s.Elapsed);

            Assert.AreEqual(image1, image2);

            const string imageReference = "localhost:5000/testimage:testtag";

            localRegistry.Pull(imageReference);
            AssertDockerInspect(imageReference);
            AssertLayerSizer(7, imageReference);
            Assert.AreEqual(
                "Hello, world. An argument.\n", new Command("docker", "run", "--rm", imageReference).Run());

            string imageReferenceByDigest = "localhost:5000/testimage@" + image1.GetDigest();

            localRegistry.Pull(imageReferenceByDigest);
            AssertDockerInspect(imageReferenceByDigest);
            Assert.AreEqual(
                "Hello, world. An argument.\n",
                new Command("docker", "run", "--rm", imageReferenceByDigest).Run());
        }