/// <summary> /// Creates a HttpHealthCheck resource in the specified project using the data included in the request. /// Documentation https://developers.google.com/compute/beta/reference/httpHealthChecks/insert /// Generation Note: This does not always build corectly. Google needs to standardise things I need to figuer out which ones are wrong. /// </summary> /// <param name="service">Authenticated Compute service.</param> /// <param name="project">Project ID for this request.</param> /// <param name="body">A valid Compute beta body.</param> /// <param name="optional">Optional paramaters.</param> /// <returns>OperationResponse</returns> public static Operation Insert(ComputeService service, string project, HttpHealthCheck body, HttpHealthChecksInsertOptionalParms optional = null) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } if (body == null) { throw new ArgumentNullException("body"); } if (project == null) { throw new ArgumentNullException(project); } // Building the initial request. var request = service.HttpHealthChecks.Insert(body, project); // Applying optional parameters to the request. request = (HttpHealthChecksResource.InsertRequest)SampleHelpers.ApplyOptionalParms(request, optional); // Requesting data. return(request.Execute()); } catch (Exception ex) { throw new Exception("Request HttpHealthChecks.Insert failed.", ex); } }
/// <summary> /// Creates a HttpHealthCheck resource in the specified project using the data included in the request. /// Documentation https://developers.google.com/compute/v1/reference/httpHealthChecks/insert /// Generation Note: This does not always build corectly. Google needs to standardise things I need to figuer out which ones are wrong. /// </summary> /// <param name="service">Authenticated compute service.</param> /// <param name="project">Project ID for this request.</param> /// <param name="body">A valid compute v1 body.</param> /// <returns>OperationResponse</returns> public static Operation Insert(computeService service, string project, HttpHealthCheck body) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } if (body == null) { throw new ArgumentNullException("body"); } if (project == null) { throw new ArgumentNullException(project); } // Make the request. return(service.HttpHealthChecks.Insert(body, project).Execute()); } catch (Exception ex) { throw new Exception("Request HttpHealthChecks.Insert failed.", ex); } }
public void test_construction() { _healthCheck = new HttpHealthCheck("Name", "http://localhost", 120, 1000); Assert.Equal("Name", _healthCheck.Name); Assert.Equal("http://localhost", _healthCheck.Url); Assert.Equal(120, _healthCheck.Interval); Assert.Equal(1000, _healthCheck.Timeout); }
public override bool ShouldBeFiltered(HttpRequest request) { var httpHealtheCheck = new HttpHealthCheck(); return(string.Compare( request.Path.ToString(), httpHealtheCheck.HealthCheckUrl, StringComparison.InvariantCultureIgnoreCase) == 0); }
public void test_AddHeader_ThrowsAnException_WhenTheHeaderValueIsNull() { _healthCheck = new HttpHealthCheck(); try { _healthCheck.AddHeader("Name", null); throw new TestFailedException(); } catch (ArgumentException ae) { Assert.Equal("The header value must not be null.", ae.Message); } }
public void test_AddHeader_ThrowsAnException_WhenTheHeaderNameIsEmpty() { _healthCheck = new HttpHealthCheck(); try { _healthCheck.AddHeader(" ", "value"); throw new TestFailedException(); } catch (ArgumentException ae) { Assert.Equal("The header name must not be null or empty.", ae.Message); } }
public void Test_Service_Unhealthy_Exception() { // arrange var factory = _fixture.GetExceptionClientFactory(); var check = new HttpHealthCheck("unittests-4", "http://localhost/health/ready", factory, 100, 200); var context = new HealthCheckContext(); // act var checkResult = check.CheckHealthAsync(context).Result; // assert Assert.Equal(HealthStatus.Unhealthy, checkResult.Status); }
public void test_AddHealthCheck() { ContainerInstance containerInstance = Model.AddContainerInstance(_deploymentNode, _database); Assert.Equal(0, containerInstance.HealthChecks.Count); HttpHealthCheck healthCheck = containerInstance.AddHealthCheck("Test web application is working", "http://localhost:8080"); Assert.Equal("Test web application is working", healthCheck.Name); Assert.Equal("http://localhost:8080", healthCheck.Url); Assert.Equal(60, healthCheck.Interval); Assert.Equal(0, healthCheck.Timeout); Assert.Equal(1, containerInstance.HealthChecks.Count); }
public void test_AddHealthCheck() { SoftwareSystemInstance softwareSystemInstance = Model.AddSoftwareSystemInstance(_deploymentNode, _softwareSystem, "Default"); Assert.Equal(0, softwareSystemInstance.HealthChecks.Count); HttpHealthCheck healthCheck = softwareSystemInstance.AddHealthCheck("Test web application is working", "http://localhost:8080"); Assert.Equal("Test web application is working", healthCheck.Name); Assert.Equal("http://localhost:8080", healthCheck.Url); Assert.Equal(60, healthCheck.Interval); Assert.Equal(0, healthCheck.Timeout); Assert.Equal(1, softwareSystemInstance.HealthChecks.Count); }
public static IMicropartBuilder UseHttpHealthCheckOfAspNetCore(this IMicropartBuilder micropartBuilder, IApplicationBuilder app) { var httpHealtheCheck = new HttpHealthCheck(); app.Map(httpHealtheCheck.HealthCheckUrl, builder => builder.Run(async context => { await context.Response.WriteAsync("OK1"); })); app.ApplicationServices.GetService <IMicropartOfServiceCenter>().RegisterService(); var httpRequestFilter = app.ApplicationServices.GetService <IMicroserviceFilterManager <HttpRequestFilter, HttpRequest> >(); httpRequestFilter.AddFilter(new HttpRequestFilterOfHealthCheck()); return(micropartBuilder); }
protected override void ProcessRecord() { if (Https || HttpsObject != null) { HttpsHealthCheck body = HttpsObject ?? new HttpsHealthCheck { Name = Name, Description = Description, Host = HostHeader, Port = Port, RequestPath = RequestPath, CheckIntervalSec = (int?)CheckInterval?.TotalSeconds, TimeoutSec = (int?)Timeout?.TotalSeconds, HealthyThreshold = HealthyThreshold, UnhealthyThreshold = UnhealthyThreshold }; HttpsHealthChecksResource.InsertRequest request = Service.HttpsHealthChecks.Insert(body, Project); Operation operation = request.Execute(); AddGlobalOperation(Project, operation, () => { WriteObject(Service.HttpsHealthChecks.Get(Project, body.Name).Execute()); }); } else { HttpHealthCheck body = HttpObject ?? new HttpHealthCheck { Name = Name, Description = Description, Host = HostHeader, Port = Port, RequestPath = RequestPath, CheckIntervalSec = (int?)CheckInterval?.TotalSeconds, TimeoutSec = (int?)Timeout?.TotalSeconds, HealthyThreshold = HealthyThreshold, UnhealthyThreshold = UnhealthyThreshold }; HttpHealthChecksResource.InsertRequest request = Service.HttpHealthChecks.Insert(body, Project); Operation operation = request.Execute(); AddGlobalOperation(Project, operation, () => { WriteObject(Service.HttpHealthChecks.Get(Project, body.Name).Execute()); }); } }
protected override IJob Build() { var job = new SimpleJob(Logger, "HttpCheck"); job.RaiseJobExceptionEvent += Job_RaiseJobExceptionEvent; var policy = Policy.Handle <HttpRequestException>().WaitAndRetryAsync(new[] { TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(3) }); job.Use((_) => { var httpCheck = new HttpHealthCheck(new HttpHealthCheckParams("http://google.com", (m, r) => Console.WriteLine(m))); return(httpCheck.Beat()); }, policy); return(job); }
public void test_AddHeader_DoesNotThrowAnException_WhenTheHeaderValueIsEmpty() { _healthCheck = new HttpHealthCheck(); _healthCheck.AddHeader("Name", ""); Assert.Equal("", _healthCheck.Headers["Name"]); }
public void test_AddHeader() { _healthCheck = new HttpHealthCheck(); _healthCheck.AddHeader("Name", "Value"); Assert.Equal("Value", _healthCheck.Headers["Name"]); }
public void test_defaultConstructorExists() { // the default constructor is used when deserializing from JSON _healthCheck = new HttpHealthCheck(); }