예제 #1
0
        public async Task Do(IDictionary <string, object> stepParameters, IDictionary <string, object> pluginParameters, IList <IRpcClient> clients)
        {
            Log.Information($"Start to conditional stop...");

            // Get parameters
            stepParameters.TryGetTypedValue(SignalRConstants.Type, out string type, Convert.ToString);
            stepParameters.TryGetTypedValue(SignalRConstants.CriteriaMaxFailConnectionPercentage,
                                            out double criteriaMaxFailConnectionPercentage, Convert.ToDouble);
            stepParameters.TryGetTypedValue(SignalRConstants.CriteriaMaxFailConnectionAmount,
                                            out int criteriaMaxFailConnectionAmount, Convert.ToInt32);
            stepParameters.TryGetTypedValue(SignalRConstants.CriteriaMaxFailSendingPercentage,
                                            out double criteriaMaxFailSendingPercentage, Convert.ToDouble);

            // Get context
            pluginParameters.TryGetTypedValue($"{SignalRConstants.LatencyStep}.{type}",
                                              out long latencyStep, Convert.ToInt64);
            pluginParameters.TryGetTypedValue($"{SignalRConstants.LatencyMax}.{type}",
                                              out long latencyMax, Convert.ToInt64);

            var results = await Task.WhenAll(from client in clients
                                             select client.QueryAsync(stepParameters));

            // Merge statistics
            var merged = SignalRUtils.MergeStatistics(results, latencyMax, latencyStep);

            merged.TryGetTypedValue(SignalRConstants.StatisticsConnectionConnectSuccess,
                                    out long connectionSuccess, Convert.ToInt64);
            merged.TryGetTypedValue(SignalRConstants.StatisticsConnectionConnectFail,
                                    out long connectionFail, Convert.ToInt64);

            var connectionTotal          = connectionSuccess + connectionFail;
            var connectionFailPercentage = (double)connectionFail / connectionTotal;
            var largeLatencyPercentage   = GetLargeLatencyPercentage(merged, latencyMax);

            if (connectionFailPercentage > criteriaMaxFailConnectionPercentage)
            {
                var message = $"Connection fail percentage {connectionFailPercentage * 100}%" +
                              $" is greater than criteria {criteriaMaxFailConnectionPercentage * 100}%, stop benchmark";
                Log.Warning(message);
                throw new Exception(message);
            }
            if (connectionFail > criteriaMaxFailConnectionAmount)
            {
                var message = $"Connection fail amount {connectionFail}" +
                              $"is greater than {criteriaMaxFailConnectionAmount}, stop benchmark";
                Log.Warning(message);
                throw new Exception(message);
            }
            if (largeLatencyPercentage > criteriaMaxFailSendingPercentage)
            {
                var message = $"The percentage {largeLatencyPercentage * 100}%" +
                              $"of Sending latency greater than {latencyMax}" +
                              $" ms is larger than {criteriaMaxFailSendingPercentage * 100}%, stop benchmark";
                Log.Warning(message);
                throw new Exception(message);
            }
        }
예제 #2
0
        protected async Task LatencyEventerCallback(
            IDictionary <string, object> stepParameters,
            IDictionary <string, object> pluginParameters, IList <IRpcClient> clients)
        {
            var results = await Task.WhenAll(from client in clients
                                             select client.QueryAsync(stepParameters));

            // Merge statistics
            var merged = SignalRUtils.MergeStatistics(results, _latencyMax, _latencyStep);

            PrintAndSave(merged);
        }
예제 #3
0
        protected async Task ConnectionStatEventerCallback(
            IDictionary <string, object> stepParameters,
            IDictionary <string, object> pluginParameters, IList <IRpcClient> clients)
        {
            var results = await Task.WhenAll(from client in clients
                                             select client.QueryAsync(stepParameters));

            // Merge statistics
            var merged = SignalRUtils.MergeStatistics(results, _latencyMax, _latencyStep);
            var connectionStatMerged = SignalRUtils.MergeConnectionStatistics(results, _percentileList.ToArray());

            merged = merged.Union(connectionStatMerged).ToDictionary(entry => entry.Key, entry => entry.Value);
            PrintAndSave(merged);
        }