Ejemplo n.º 1
0
 public BadRequestCommand(TestCircuitBreaker circuitBreaker, ExecutionIsolationStrategy isolationType)
     : base(new TestCommandBuilder()
 {
     CircuitBreaker            = circuitBreaker,
     CommandPropertiesDefaults = UnitTestSetterFactory.GetCommandPropertiesSetter().WithExecutionIsolationStrategy(isolationType),
 })
 {
 }
 public KnownFailureTestCommandWithoutFallback(TestCircuitBreaker circuitBreaker)
     : base(new TestCommandBuilder()
 {
     CircuitBreaker = circuitBreaker,
     Metrics        = circuitBreaker.Metrics,
 })
 {
 }
 public CommandWithCheckedException(TestCircuitBreaker circuitBreaker)
     : base(new TestCommandBuilder()
 {
     CircuitBreaker            = circuitBreaker,
     Metrics                   = circuitBreaker.Metrics,
     CommandPropertiesDefaults = UnitTestSetterFactory.GetCommandPropertiesSetter().WithExecutionIsolationThreadTimeout(Timeout.InfiniteTimeSpan),
 })
 {
 }
 public KnownFailureTestCommandWithFallback(TestCircuitBreaker circuitBreaker, bool fallbackEnabled)
     : base(new TestCommandBuilder()
     {
         CircuitBreaker = circuitBreaker,
         Metrics = circuitBreaker.Metrics,
         CommandPropertiesDefaults = UnitTestSetterFactory.GetCommandPropertiesSetter().WithFallbackEnabled(fallbackEnabled)
     })
 {
 }
Ejemplo n.º 5
0
 public RequestCacheThreadRejectionWithoutFallback(TestCircuitBreaker circuitBreaker, CountdownEvent completionLatch)
     : base(new TestCommandBuilder()
 {
     CircuitBreaker = circuitBreaker,
     Metrics        = circuitBreaker.Metrics,
     ThreadPool     = new RejectingThreadPool(),
 })
 {
     this.completionLatch = completionLatch;
 }
Ejemplo n.º 6
0
 public SuccessfulCacheableCommand(TestCircuitBreaker circuitBreaker, bool cacheEnabled, string value)
     : base(new TestCommandBuilder()
 {
     CircuitBreaker = circuitBreaker,
     Metrics        = circuitBreaker.Metrics,
 })
 {
     this.value        = value;
     this.cacheEnabled = cacheEnabled;
 }
Ejemplo n.º 7
0
 public TestSemaphoreCommandWithSlowFallback(TestCircuitBreaker circuitBreaker, int fallbackSemaphoreExecutionCount, TimeSpan fallbackSleep)
     : base(new TestCommandBuilder()
 {
     CircuitBreaker            = circuitBreaker,
     Metrics                   = circuitBreaker.Metrics,
     CommandPropertiesDefaults = UnitTestSetterFactory.GetCommandPropertiesSetter().WithFallbackIsolationSemaphoreMaxConcurrentRequests(fallbackSemaphoreExecutionCount)
 })
 {
     this.fallbackSleep = fallbackSleep;
 }
Ejemplo n.º 8
0
 public RequestCacheNullPointerExceptionCase(TestCircuitBreaker circuitBreaker)
     : base(new TestCommandBuilder()
 {
     CircuitBreaker            = circuitBreaker,
     Metrics                   = circuitBreaker.Metrics,
     CommandPropertiesDefaults = UnitTestSetterFactory.GetCommandPropertiesSetter().WithExecutionIsolationThreadTimeoutInMilliseconds(200),
 })
 {
     // we want it to timeout
 }
 public SlowCacheableCommand(TestCircuitBreaker circuitBreaker, string value, TimeSpan duration)
     : base(new TestCommandBuilder()
 {
     CircuitBreaker = circuitBreaker,
     Metrics        = circuitBreaker.Metrics,
 })
 {
     this.value    = value;
     this.duration = duration;
 }
 public SuccessfulCacheableCommandViaSemaphore(TestCircuitBreaker circuitBreaker, bool cacheEnabled, string value)
     : base(new TestCommandBuilder()
 {
     CircuitBreaker            = circuitBreaker,
     Metrics                   = circuitBreaker.Metrics,
     CommandPropertiesDefaults = UnitTestSetterFactory.GetCommandPropertiesSetter().WithExecutionIsolationStrategy(ExecutionIsolationStrategy.Semaphore),
 })
 {
     this.value        = value;
     this.cacheEnabled = cacheEnabled;
 }
