public void Returns_Values_From_Default_Json_If_Specific_Json_Is_Not_Present_Or_Invalid()
        {
            ConfigurationManager.AppSettings["HystrixJsonConfigConfigurationService-BaseLocation"]    = "http://hystrix-configuration.staging.travix.com/";
            ConfigurationManager.AppSettings["HystrixJsonConfigConfigurationService-LocationPattern"] = "{0}-{1}.json";

            var commandIdentifier    = new HystrixCommandIdentifier("NoExisting", "Command");
            var configurationService = new HystrixJsonConfigConfigurationService(commandIdentifier);

            // act
            var value = configurationService.GetCommandTimeoutInMilliseconds();

            Assert.Equal(60000, value);
        }
        public void Returns_Remote_Config_Value_From_Http_Scheme_Json_File()
        {
            ConfigurationManager.AppSettings["HystrixJsonConfigConfigurationService-BaseLocation"]    = "http://hystrix-configuration.staging.travix.com/";
            ConfigurationManager.AppSettings["HystrixJsonConfigConfigurationService-LocationPattern"] = "{0}-{1}.json";

            var commandIdentifier    = new HystrixCommandIdentifier("Group", "Command");
            var configurationService = new HystrixJsonConfigConfigurationService(commandIdentifier);

            // act
            var value = configurationService.GetCommandTimeoutInMilliseconds();

            Assert.Equal(25000, value);
        }
        public void Returns_Remote_Config_Value_From_File_Scheme()
        {
            SetLocalFileBaseLocation();
            ConfigurationManager.AppSettings["HystrixJsonConfigConfigurationService-LocationPattern"] = "{0}-{1}.json";

            var commandIdentifier    = new HystrixCommandIdentifier("Group", "Command");
            var configurationService = new HystrixJsonConfigConfigurationService(commandIdentifier);

            // act
            var value = configurationService.GetCommandTimeoutInMilliseconds();

            Assert.Equal(25000, value);
        }
Example #4
0
        public void Returns_Remote_Config_Value_From_File_Scheme()
        {
            var options = new HystrixJsonConfigurationSourceOptions
            {
                BaseLocation    = GetLocalBaseLocation(),
                LocationPattern = "{0}-{1}.json"
            };

            var commandIdentifier    = new HystrixCommandIdentifier("Group", "Command");
            var configurationService = new HystrixJsonConfigConfigurationService(commandIdentifier, options);

            // Act
            var value = configurationService.GetCommandTimeoutInMilliseconds();

            Assert.Equal(25000, value);
        }
Example #5
0
        public void Returns_Values_From_Default_Json_If_Specific_Json_Is_Invalid()
        {
            using (var apiStub = new ApiStub())
            {
                apiStub.Get(
                    "/Group-Command.json",
                    (req, args) => @"This is { not a valid json """);

                apiStub.Get(
                    "/Default.json",
                    (req, args) => @"{
""HystrixCommandEnabled"": true,
""CommandTimeoutInMilliseconds"":50000,
""CircuitBreakerForcedOpen"":false,
""CircuitBreakerForcedClosed"":false,
""CircuitBreakerErrorThresholdPercentage"":50,
""CircuitBreakerSleepWindowInMilliseconds"":5000,
""CircuitBreakerRequestVolumeThreshold"":20,
""MetricsHealthSnapshotIntervalInMilliseconds"":500,
""MetricsRollingStatisticalWindowInMilliseconds"":10000,
""MetricsRollingStatisticalWindowBuckets"":10,
""MetricsRollingPercentileEnabled"":true,
""MetricsRollingPercentileWindowInMilliseconds"":60000,
""MetricsRollingPercentileWindowBuckets"":6,
""MetricsRollingPercentileBucketSize"":100
}");

                apiStub.Start();

                var options = new HystrixJsonConfigurationSourceOptions
                {
                    BaseLocation    = apiStub.Address,
                    LocationPattern = "{0}-{1}.json"
                };

                var commandIdentifier    = new HystrixCommandIdentifier("Group", "Command");
                var configurationService = new HystrixJsonConfigConfigurationService(commandIdentifier, options);

                // Act
                var value = configurationService.GetCommandTimeoutInMilliseconds();

                Assert.Equal(50000, value);
            }
        }