public void Should_be_reflected_as_active_endpoints_in_the_heartbeat_summary() { var context = new MyContext(); HeartbeatSummary summary = null; Scenario.Define(context) .WithEndpoint <ManagementEndpoint>(c => c.AppConfig(PathToAppConfig)) .WithEndpoint <Endpoint1>() .WithEndpoint <Endpoint2>() .Done(c => { if (!TryGet("/api/heartbeats/stats", out summary, m => m.Active >= 2)) { return(false); } List <EndpointsView> endpoints; return(TryGetMany("/api/endpoints", out endpoints, e => e.Name.Contains("Endpoint1"))); }) .Run(TimeSpan.FromMinutes(2)); Assert.AreEqual(0, summary.Failing); }
public void Should_be_reflected_as_active_endpoints_in_the_heartbeat_summary() { var context = new MyContext(); HeartbeatSummary summary = null; Define(context) .WithEndpoint <ManagementEndpoint>(c => c.AppConfig(PathToAppConfig)) .WithEndpoint <Endpoint1>() .WithEndpoint <Endpoint2>() .Done(c => { List <EndpointsView> endpoints; if (!TryGetMany("/api/endpoints", out endpoints)) { return(false); } Console.WriteLine("Found {0} endpoints", endpoints.Count); Console.WriteLine(String.Join(Environment.NewLine, endpoints.Select(x => x.Name))); var endpoint1s = endpoints.Where(x => x.Name.Contains("Endpoint1")).ToArray(); if (endpoint1s.Length != 1) { Console.WriteLine("Endpoint 1 not registered"); return(false); } var endpoint2s = endpoints.Where(x => x.Name.Contains("Endpoint2")).ToArray(); if (endpoint2s.Length != 1) { Console.WriteLine("Endpoint 2 not registered"); return(false); } var otherEndpoints = endpoints.Except(endpoint1s).Except(endpoint2s).ToArray(); var foundOthers = false; foreach (var otherEndpoint in otherEndpoints) { if (otherEndpoint.MonitorHeartbeat) { Console.WriteLine("Disabling Heartbeats on {0}", otherEndpoint.Name); Patch("/api/endpoints/" + otherEndpoint.Id, new EndpointUpdateModel { MonitorHeartbeat = false }); foundOthers = true; } } if (foundOthers) { return(false); } HeartbeatSummary local; if (TryGet("/api/heartbeats/stats", out local)) { Console.WriteLine("Stats: Active({0}) Failing({1})", local.Active, local.Failing); summary = local; return(true); } Console.WriteLine("NOT DONE"); Thread.Sleep(500); return(false); }) .Run(TimeSpan.FromMinutes(2)); Assert.AreEqual(0, summary.Failing); Assert.AreEqual(2, summary.Active); }