public IISTestSiteFixture()
        {
            var deploymentParameters = new DeploymentParameters(Helpers.GetInProcessTestSitesPath(),
                                                                ServerType.IISExpress,
                                                                RuntimeFlavor.CoreClr,
                                                                RuntimeArchitecture.x64)
            {
                ServerConfigTemplateContent = File.ReadAllText("AppHostConfig/Http.config"),
                SiteName        = "HttpTestSite",
                TargetFramework = "netcoreapp2.1",
                ApplicationType = ApplicationType.Portable,
                Configuration   =
#if DEBUG
                    "Debug"
#else
                    "Release"
#endif
            };

            _deployer        = ApplicationDeployerFactory.Create(deploymentParameters, NullLoggerFactory.Instance);
            DeploymentResult = _deployer.DeployAsync().Result;
            Client           = DeploymentResult.HttpClient;
            BaseUri          = DeploymentResult.ApplicationBaseUri;
            ShutdownToken    = DeploymentResult.HostShutdownToken;
        }
Example #2
0
        public async Task <DeploymentResult> CreateDeploymentAsync(ILoggerFactory loggerFactory)
        {
            lock (_deploymentLock)
            {
                if (_deploymentTask == null)
                {
                    var deploymentParameters = GetDeploymentParameters();
                    _deployer       = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory);
                    _deploymentTask = _deployer.DeployAsync();
                }
            }

            return(await _deploymentTask);
        }
        public void Setup()
        {
            var deploymentParameters = new DeploymentParameters(Path.Combine(TestPathUtilities.GetSolutionRootDirectory("IISIntegration"), "test/Websites/InProcessWebSite"),
                                                                ServerType.IISExpress,
                                                                RuntimeFlavor.CoreClr,
                                                                RuntimeArchitecture.x64)
            {
                ServerConfigTemplateContent = File.ReadAllText("Http.config"),
                SiteName        = "HttpTestSite",
                TargetFramework = "netcoreapp2.1",
                ApplicationType = ApplicationType.Portable,
                ANCMVersion     = ANCMVersion.AspNetCoreModuleV2
            };

            _deployer = ApplicationDeployerFactory.Create(deploymentParameters, NullLoggerFactory.Instance);
            _client   = _deployer.DeployAsync().Result.HttpClient;
        }
Example #4
0
        public async Task <StressTestServerStartResult> StartAsync()
        {
            var framework    = "CoreCLR";
            var fullTestName = $"{_testMethodName}.{_testName}.{framework}";

            fullTestName = fullTestName.Replace('_', '.');

            var loggerFactory = LogUtility.LoggerFactory;

            _logger = loggerFactory.CreateLogger(fullTestName);

            var baseAddress = $"http://localhost:{_port}/";

            var p = new DeploymentParameters(
                PathHelper.GetTestAppFolder(_testName),
                _serverType,
                RuntimeFlavor.CoreClr,
                RuntimeArchitecture.x64)
            {
                SiteName = _testName,
                ApplicationBaseUriHint = baseAddress,
                TargetFramework        = Runtimes.GetFrameworkName(framework),
            };

            var deployerLoggerFactory = StressConfig.Instance.DeployerLogging ?
                                        loggerFactory :
                                        NullLoggerFactory.Instance;

            _applicationDeployer = ApplicationDeployerFactory.Create(p, deployerLoggerFactory);
            var deploymentResult = _applicationDeployer.DeployAsync().Result;

            baseAddress = deploymentResult.ApplicationBaseUri;

            _logger.LogInformation($"Test project is set up at {deploymentResult.ContentRoot}");

            var result = new StressTestServerStartResult
            {
                ServerHandle = this
            };
            var serverVerificationClient = new HttpClient
            {
                BaseAddress = new Uri(baseAddress)
            };

            HttpResponseMessage response = null;

            for (var i = 0; i < 20; ++i)
            {
                try
                {
                    _logger.LogInformation($"Pinging {serverVerificationClient.BaseAddress} to ensure server booted properly");
                    response = await serverVerificationClient.GetAsync(serverVerificationClient.BaseAddress);

                    break;
                }
                catch (TimeoutException)
                {
                    _logger.LogError("Http client timeout.");
                    break;
                }
                catch (Exception)
                {
                    _logger.LogInformation("Failed to ping server. Retrying...");
                    Thread.Sleep(TimeSpan.FromSeconds(1));
                    continue;
                }
            }

            result.SuccessfullyStarted = false;
            if (response != null)
            {
                _logger.LogInformation($"Response {response.StatusCode}");

                if (response.IsSuccessStatusCode)
                {
                    _logger.LogInformation("Server started successfully");
                    result.SuccessfullyStarted = true;
                    ClientFactory = () => new RequestTrackingHttpClient(baseAddress, _metricCollector);
                }
            }

            return(result);
        }