Ejemplo n.º 11
0
 public CommandWithCustomThreadPool(TestCircuitBreaker circuitBreaker, IHystrixThreadPool threadPool, TimeSpan sleepTime, HystrixCommandPropertiesSetter properties)
     : base(new TestCommandBuilder()
 {
     ThreadPool                = threadPool,
     CircuitBreaker            = circuitBreaker,
     Metrics                   = circuitBreaker.Metrics,
     CommandPropertiesDefaults = properties,
 })
 {
     this.sleepTime = sleepTime;
 }
 public TestCommandRejection(TestCircuitBreaker circuitBreaker, IHystrixThreadPool threadPool, TimeSpan sleepTime, TimeSpan timeout, int fallbackBehavior)
     : base(new TestCommandBuilder()
 {
     ThreadPool                = threadPool,
     CircuitBreaker            = circuitBreaker,
     Metrics                   = circuitBreaker.Metrics,
     CommandPropertiesDefaults = UnitTestSetterFactory.GetCommandPropertiesSetter().WithExecutionIsolationThreadTimeout(timeout)
 })
 {
     this.fallbackBehavior = fallbackBehavior;
     this.sleepTime        = sleepTime;
 }
 public TestSemaphoreCommand(TestCircuitBreaker circuitBreaker, TryableSemaphore semaphore, TimeSpan executionSleep)
     : base(new TestCommandBuilder()
 {
     CircuitBreaker            = circuitBreaker,
     Metrics                   = circuitBreaker.Metrics,
     CommandPropertiesDefaults = UnitTestSetterFactory.GetCommandPropertiesSetter()
                                 .WithExecutionIsolationStrategy(ExecutionIsolationStrategy.Semaphore),
     ExecutionSemaphore = semaphore,
 })
 {
     this.executionSleep = executionSleep;
 }
 public TestSemaphoreCommand(TestCircuitBreaker circuitBreaker, int executionSemaphoreCount, TimeSpan executionSleep)
     : base(new TestCommandBuilder()
 {
     CircuitBreaker            = circuitBreaker,
     Metrics                   = circuitBreaker.Metrics,
     CommandPropertiesDefaults = UnitTestSetterFactory.GetCommandPropertiesSetter()
                                 .WithExecutionIsolationStrategy(ExecutionIsolationStrategy.Semaphore)
                                 .WithExecutionIsolationSemaphoreMaxConcurrentRequests(executionSemaphoreCount),
 })
 {
     this.executionSleep = executionSleep;
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="circuitBreaker"></param>
 /// <param name="semaphore"></param>
 /// <param name="startLatch">this command calls {@link java.util.concurrent.CountDownLatch#countDown()} immediately upon running</param>
 /// <param name="waitLatch">this command calls {@link java.util.concurrent.CountDownLatch#await()} once it starts to run.  The caller can use the latch to signal the command to finish</param>
 public LatchedSemaphoreCommand(TestCircuitBreaker circuitBreaker, TryableSemaphore semaphore, CountdownEvent startLatch, CountdownEvent waitLatch)
     : base(new TestCommandBuilder()
 {
     CircuitBreaker            = circuitBreaker,
     Metrics                   = circuitBreaker.Metrics,
     CommandPropertiesDefaults = UnitTestSetterFactory.GetCommandPropertiesSetter()
                                 .WithExecutionIsolationStrategy(ExecutionIsolationStrategy.Semaphore),
     ExecutionSemaphore = semaphore,
 })
 {
     this.startLatch = startLatch;
     this.waitLatch  = waitLatch;
 }
Ejemplo n.º 16
0
        public TestCommandBuilder()
        {
            TestCircuitBreaker cb = new TestCircuitBreaker();

            Owner                        = CommandGroupForUnitTest.OwnerOne;
            DependencyKey                = null;
            ThreadPoolKey                = null;
            CircuitBreaker               = cb;
            ThreadPool                   = null;
            CommandPropertiesDefaults    = UnitTestSetterFactory.GetCommandPropertiesSetter();
            ThreadPoolPropertiesDefaults = UnitTestSetterFactory.GetThreadPoolPropertiesSetter();
            Metrics                      = cb.Metrics;
            FallbackSemaphore            = null;
            ExecutionSemaphore           = null;
            ExecutionHook                = new TestExecutionHook();
        }