public async Task VerifyImages(ImageData imageData)
        {
            string appSdkImage = GetIdentifier(imageData.DotNetVersion, "app-sdk");

            try
            {
                CreateTestAppWithSdkImage(imageData, appSdkImage);

                if (!imageData.HasNoSdk)
                {
                    VerifySdkImage_PackageCache(imageData);

                    // TODO: Skip running app in arm + web configuration to workaround https://github.com/dotnet/cli/issues/9162
                    if (!(imageData.IsArm && imageData.IsWeb))
                    {
                        await VerifySdkImage_RunApp(imageData, appSdkImage);
                    }
                }

                await VerifyRuntimeImage_FrameworkDependentApp(imageData, appSdkImage);

                if (DockerHelper.IsLinuxContainerModeEnabled)
                {
                    await VerifyRuntimeDepsImage_SelfContainedApp(imageData, appSdkImage);
                }
            }
            finally
            {
                _dockerHelper.DeleteImage(appSdkImage);
            }
        }
Exemple #2
0
        public async Task VerifyImages(ImageData imageData)
        {
            string appSdkImage = GetIdentifier(imageData.DotNetVersion, "app-sdk");

            try
            {
                CreateTestAppWithSdkImage(imageData, appSdkImage);

                if (!imageData.HasNoSdk)
                {
                    VerifySdkImage_PackageCache(imageData);
                    await VerifySdkImage_RunApp(imageData, appSdkImage);
                }

                await VerifyRuntimeImage_FrameworkDependentApp(imageData, appSdkImage);

                if (DockerHelper.IsLinuxContainerModeEnabled)
                {
                    await VerifyRuntimeDepsImage_SelfContainedApp(imageData, appSdkImage);
                }
            }
            finally
            {
                _dockerHelper.DeleteImage(appSdkImage);
            }
        }
Exemple #3
0
        private async Task VerifySampleAsync(
            SampleImageData imageData,
            SampleImageType sampleImageType,
            Func <string, string, Task> verifyImageAsync)
        {
            string image     = imageData.GetImage(sampleImageType, DockerHelper);
            string imageType = Enum.GetName(typeof(SampleImageType), sampleImageType).ToLowerInvariant();

            try
            {
                if (!imageData.IsPublished)
                {
                    string sampleFolder   = Path.Combine(s_samplesPath, imageType);
                    string dockerfilePath = $"{sampleFolder}/Dockerfile.{imageData.DockerfileSuffix}";

                    DockerHelper.Build(image, dockerfilePath, contextDir: sampleFolder, pull: Config.PullImages);
                }

                string containerName = imageData.GetIdentifier($"sample-{imageType}");
                await verifyImageAsync(image, containerName);
            }
            finally
            {
                if (!imageData.IsPublished)
                {
                    DockerHelper.DeleteImage(image);
                }
            }
        }
Exemple #4
0
        public async Task VerifyImages(ImageData imageData)
        {
            if (!DockerHelper.IsLinuxContainerModeEnabled && imageData.IsArm)
            {
                _outputHelper.WriteLine("Tests are blocked on https://github.com/dotnet/corefx/issues/33563");
                return;
            }
            else if (imageData.Version == V3_0 && imageData.OS == OS.StretchSlim)
            {
                _outputHelper.WriteLine("Intermittent compile failure");
                return;
            }

            string appSdkImage = GetIdentifier(imageData, "app-sdk");

            try
            {
                CreateTestAppWithSdkImage(imageData, appSdkImage);

                if (!imageData.HasNoSdk)
                {
                    VerifySdkImage_PackageCache(imageData);

                    // TODO: Skip running app in arm + web configuration to workaround https://github.com/dotnet/cli/issues/9162
                    if (!(imageData.IsArm && imageData.IsWeb))
                    {
                        await VerifySdkImage_RunApp(imageData, appSdkImage);
                    }
                }

                await VerifyRuntimeImage_FrameworkDependentApp(imageData, appSdkImage);

                if (DockerHelper.IsLinuxContainerModeEnabled)
                {
                    await VerifyRuntimeDepsImage_SelfContainedApp(imageData, appSdkImage);
                }
            }
            finally
            {
                _dockerHelper.DeleteImage(appSdkImage);
            }
        }
