public void Verify_probe_na()
        {
            var knowledgeBaseProvider = _provider.GetService <IKnowledgeBaseProvider>();
            var probe = new SocketDescriptorThrottlingProbe(null, knowledgeBaseProvider);

            NodeSnapshot snapshot = new FakeNodeSnapshot1(10, 4, 4.2M);

            var result = probe.Execute(snapshot);

            result.Status.ShouldBe(ProbeResultStatus.NA);
            result.KB.Id.ShouldBe(typeof(SocketDescriptorThrottlingProbe).GetIdentifier());
        }
        public void Verify_probe_healthy_condition()
        {
            var knowledgeBaseProvider = _provider.GetService <IKnowledgeBaseProvider>();
            var config = _provider.GetService <HareDuConfig>();
            var probe  = new SocketDescriptorThrottlingProbe(config.Diagnostics, knowledgeBaseProvider);

            NodeSnapshot snapshot = new FakeNodeSnapshot1(10, 4, 4.2M);

            var result = probe.Execute(snapshot);

            result.Status.ShouldBe(ProbeResultStatus.Healthy);
            result.KB.Id.ShouldBe(typeof(SocketDescriptorThrottlingProbe).GetIdentifier());
        }
        public void Verify_probe_na()
        {
            var knowledgeBaseProvider = _services.GetService <IKnowledgeBaseProvider>();
            var probe = new SocketDescriptorThrottlingProbe(null, knowledgeBaseProvider);

            NodeSnapshot snapshot = new (){ OS = new () { SocketDescriptors = new () { Available = 10, Used = 4, UsageRate = 4.2M } } };

            var result = probe.Execute(snapshot);

            Assert.Multiple(() =>
            {
                Assert.AreEqual(ProbeResultStatus.NA, result.Status);
                Assert.AreEqual(typeof(SocketDescriptorThrottlingProbe).GetIdentifier(), result.KB.Id);
            });
        }
    }
        public void Verify_probe_healthy_condition()
        {
            HareDuConfig config = new () { Diagnostics = new () { Probes = new () { SocketUsageThresholdCoefficient = 0.60M } } };
            var          knowledgeBaseProvider = _services.GetService <IKnowledgeBaseProvider>();
            var          probe = new SocketDescriptorThrottlingProbe(config.Diagnostics, knowledgeBaseProvider);

            NodeSnapshot snapshot = new (){ OS = new () { SocketDescriptors = new () { Available = 10, Used = 4, UsageRate = 4.2M } } };

            var result = probe.Execute(snapshot);

            Assert.Multiple(() =>
            {
                Assert.AreEqual(ProbeResultStatus.Healthy, result.Status);
                Assert.AreEqual(typeof(SocketDescriptorThrottlingProbe).GetIdentifier(), result.KB.Id);
            });
        }

        [Test]
        public void Verify_probe_warning_condition()
        {
            HareDuConfig config = new () { Diagnostics = new () { Probes = new () { SocketUsageThresholdCoefficient = 0.60M } } };
            var          knowledgeBaseProvider = _services.GetService <IKnowledgeBaseProvider>();
            var          probe = new SocketDescriptorThrottlingProbe(config.Diagnostics, knowledgeBaseProvider);

            NodeSnapshot snapshot = new (){ OS = new () { SocketDescriptors = new () { Available = 10, Used = 9, UsageRate = 4.2M } } };

            var result = probe.Execute(snapshot);

            Assert.Multiple(() =>
            {
                Assert.AreEqual(ProbeResultStatus.Warning, result.Status);
                Assert.AreEqual(typeof(SocketDescriptorThrottlingProbe).GetIdentifier(), result.KB.Id);
            });
        }

        [Test(Description = "When sockets used >= calculated high watermark and calculated high watermark >= max sockets available")]