Ejemplo n.º 1
0
        public void AddCheck_ShouldAddCheckOnlyOnce_WhenSameCheckAddedMultipleTimes(IHealthCheck check)
        {
            HealthMonitor.AddCheck(check).Should().BeTrue();
            HealthMonitor.AddCheck(check).Should().BeFalse();
            HealthMonitor.AddCheck(check).Should().BeFalse();
            HealthMonitor.AddCheck(check).Should().BeFalse();

            HealthMonitor.Checks.Count.Should().Be(1);
        }
Ejemplo n.º 2
0
        public async void Tick_ShouldNotCallHealthCheck_WhenItDoesNotNeedToRun(IHealthCheck check)
        {
            check.NeedsToRun.Returns(false);
            HealthMonitor.AddCheck(check).Should().BeTrue();

            HealthMonitor.Tick();

            // wait for the queue to run
            await Task.Delay(5);

            check.DidNotReceive().RunAsync();
        }
Ejemplo n.º 3
0
        internal static void Main(string[] args)
        {
            // Initialize the logger from app.config settings
            Log.Logger = new LoggerConfiguration().ReadFrom.AppSettings().Enrich.WithThreadId().CreateLogger();

            // Create healthcheck that uses a ClusterManager based on app.config username/password
            // This will cause monitoring failure alerts if no valid config is present
            HealthMonitor.AddCheck(new BucketsHealthCheck());
            HealthMonitor.AddCheck(new ClusterHealthCheck());

            HealthMonitor.AddCheck(new PingHealthCheck());

            // Add a logging notifier which, by default, logs the results to console as json
            HealthMonitor.AddNotifier(LibLogNotifierSettings.Create().ToNotifier());

            // Start the ticking loop
            HealthMonitor.StartTicking();

            // "press any key to stop"
            Console.ReadKey();
        }
Ejemplo n.º 4
0
        public void AddCheck_ShouldAddCheck(IHealthCheck check)
        {
            HealthMonitor.AddCheck(check).Should().BeTrue();

            HealthMonitor.Checks.Count.Should().Be(1);
        }