コード例 #1
0
ファイル: Tests.cs プロジェクト: yonglehou/Mjolnir
        private async Task <ChartSet> IdealCommandAttribute(string key)
        {
            _testConfigProvider.Set("mjolnir.breaker." + key + ".minimumOperations", 5);
            _testConfigProvider.Set("mjolnir.breaker." + key + ".thresholdPercentage", 50);
            _testConfigProvider.Set("mjolnir.breaker." + key + ".trippedDurationMillis", 5000);
            _testConfigProvider.Set("mjolnir.metrics." + key + ".windowMillis", 10000);

            // Command timeout is defined on the interface.
            var instance = new HttpClientService();
            var proxy    = CommandInterceptor.CreateProxy <IHttpClientService>(instance);

            using (var server = new HttpServer(1))
            {
                var url = string.Format("http://*****:*****@"c:\hudl\logs\mjolnir-metrics-{0}-{1}.txt", key, DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")), _testStats.Metrics.Select(m => m.ToCsvLine()));

            return(new ChartSet
            {
                Name = "Ideal (Command Attribute)",
                Description = "30s @ 5/sec.<br/>Command: Inherited<br/>Timeout: 10000<br/>Server: Immediate 200<br/>Breaker: 50% / 10sec, min 5 ops, 5s tripped",
                Charts = GatherChartData(_testStats.Metrics, key, key + ".IHttpClientService-MakeRequest"),
            });
        }
コード例 #2
0
ファイル: Tests.cs プロジェクト: yonglehou/Mjolnir
        // I've made a couple passes at trying to refactor out the scenarios, but haven't
        // come across one that feels right. My leaning right now is to separate server behavior
        // and client behavior, and provide a couple config objects to each. That way we could
        // define somewhat generic server and client behavior and mix/match them.
        //
        // I think we need to write about 8-10 different scenarios with different configurations
        // and server behavior to understand how to refactor these in a way that makes sense.
        //
        // Versaw suggested using observables, which sound fitting.
        // http://msdn.microsoft.com/en-us/library/hh242977(v=vs.103).aspx
        //
        // But for now ... copypasta.

        private async Task <ChartSet> IdealInheritedCommand(string key)
        {
            _testConfigProvider.Set("mjolnir.breaker." + key + ".minimumOperations", 5);
            _testConfigProvider.Set("mjolnir.breaker." + key + ".thresholdPercentage", 50);
            _testConfigProvider.Set("mjolnir.breaker." + key + ".trippedDurationMillis", 5000);
            _testConfigProvider.Set("mjolnir.metrics." + key + ".windowMillis", 10000);

            using (var server = new HttpServer(1))
            {
                var url = string.Format("http://*****:*****@"c:\hudl\logs\mjolnir-metrics-{0}-{1}.txt", key, DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")), _testStats.Metrics.Select(m => m.ToCsvLine()));

            return(new ChartSet
            {
                Name = "Ideal (Inherited Command)",
                Description = "30s @ 5/sec.<br/>Command: Inherited<br/>Timeout: 10000<br/>Server: Immediate 200<br/>Breaker: 50% / 10sec, min 5 ops, 5s tripped",
                Charts = GatherChartData(_testStats.Metrics, key, key + ".HttpClient"),
            });
        }
コード例 #3
0
ファイル: Tests.cs プロジェクト: yonglehou/Mjolnir
        private async Task <ChartSet> ErrorsInTheMiddle(string key)
        {
            _testConfigProvider.Set("mjolnir.breaker." + key + ".minimumOperations", 5);
            _testConfigProvider.Set("mjolnir.breaker." + key + ".thresholdPercentage", 50);
            _testConfigProvider.Set("mjolnir.breaker." + key + ".trippedDurationMillis", 5000);
            _testConfigProvider.Set("mjolnir.metrics." + key + ".windowMillis", 10000);

            // Cranked up the threads here. We're going to sleeping on the server just a bit longer than
            // the timeout, so there's potential for server threads to grow while we throw more requests
            // at them.
            using (var server = new HttpServer(1))
            {
                var url = string.Format("http://*****:*****@"c:\hudl\logs\mjolnir-metrics-{0}-{1}.txt", key, DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")), _testStats.Metrics.Select(m => m.ToCsvLine()));

            return(new ChartSet
            {
                Name = "Error for 5s",
                Description = "30s @ 5/sec.<br/>Command: Inherited<br/>Timeout: 10000<br/>Server: 500 for 5 seconds in the middle<br/>Breaker: 50% / 10sec, min 5 ops, 5s tripped",
                Charts = GatherChartData(_testStats.Metrics, key, key + ".HttpClient"),
            });
        }