public PSHealthCheckStepProperties(HealthCheckStepProperties healthCheckStepProperties) : base(healthCheckStepProperties) { if (healthCheckStepProperties.Attributes is RestHealthCheckStepAttributes) { this.Attributes = new PSRestHealthCheckStepAttributes(healthCheckStepProperties.Attributes as RestHealthCheckStepAttributes); } }
private void HealthCheckStepTests( string location, DeploymentManagerClientHelper clientHelper, AzureDeploymentManagerClient deploymentManagerClient) { // Test Create step. var stepName = clientHelper.ResourceGroupName + "HealthCheckStep"; var healthChecks = new List <RestHealthCheck>(); healthChecks.Add(new RestHealthCheck() { Name = "webAppHealthCheck", Request = new RestRequest() { Method = RestRequestMethod.GET, Uri = "https://clientvalidations.deploymentmanager.net/healthstatus", Authentication = new ApiKeyAuthentication() { Name = "code", InProperty = RestAuthLocation.Header, Value = "AuthValue" } }, Response = new RestResponse() { SuccessStatusCodes = new List <string> { "200", "204" }, Regex = new RestResponseRegex() { MatchQuantifier = RestMatchQuantifier.All, Matches = new List <string> { "Contoso-Service-EndToEnd", "(?i)\"health_status\":((.|\n)*)\"(green|yellow)\"", "(?mi)^(\"application_host\": 94781052)$" } } } }); healthChecks.Add(new RestHealthCheck() { Name = "webBackEndHealthCheck", Request = new RestRequest() { Method = RestRequestMethod.GET, Uri = "https://clientvalidations.deploymentmanager.net/healthstatus", Authentication = new RolloutIdentityAuthentication() }, Response = new RestResponse() { SuccessStatusCodes = new List <string> { "200", "204" }, Regex = new RestResponseRegex() { MatchQuantifier = RestMatchQuantifier.All, Matches = new List <string> { "Contoso-Service-Backend", "(?i)\"health_status\":((.|\n)*)\"(green|yellow)\"", "(?mi)^(\"application_host\": 94781055)$" } } } }); var stepProperties = new HealthCheckStepProperties() { Attributes = new RestHealthCheckStepAttributes() { WaitDuration = "PT10M", MaxElasticDuration = "PT15M", HealthyStateDuration = "PT30M", HealthChecks = healthChecks } }; var inputStep = new StepResource( location: location, properties: stepProperties, name: stepName); var stepResponse = deploymentManagerClient.Steps.CreateOrUpdate( resourceGroupName: clientHelper.ResourceGroupName, stepName: stepName, stepInfo: inputStep); this.ValidateHealthCheckStep(inputStep, stepResponse); // Test list steps. var steps = deploymentManagerClient.Steps.List( resourceGroupName: clientHelper.ResourceGroupName); Assert.Equal(2, steps.Count); this.ValidateHealthCheckStep(inputStep, steps.ToList().First(s => s.Name.Equals(inputStep.Name, StringComparison.InvariantCultureIgnoreCase))); deploymentManagerClient.Steps.Delete( resourceGroupName: clientHelper.ResourceGroupName, stepName: stepName); var cloudException = Assert.Throws <CloudException>(() => deploymentManagerClient.Steps.Get( resourceGroupName: clientHelper.ResourceGroupName, stepName: stepName)); Assert.Equal(HttpStatusCode.NotFound, cloudException.Response.StatusCode); }