Esempio n. 1
0
        public void VerifySdkImage_EnvironmentVariables(ImageData imageData)
        {
            List <EnvironmentVariableInfo> variables = new List <EnvironmentVariableInfo>();

            variables.AddRange(GetCommonEnvironmentVariables());

            string aspnetUrlsValue = imageData.Version.Major < 3 ? "http://+:80" : string.Empty;

            variables.Add(new EnvironmentVariableInfo("ASPNETCORE_URLS", aspnetUrlsValue));
            variables.Add(new EnvironmentVariableInfo("DOTNET_USE_POLLING_FILE_WATCHER", "true"));
            variables.Add(new EnvironmentVariableInfo("NUGET_XMLDOC_MODE", "skip"));

            if (imageData.Version.Major >= 3 &&
                (DockerHelper.IsLinuxContainerModeEnabled || imageData.Version >= new Version("3.1")))
            {
                variables.Add(new EnvironmentVariableInfo("POWERSHELL_DISTRIBUTION_CHANNEL", allowAnyValue: true));
            }

            if (imageData.SdkOS.StartsWith(Tests.OS.AlpinePrefix))
            {
                variables.Add(new EnvironmentVariableInfo("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT", "false"));
                variables.Add(new EnvironmentVariableInfo("LC_ALL", "en_US.UTF-8"));
                variables.Add(new EnvironmentVariableInfo("LANG", "en_US.UTF-8"));
            }

            EnvironmentVariableInfo.Validate(variables, DotNetImageType.SDK, imageData, _dockerHelper);
        }
Esempio n. 2
0
        protected void VerifyCommonEnvironmentVariables(
            ProductImageData imageData, IEnumerable <EnvironmentVariableInfo> customVariables = null)
        {
            List <EnvironmentVariableInfo> variables = new List <EnvironmentVariableInfo>();

            variables.AddRange(GetCommonEnvironmentVariables());
            variables.Add(new EnvironmentVariableInfo("ASPNETCORE_URLS", "http://+:80"));

            if (customVariables != null)
            {
                variables.AddRange(customVariables);
            }

            if (imageData.OS.StartsWith(OS.AlpinePrefix))
            {
                variables.Add(new EnvironmentVariableInfo("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT", "true"));
            }

            string imageTag;

            if (imageData.IsDistroless)
            {
                imageTag = DockerHelper.BuildDistrolessHelper(ImageType, imageData, "bash");
            }
            else
            {
                imageTag = imageData.GetImage(ImageType, DockerHelper);
            }

            EnvironmentVariableInfo.Validate(variables, imageTag, imageData, DockerHelper);
        }
Esempio n. 3
0
        public void VerifyEnvironmentVariables(ProductImageData imageData)
        {
            List <EnvironmentVariableInfo> variables = new()
            {
                new EnvironmentVariableInfo("ASPNETCORE_URLS", string.Empty),
                new EnvironmentVariableInfo("DOTNET_GENERATE_ASPNET_CERTIFICATE", "false"),
                new EnvironmentVariableInfo("DOTNET_USE_POLLING_FILE_WATCHER", "true"),
                new EnvironmentVariableInfo("NUGET_XMLDOC_MODE", "skip")
            };

            variables.AddRange(GetCommonEnvironmentVariables());

            if (imageData.Version.Major >= 3)
            {
                variables.Add(new EnvironmentVariableInfo("POWERSHELL_DISTRIBUTION_CHANNEL", allowAnyValue: true));
            }

            if (imageData.Version.Major >= 5)
            {
                string version = imageData.GetProductVersion(ImageType, DockerHelper);
                variables.Add(new EnvironmentVariableInfo("DOTNET_SDK_VERSION", version));
            }

            if (imageData.Version.Major >= 5)
            {
                variables.Add(AspnetImageTests.GetAspnetVersionVariableInfo(imageData, DockerHelper));
                variables.Add(RuntimeImageTests.GetRuntimeVersionVariableInfo(imageData, DockerHelper));
            }

            if (imageData.Version.Major >= 6)
            {
                variables.Add(new EnvironmentVariableInfo("DOTNET_NOLOGO", "true"));
            }

            if (imageData.Version.Major == 6)
            {
                variables.Add(new EnvironmentVariableInfo("Logging__Console__FormatterName", string.Empty));
            }

            if (imageData.SdkOS.StartsWith(OS.AlpinePrefix))
            {
                variables.Add(new EnvironmentVariableInfo("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT", "false"));

                if (imageData.Version.Major < 5)
                {
                    variables.Add(new EnvironmentVariableInfo("LC_ALL", "en_US.UTF-8"));
                    variables.Add(new EnvironmentVariableInfo("LANG", "en_US.UTF-8"));
                }
            }

            EnvironmentVariableInfo.Validate(variables, imageData.GetImage(DotNetImageType.SDK, DockerHelper), imageData, DockerHelper);
        }
Esempio n. 4
0
        private void VerifyCommonRuntimeEnvironmentVariables(DotNetImageType imageType, ImageData imageData)
        {
            List <EnvironmentVariableInfo> variables = new List <EnvironmentVariableInfo>();

            variables.AddRange(GetCommonEnvironmentVariables());
            variables.Add(new EnvironmentVariableInfo("ASPNETCORE_URLS", "http://+:80"));

            if (imageData.OS.StartsWith(Tests.OS.AlpinePrefix))
            {
                variables.Add(new EnvironmentVariableInfo("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT", "true"));
            }

            EnvironmentVariableInfo.Validate(variables, imageType, imageData, _dockerHelper);
        }
