public void TestSequentialWorkQueueUpdate()
        {
            using (var queue = new RedisSequentialWorkQueue<string>(10, 10, TestConfig.SingleHost, TestConfig.RedisPort,1))
            {

                for (int i = 0; i < numMessages; ++i)
                {
                    queue.Enqueue(patients[0], messages0[i]);
                    queue.Enqueue(patients[1], messages1[i]);
                }

                for (int i = 0; i < numMessages / 2; ++i)
                {
                    queue.Update(patients[0], i, messages0[i] + "UPDATE");
               }
                queue.PrepareNextWorkItem();
                var batch = queue.Dequeue(numMessages / 2);
                // check that half of patient[0] messages are returned
                for (int i = 0; i < numMessages / 2; ++i)
                {
                    Assert.AreEqual(batch.DequeueItems[i], messages0[i] + "UPDATE");

                }
            }
        }
        public void TestSequentialWorkQueue()
        {
            using (var queue = new RedisSequentialWorkQueue <string>(10, 10, TestConfig.SingleHost, TestConfig.RedisPort, 1))
            {
                for (int i = 0; i < numMessages; ++i)
                {
                    queue.Enqueue(patients[0], messages0[i]);
                    queue.Enqueue(patients[1], messages1[i]);
                }

                queue.PrepareNextWorkItem();
                var batch = queue.Dequeue(numMessages / 2);
                // check that half of patient[0] messages are returned
                for (int i = 0; i < numMessages / 2; ++i)
                {
                    Assert.AreEqual(batch.DequeueItems[i], messages0[i]);
                }
                Assert.AreEqual(numMessages / 2, batch.DequeueItems.Count);
                Thread.Sleep(5000);
                Assert.IsTrue(queue.HarvestZombies());
                for (int i = 0; i < batch.DequeueItems.Count; ++i)
                {
                    batch.DoneProcessedWorkItem();
                }

                // check that all patient[1] messages are returned
                queue.PrepareNextWorkItem();
                batch = queue.Dequeue(2 * numMessages);
                // check that batch size is respected
                Assert.AreEqual(batch.DequeueItems.Count, numMessages);
                for (int i = 0; i < numMessages; ++i)
                {
                    Assert.AreEqual(batch.DequeueItems[i], messages1[i]);
                    batch.DoneProcessedWorkItem();
                }

                // check that there are numMessages/2 messages in the queue
                queue.PrepareNextWorkItem();
                batch = queue.Dequeue(numMessages);
                Assert.AreEqual(batch.DequeueItems.Count, numMessages / 2);

                // test pop and unlock
                batch.DoneProcessedWorkItem();
                int remaining = batch.DequeueItems.Count - 1;
                batch.PopAndUnlock();

                //process remaining items
                Assert.IsTrue(queue.PrepareNextWorkItem());
                batch = queue.Dequeue(remaining);
                Assert.AreEqual(batch.DequeueItems.Count, remaining);
                for (int i = 0; i < batch.DequeueItems.Count; ++i)
                {
                    batch.DoneProcessedWorkItem();
                }

                Assert.IsFalse(queue.PrepareNextWorkItem());
                batch = queue.Dequeue(remaining);
                Assert.AreEqual(batch.DequeueItems.Count, 0);
            }
        }
        public void TestSequentialWorkQueue()
        {
            using (var queue = new RedisSequentialWorkQueue<string>(10, 10, TestConfig.SingleHost, TestConfig.RedisPort, 1))
            {
              
                for (int i = 0; i < numMessages; ++i)
                {
                    queue.Enqueue(patients[0], messages0[i]);
                    queue.Enqueue(patients[1], messages1[i]);
                }

                queue.PrepareNextWorkItem();
                var batch = queue.Dequeue(numMessages/2);
                // check that half of patient[0] messages are returned
                for (int i = 0; i < numMessages/2; ++i)
                    Assert.AreEqual(batch.DequeueItems[i], messages0[i]);
                Assert.AreEqual(numMessages/2, batch.DequeueItems.Count);
                Thread.Sleep(5000);
                Assert.IsTrue(queue.HarvestZombies());
                for (int i = 0; i < batch.DequeueItems.Count; ++i)
                    batch.DoneProcessedWorkItem();
     

                // check that all patient[1] messages are returned
                queue.PrepareNextWorkItem();
                batch = queue.Dequeue(2*numMessages);
                // check that batch size is respected
                Assert.AreEqual(batch.DequeueItems.Count, numMessages);
                for (int i = 0; i < numMessages; ++i)
                {
                    Assert.AreEqual(batch.DequeueItems[i], messages1[i]);
                    batch.DoneProcessedWorkItem();
                }
           

                // check that there are numMessages/2 messages in the queue
                queue.PrepareNextWorkItem();
                batch = queue.Dequeue(numMessages);
                Assert.AreEqual(batch.DequeueItems.Count, numMessages/2);

                // test pop and unlock
                batch.DoneProcessedWorkItem();
                int remaining = batch.DequeueItems.Count-1;
                batch.PopAndUnlock();

                //process remaining items
                Assert.IsTrue(queue.PrepareNextWorkItem());
                batch = queue.Dequeue(remaining);
                Assert.AreEqual(batch.DequeueItems.Count, remaining);
                for (int i = 0; i < batch.DequeueItems.Count; ++i)
                    batch.DoneProcessedWorkItem();

                Assert.IsFalse(queue.PrepareNextWorkItem());
                batch = queue.Dequeue(remaining);
                Assert.AreEqual(batch.DequeueItems.Count, 0);
           
            }
 
        }
Beispiel #4
0
        public void TestSequentialWorkQueueUpdate()
        {
            using (var queue = new RedisSequentialWorkQueue <string>(10, 10, "127.0.0.1", 6379, 1))
            {
                for (int i = 0; i < numMessages; ++i)
                {
                    queue.Enqueue(patients[0], messages0[i]);
                    queue.Enqueue(patients[1], messages1[i]);
                }

                for (int i = 0; i < numMessages / 2; ++i)
                {
                    queue.Update(patients[0], i, messages0[i] + "UPDATE");
                }
                queue.PrepareNextWorkItem();
                var batch = queue.Dequeue(numMessages / 2);
                // check that half of patient[0] messages are returned
                for (int i = 0; i < numMessages / 2; ++i)
                {
                    Assert.AreEqual(batch.DequeueItems[i], messages0[i] + "UPDATE");
                }
            }
        }
Beispiel #5
0
        public void TestSequentialWorkQueueUpdate()
        {
            using (var queue =
                       new RedisSequentialWorkQueue <string>(10, 10, Config.LocalhostWithPassword, Config.LocalhostPort, 1)) {
                for (var i = 0; i < _numMessages; ++i)
                {
                    queue.Enqueue(this._patients[0], this._messages0[i]);
                    queue.Enqueue(this._patients[1], this._messages1[i]);
                }

                for (var i = 0; i < _numMessages / 2; ++i)
                {
                    queue.Update(this._patients[0], i, this._messages0[i] + "UPDATE");
                }

                queue.PrepareNextWorkItem();
                var batch = queue.Dequeue(_numMessages / 2);
                // check that half of patient[0] messages are returned
                for (var i = 0; i < _numMessages / 2; ++i)
                {
                    Assert.AreEqual(batch.DequeueItems[i], this._messages0[i] + "UPDATE");
                }
            }
        }