Esempio n. 1
0
 public void CanClearFailedJobs()
 {
     Job.create("jobs", "resque.BadJob");
     worker.work(0);
     Assert.AreEqual(1, Resque.failure.count());
     Resque.failure.clear();
     Assert.AreEqual(0, Resque.failure.count());
 }
Esempio n. 2
0
        public void CanReQueueJobs()
        {
            Job.create("jobs", "resque.DummyJob", 20, "/tmp");
            Job job = Resque.Reserve("jobs");

            job.recreate();
            Assert.That(job, Is.EqualTo(Resque.Reserve("jobs")));
        }
Esempio n. 3
0
        public void CatchesExceptionalJobs()
        {
            Job.create("jobs", "resque.BadJob");
            Job.create("jobs", "resque.BadJob");
            worker.work(0);
            worker.work(0);
            worker.work(0);

            Assert.AreEqual(2, Resque.failure.count());
        }
Esempio n. 4
0
        public void ProcesesAllQueuesInAlphabeticalOrder()
        {
            Job.create("high", "resque.GoodJob");
            Job.create("critical", "resque.GoodJob");
            Job.create("blahblah", "resque.GoodJob");

            worker = new Worker("*");

            //worker.work(0, (List<String> queueList) => { int a; });
        }
Esempio n. 5
0
        public void CanGrabJobsOffAQueue()
        {
            //Job.create("jobs", "dummy-job", 20, "/tmp"); FIXME NEED TO DEAL WITH THIS
            Job.create("jobs", "resque.DummyJob", 20, "/tmp");
            Job job = Resque.Reserve("jobs");

            Assert.AreEqual("resque.DummyJob", job.PayloadClass().FullName);
            var num = job.args()[0];

            Assert.AreEqual(20, num);
            Assert.That("/tmp", Is.EqualTo(job.args()[1]));
        }
Esempio n. 6
0
        public void CanWorkOnMultipleQueues()
        {
            Job.create("high", "resque.GoodJob");
            Job.create("critical", "resque.GoodJob");

            worker = new Worker(new string[] { "critical", "high" });

            worker.process();
            Assert.AreEqual(Resque.size("high"), 1);
            Assert.AreEqual(Resque.size("critical"), 0);

            worker.process();
            Assert.AreEqual(Resque.size("high"), 0);
        }
Esempio n. 7
0
        public void CanPeekAtFailedJobs()
        {
            for (int i = 0; i < 10; i++)
            {
                Job.create("jobs", "resque.BadJob");
            }
            worker.work(0);

            Assert.AreEqual(10, Resque.failure.count());

            Byte[][] b = null;

            Assert.AreEqual(Resque.failure.all().Length, 10);
        }
Esempio n. 8
0
        public void CanTestForEquality()
        {
            Assert.IsTrue(Job.create("jobs", "resque.DummyJob", 20, "/tmp"));
            Assert.IsTrue(Job.create("jobs", "resque.DummyJob", 20, "/tmp"));
            //Assert.IsTrue(Job.create("jobs", "dummy-job", 20, "/tmp"));  NEED TO  MAKE THIS WORK
            Assert.That(Resque.Reserve("jobs"), Is.EqualTo(Resque.Reserve("jobs")));

            Assert.IsTrue(Job.create("jobs", "resque.NotDummyJob", 20, "/tmp"));
            Assert.IsTrue(Job.create("jobs", "resque.DummyJob", 20, "/tmp"));
            Assert.That(Resque.Reserve("jobs"), Is.Not.EqualTo(Resque.Reserve("jobs")));

            Assert.IsTrue(Job.create("jobs", "resque.DummyJob", 20, "/tmp"));
            Assert.IsTrue(Job.create("jobs", "resque.DummyJob", 30, "/tmp"));
            Assert.That(Resque.Reserve("jobs"), Is.Not.EqualTo(Resque.Reserve("jobs")));
        }
Esempio n. 9
0
        public static bool enqueue(string className, params object[] args)
        {
            Type workerType = Type.GetType(className);

            System.Reflection.MethodInfo methodInfo = workerType.GetMethod("queue", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.FlattenHierarchy);
            if (methodInfo == null)
            {
                throw new NoQueueError();
            }
            string queue = (string)methodInfo.Invoke(null, null);

            if (String.IsNullOrEmpty(queue))
            {
                throw new NoQueueError();
            }
            return(Job.create(queue, className, args));
        }
Esempio n. 10
0
        public void CanWorkOnAllQueues()
        {
            Job.create("high", "resque.GoodJob");
            Job.create("critical", "resque.GoodJob");
            Job.create("blahblah", "resque.GoodJob");

            worker = new Worker("*");

            worker.work(0);

            Console.WriteLine(Resque.size("high"));
            Console.WriteLine(Resque.size("critical"));
            Console.WriteLine(Resque.size("blahblah"));

            Assert.AreEqual(Resque.size("high"), 0);
            Assert.AreEqual(Resque.size("critical"), 0);
            Assert.AreEqual(Resque.size("blahblah"), 0);
        }
Esempio n. 11
0
 public void recreate()
 {
     Job.create(queue, PayloadClass().FullName, args().ToArray());
 }
Esempio n. 12
0
 public void CanAskResqueForQueueSize()
 {
     Assert.That(0, Is.EqualTo(Resque.size("a_queue")));
     Job.create("a_queue", "resque.DummyJob", 1, "asdf");
     Assert.That(1, Is.EqualTo(Resque.size("a_queue")));
 }
Esempio n. 13
0
 public void CanPutJobsOnAQueue()
 {
     Assert.IsTrue(Job.create("jobs", "DummyJob", 20, "/tmp"));
     Assert.IsTrue(Job.create("jobs", "DummyJob", 20, "/tmp"));
 }
Esempio n. 14
0
 internal void TryToCreateJobWithNoClassName()
 {
     Job.create("jobs", null);
 }
Esempio n. 15
0
 public void KeepsStats()
 {
     Job.create("jobs", "resque.DummyJob", 20, "/tmp");
 }