Exemple #5
0
        public void VerifyComplexAppSample()
        {
            string appTag            = SampleImageData.GetImageName("complexapp-local-app");
            string testTag           = SampleImageData.GetImageName("complexapp-local-test");
            string sampleFolder      = Path.Combine(s_samplesPath, "complexapp");
            string dockerfilePath    = $"{sampleFolder}/Dockerfile";
            string testContainerName = ImageData.GenerateContainerName("sample-complex-test");
            string tempDir           = null;

            try
            {
                // Test that the app works
                DockerHelper.Build(appTag, dockerfilePath, contextDir: sampleFolder, pull: Config.PullImages);
                string containerName = ImageData.GenerateContainerName("sample-complex");
                string output        = DockerHelper.Run(appTag, containerName);
                Assert.StartsWith("string: The quick brown fox jumps over the lazy dog", output);

                if (!DockerHelper.IsLinuxContainerModeEnabled &&
                    DockerHelper.DockerArchitecture.StartsWith("arm", StringComparison.OrdinalIgnoreCase))
                {
                    // Skipping run app tests due to a .NET issue: https://github.com/dotnet/runtime/issues/2082
                    return;
                }

                // Run the app's tests
                DockerHelper.Build(testTag, dockerfilePath, target: "test", contextDir: sampleFolder);
                DockerHelper.Run(testTag, testContainerName, skipAutoCleanup: true);

                // Copy the test log from the container to the host
                tempDir = Directory.CreateDirectory(
                    Path.Combine(Path.GetTempPath(), Path.GetRandomFileName())).FullName;
                DockerHelper.Copy($"{testContainerName}:/source/tests/TestResults", tempDir);
                string testLogFile = new DirectoryInfo($"{tempDir}/TestResults").GetFiles("*.trx").First().FullName;

                // Open the test log file and verify the tests passed
                XDocument doc     = XDocument.Load(testLogFile);
                XElement  summary = doc.Root.Element(XName.Get("ResultSummary", doc.Root.Name.NamespaceName));
                Assert.Equal("Completed", summary.Attribute("outcome").Value);
                XElement counters = summary.Element(XName.Get("Counters", doc.Root.Name.NamespaceName));
                Assert.Equal("2", counters.Attribute("total").Value);
                Assert.Equal("2", counters.Attribute("passed").Value);
            }
            finally
            {
                if (tempDir != null)
                {
                    Directory.Delete(tempDir, true);
                }

                DockerHelper.DeleteContainer(testContainerName);
                DockerHelper.DeleteImage(testTag);
                DockerHelper.DeleteImage(appTag);
            }
        }
