public void TestEmptyStreamProducesZeros()
        {
            IHystrixCollapserKey key = HystrixCollapserKeyDefault.AsKey("RollingCollapser-A");

            stream = RollingCollapserEventCounterStream.GetInstance(key, 10, 100);
            stream.StartCachingStreamValuesIfUnstarted();

            CountdownEvent latch = new CountdownEvent(1);

            stream.Observe().Take(10).Subscribe(GetSubscriber(output, latch));

            // no writes
            try
            {
                Assert.True(latch.Wait(10000));
            }
            catch (Exception)
            {
                Assert.True(false, "Interrupted ex");
            }

            output.WriteLine("ReqLog : " + HystrixRequestLog.CurrentRequestLog.GetExecutedCommandsAsString());
            Assert.Equal(CollapserEventTypeHelper.Values.Count, stream.Latest.Length);
            Assert.Equal(0, stream.GetLatest(CollapserEventType.ADDED_TO_BATCH));
            Assert.Equal(0, stream.GetLatest(CollapserEventType.BATCH_EXECUTED));
            Assert.Equal(0, stream.GetLatest(CollapserEventType.RESPONSE_FROM_CACHE));
        }
Esempio n. 2
0
        public void TestEmptyStreamProducesZeros()
        {
            var key      = HystrixCollapserKeyDefault.AsKey("RollingCollapser-A");
            var latch    = new CountdownEvent(1);
            var observer = new LatchedObserver(output, latch);

            stream            = RollingCollapserEventCounterStream.GetInstance(key, 10, 100);
            latchSubscription = stream.Observe().Subscribe(observer);
            Assert.True(Time.WaitUntil(() => observer.StreamRunning, 1000), "Stream failed to start");

            Assert.True(WaitForLatchedObserverToUpdate(observer, 1, 500, output), "Latch took to long to update");

            Assert.Equal(CollapserEventTypeHelper.Values.Count, stream.Latest.Length);
            Assert.Equal(0, stream.GetLatest(CollapserEventType.ADDED_TO_BATCH));
            Assert.Equal(0, stream.GetLatest(CollapserEventType.BATCH_EXECUTED));
            Assert.Equal(0, stream.GetLatest(CollapserEventType.RESPONSE_FROM_CACHE));
        }
Esempio n. 3
0
 public long GetRollingCount(CollapserEventType collapserEventType)
 {
     return(_rollingCollapserEventCounterStream.GetLatest(collapserEventType));
 }