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_ThrowsAnException_WhenTheTimeoutIsLessThanZero() { ContainerInstance containerInstance = Model.AddContainerInstance(_deploymentNode, _database); try { containerInstance.AddHealthCheck("Name", "https://localhost", 60, -1); throw new TestFailedException(); } catch (ArgumentException ae) { Assert.Equal("The timeout must be zero or a positive integer.", ae.Message); } }
public void test_AddHealthCheck_ThrowsAnException_WhenTheUrlIsInvalid() { ContainerInstance containerInstance = Model.AddContainerInstance(_deploymentNode, _database); try { containerInstance.AddHealthCheck("Name", "localhost"); throw new TestFailedException(); } catch (ArgumentException ae) { Assert.Equal("localhost is not a valid URL.", ae.Message); } }
public void test_AddHealthCheck_ThrowsAnException_WhenTheUrlIsEmpty() { ContainerInstance containerInstance = Model.AddContainerInstance(_deploymentNode, _database); try { containerInstance.AddHealthCheck("Name", " "); throw new TestFailedException(); } catch (ArgumentException ae) { Assert.Equal("The URL must not be null or empty.", ae.Message); } }
public void test_AddHealthCheck_ThrowsAnException_WhenTheNameIsNull() { ContainerInstance containerInstance = Model.AddContainerInstance(_deploymentNode, _database); try { containerInstance.AddHealthCheck(null, "http://localhost"); throw new TestFailedException(); } catch (ArgumentException ae) { Assert.Equal("The name must not be null or empty.", ae.Message); } }
static void Main() { Workspace workspace = new Workspace("HTTP-based health checks example", "An example of how to use the HTTP-based health checks feature"); Model model = workspace.Model; ViewSet views = workspace.Views; SoftwareSystem structurizr = model.AddSoftwareSystem("Structurizr", "A publishing platform for software architecture diagrams and documentation based upon the C4 model."); Container webApplication = structurizr.AddContainer("structurizr.com", "Provides all of the server-side functionality of Structurizr, serving static and dynamic content to users.", "Java and Spring MVC"); Container database = structurizr.AddContainer("Database", "Stores information about users, workspaces, etc.", "Relational Database Schema"); database.AddTags(DatabaseTag); webApplication.Uses(database, "Reads from and writes to", "JDBC"); DeploymentNode amazonWebServices = model.AddDeploymentNode("Amazon Web Services", "", "us-east-1"); DeploymentNode pivotalWebServices = amazonWebServices.AddDeploymentNode("Pivotal Web Services", "Platform as a Service provider.", "Cloud Foundry"); ContainerInstance liveWebApplication = pivotalWebServices.AddDeploymentNode("www.structurizr.com", "An open source Java EE web server.", "Apache Tomcat") .Add(webApplication); ContainerInstance liveDatabaseInstance = amazonWebServices.AddDeploymentNode("Amazon RDS", "Database as a Service provider.", "MySQL") .Add(database); // add health checks to the container instances, which return a simple HTTP 200 to say everything is okay liveWebApplication.AddHealthCheck("Web Application is running", "https://www.structurizr.com/health"); liveDatabaseInstance.AddHealthCheck("Database is accessible from Web Application", "https://www.structurizr.com/health/database"); // the pass/fail status from the health checks is used to supplement any deployment views that include the container instances that have health checks defined DeploymentView deploymentView = views.CreateDeploymentView(structurizr, "Deployment", "A deployment diagram showing the live environment."); deploymentView.Environment = "Live"; deploymentView.AddAllDeploymentNodes(); views.Configuration.Styles.Add(new ElementStyle(Tags.Element) { Color = "#ffffff" }); views.Configuration.Styles.Add(new ElementStyle(DatabaseTag) { Shape = Shape.Cylinder }); StructurizrClient structurizrClient = new StructurizrClient(ApiKey, ApiSecret); WorkspaceUtils.PrintWorkspaceAsJson(workspace); Console.ReadKey(); structurizrClient.PutWorkspaceAsync(WorkspaceId, workspace).Wait(); }
public void AddHealthCheck(string name, string url) { containerInstance.AddHealthCheck(name, url); }