Exemple #6
0
        public async Task Execute()
        {
            string        appDir = CreateTestAppWithSdkImage(_isWeb ? "web" : "console");
            List <string> tags   = new List <string>();

            InjectCustomTestCode(appDir);

            try
            {
                if (!_imageData.HasCustomSdk)
                {
                    // Use `sdk` image to build and run test app
                    string buildTag = BuildTestAppImage("build", appDir);
                    tags.Add(buildTag);
                    string dotnetRunArgs = _isWeb ? " --urls http://0.0.0.0:80" : string.Empty;
                    await RunTestAppImage(buildTag, command : $"dotnet run{dotnetRunArgs}");
                }

                // Use `sdk` image to publish FX dependent app and run with `runtime` or `aspnet` image
                string fxDepTag = BuildTestAppImage("fx_dependent_app", appDir);
                tags.Add(fxDepTag);
                bool runAsAdmin = _isWeb && !DockerHelper.IsLinuxContainerModeEnabled;
                await RunTestAppImage(fxDepTag, runAsAdmin : runAsAdmin);

                if (DockerHelper.IsLinuxContainerModeEnabled)
                {
                    // Skip test until end-to-end scenario works for self-contained publishing on Alpine arm32
                    if ((_imageData.Version.Major == 5) &&
                        _imageData.Arch == Arch.Arm && _imageData.OS.Contains("alpine"))
                    {
                        return;
                    }

                    // Use `sdk` image to publish self contained app and run with `runtime-deps` image
                    string selfContainedTag = BuildTestAppImage("self_contained_app", appDir, customBuildArgs: $"rid={_imageData.Rid}");
                    tags.Add(selfContainedTag);
                    await RunTestAppImage(selfContainedTag, runAsAdmin : runAsAdmin);
                }
            }
            finally
            {
                tags.ForEach(tag => _dockerHelper.DeleteImage(tag));
                Directory.Delete(appDir, true);
            }
        }
        public async Task Execute()
        {
            if (!DockerHelper.IsLinuxContainerModeEnabled && _imageData.IsArm && _imageData.Version.Major == 3)
            {
                _outputHelper.WriteLine("Tests are blocked on https://github.com/dotnet/corefx/issues/33563");
                return;
            }

            string        appDir = CreateTestAppWithSdkImage(_isWeb ? "web" : "console");
            List <string> tags   = new List <string>();

            try
            {
                if (_imageData.HasSdk)
                {
                    // Use `sdk` image to build and run test app
                    string buildTag = BuildTestAppImage("build", appDir);
                    tags.Add(buildTag);
                    string dotnetRunArgs = _isWeb ? " --urls http://0.0.0.0:80" : string.Empty;
                    await RunTestAppImage(buildTag, command : $"dotnet run{dotnetRunArgs}");
                }

                // Use `sdk` image to publish FX dependent app and run with `runtime` or `aspnet` image
                string fxDepTag = BuildTestAppImage("fx_dependent_app", appDir);
                tags.Add(fxDepTag);
                bool runAsAdmin = _isWeb && !DockerHelper.IsLinuxContainerModeEnabled && _imageData.OS != OS.NanoServerSac2016;
                await RunTestAppImage(fxDepTag, runAsAdmin : runAsAdmin);

                if (DockerHelper.IsLinuxContainerModeEnabled)
                {
                    // Use `sdk` image to publish self contained app and run with `runtime-deps` image
                    string selfContainedTag = BuildTestAppImage("self_contained_app", appDir, customBuildArgs: $"rid={_imageData.Rid}");
                    tags.Add(selfContainedTag);
                    await RunTestAppImage(selfContainedTag, runAsAdmin : runAsAdmin);
                }
            }
            finally
            {
                tags.ForEach(tag => _dockerHelper.DeleteImage(tag));
                Directory.Delete(appDir, true);
            }
        }
        public async Task Execute()
        {
            string        appDir = CreateTestAppWithSdkImage(_isWeb ? "web" : "console");
            List <string> tags   = new List <string>();

            try
            {
                if (_imageData.HasSdk)
                {
                    // Use `sdk` image to build and run test app
                    string buildTag = BuildTestAppImage("build", appDir);
                    tags.Add(buildTag);
                    string dotnetRunArgs = _isWeb ? " --urls http://0.0.0.0:80" : string.Empty;
                    await RunTestAppImage(buildTag, command : $"dotnet run{dotnetRunArgs}");
                }

                // Use `sdk` image to publish FX dependent app and run with `runtime` or `aspnet` image
                string fxDepTag = BuildTestAppImage("fx_dependent_app", appDir);
                tags.Add(fxDepTag);
                bool runAsAdmin = _isWeb && !DockerHelper.IsLinuxContainerModeEnabled;
                await RunTestAppImage(fxDepTag, runAsAdmin : runAsAdmin);

                if (DockerHelper.IsLinuxContainerModeEnabled)
                {
                    // Use `sdk` image to publish self contained app and run with `runtime-deps` image
                    string selfContainedTag = BuildTestAppImage("self_contained_app", appDir, customBuildArgs: $"rid={_imageData.Rid}");
                    tags.Add(selfContainedTag);
                    await RunTestAppImage(selfContainedTag, runAsAdmin : runAsAdmin);
                }
            }
            finally
            {
                tags.ForEach(tag => _dockerHelper.DeleteImage(tag));
                Directory.Delete(appDir, true);
            }
        }