コード例 #1
0
 private void AssertHttpStats(INodesStatsResponse response)
 {
     foreach (var node in response.Nodes.Values)
     {
         node.Http.TotalOpened.Should().BeGreaterThan(2);
         node.Http.TotalOpened.Should().BeLessThan(100);
         node.Http.CurrentOpen.Should().BeLessThan(100);
     }
 }
コード例 #2
0
        private static void AssertHttpStats(IElasticClient c, INodesStatsResponse r, int i, int requestsPerIteration)
        {
            const int leeWay          = 10;
            var       connectionLimit = c.ConnectionSettings.ConnectionLimit;
            var       maxCurrent      = connectionLimit;
            var       maxCurrentOpen  = connectionLimit + 1; //cluster bootstrap opens it own connections

            foreach (var node in r.Nodes.Values)             //in our cluster we only have 1 node
            {
                node.Http.TotalOpened.Should().BeGreaterThan(2, "We want to see some concurrency");
                var h = node.Http;
                node.Http.CurrentOpen.Should().BeLessOrEqualTo(maxCurrentOpen, $"CurrentOpen exceed our connection limit {maxCurrent}");

                string errorMessage;
                int    iterationMax;

                if (!IsCurlHandler)
                {
                    //on non curl connections we expect full connection reuse
                    //we allow some leeway on the maxOpened because of connections setup and teared down
                    //during the initial bootstrap procudure from the test framework getting the cluster up.
                    iterationMax = maxCurrent + leeWay;
                    errorMessage = $"Total openend exceeded {maxCurrent} + leighway factor {leeWay}";
                }
                else
                {
                    var m = Math.Max(2, i + 1) + 1;
                    iterationMax = maxCurrent * m / 2 + leeWay;
                    errorMessage =
                        $"Expected some socket bleeding but iteration {i} exceeded iteration specific max {iterationMax} = (({maxCurrent} * {m}) / 2) + {leeWay}";
                }
                node.Http.TotalOpened.Should().BeLessOrEqualTo(iterationMax, errorMessage);
                if (i == -1)
                {
                    return;
                }

                Console.WriteLine(
                    $"Current Open: {h.CurrentOpen}, Total Opened: {h.TotalOpened}, Iteration Max = {iterationMax}, Iteration: {i}, Total Searches {(i + 1) * requestsPerIteration}");
            }
        }