Esempio n. 5
0
        private void ValidateEnvironmentVariables(SampleImageData imageData, string image, SampleImageType imageType)
        {
            List <EnvironmentVariableInfo> variables = new List <EnvironmentVariableInfo>();

            variables.AddRange(ProductImageTests.GetCommonEnvironmentVariables());

            if (imageType == SampleImageType.Aspnetapp)
            {
                variables.Add(new EnvironmentVariableInfo("ASPNETCORE_URLS", "http://+:80"));
            }

            EnvironmentVariableInfo.Validate(
                variables,
                image,
                imageData,
                DockerHelper);
        }
Esempio n. 6
0
        public void VerifyEnvironmentVariables(MonitorImageData imageData)
        {
            List <EnvironmentVariableInfo> variables = new List <EnvironmentVariableInfo>();

            variables.AddRange(ProductImageTests.GetCommonEnvironmentVariables());

            // ASPNETCORE_URLS has been unset to allow the default URL binding to occur.
            variables.Add(new EnvironmentVariableInfo("ASPNETCORE_URLS", string.Empty));
            // Diagnostics should be disabled
            variables.Add(new EnvironmentVariableInfo("COMPlus_EnableDiagnostics", "0"));

            EnvironmentVariableInfo.Validate(
                variables,
                imageData.GetImage(DockerHelper),
                imageData,
                DockerHelper);
        }
Esempio n. 7
0
        public void VerifyEnvironmentVariables(ProductImageData imageData)
        {
            List <EnvironmentVariableInfo> variables = new List <EnvironmentVariableInfo>();

            variables.AddRange(GetCommonEnvironmentVariables());

            string aspnetUrlsValue = imageData.Version.Major < 3 ? "http://+:80" : string.Empty;

            variables.Add(new EnvironmentVariableInfo("ASPNETCORE_URLS", aspnetUrlsValue));
            variables.Add(new EnvironmentVariableInfo("DOTNET_USE_POLLING_FILE_WATCHER", "true"));
            variables.Add(new EnvironmentVariableInfo("NUGET_XMLDOC_MODE", "skip"));

            if (imageData.Version.Major >= 3)
            {
                variables.Add(new EnvironmentVariableInfo("POWERSHELL_DISTRIBUTION_CHANNEL", allowAnyValue: true));
            }

            if (imageData.Version.Major >= 5 || (imageData.Version.Major == 2 && DockerHelper.IsLinuxContainerModeEnabled))
            {
                string version = imageData.GetProductVersion(ImageType, DockerHelper);
                variables.Add(new EnvironmentVariableInfo("DOTNET_SDK_VERSION", version));
            }

            if (imageData.Version.Major >= 5)
            {
                variables.Add(AspnetImageTests.GetAspnetVersionVariableInfo(imageData, DockerHelper));
                variables.Add(RuntimeImageTests.GetRuntimeVersionVariableInfo(imageData, DockerHelper));
            }

            if (imageData.SdkOS.StartsWith(OS.AlpinePrefix))
            {
                variables.Add(new EnvironmentVariableInfo("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT", "false"));

                if (imageData.Version.Major < 5)
                {
                    variables.Add(new EnvironmentVariableInfo("LC_ALL", "en_US.UTF-8"));
                    variables.Add(new EnvironmentVariableInfo("LANG", "en_US.UTF-8"));
                }
            }

            EnvironmentVariableInfo.Validate(variables, DotNetImageType.SDK, imageData, DockerHelper);
        }
        public void VerifyEnvironmentVariables(MonitorImageData imageData)
        {
            List <EnvironmentVariableInfo> variables = new List <EnvironmentVariableInfo>();

            variables.AddRange(ProductImageTests.GetCommonEnvironmentVariables());

            // ASPNETCORE_URLS has been unset to allow the default URL binding to occur.
            variables.Add(new EnvironmentVariableInfo("ASPNETCORE_URLS", string.Empty));
            // Diagnostics should be disabled
            variables.Add(new EnvironmentVariableInfo("COMPlus_EnableDiagnostics", "0"));
            // DefaultProcess filter should select a process with a process ID of 1
            variables.Add(new EnvironmentVariableInfo("DefaultProcess__Filters__0__Key", "ProcessId"));
            variables.Add(new EnvironmentVariableInfo("DefaultProcess__Filters__0__Value", "1"));
            // Console logger format should be JSON and output UTC timestamps without timezone information
            variables.Add(new EnvironmentVariableInfo("Logging__Console__FormatterName", "json"));
            variables.Add(new EnvironmentVariableInfo("Logging__Console__FormatterOptions__TimestampFormat", "yyyy-MM-ddTHH:mm:ss.fffffffZ"));
            variables.Add(new EnvironmentVariableInfo("Logging__Console__FormatterOptions__UseUtcTimestamp", "true"));

            EnvironmentVariableInfo.Validate(
                variables,
                imageData.GetImage(DockerHelper),
                imageData,
                DockerHelper);
        }