X-Git-Url: https://code.grnet.gr/git/ganeti-local/blobdiff_plain/a06c6ae87a44ea6951579f0256245f3cc6a68490..7939f60cf03bd318847b158a448d50f7ca51068c:/test/ganeti.jqueue_unittest.py diff --git a/test/ganeti.jqueue_unittest.py b/test/ganeti.jqueue_unittest.py index dcbad14..41b4c4b 100755 --- a/test/ganeti.jqueue_unittest.py +++ b/test/ganeti.jqueue_unittest.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -# Copyright (C) 2010, 2011 Google Inc. +# Copyright (C) 2010, 2011, 2012 Google Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -309,10 +309,11 @@ class TestQueuedJob(unittest.TestCase): ["unknown-field"]) self.assertEqual(job.GetInfo(["summary"]), [[op.input.Summary() for op in job.ops]]) + self.assertFalse(job.archived) job1 = jqueue._QueuedJob(None, job_id, ops, True) _Check(job1) - job2 = jqueue._QueuedJob.Restore(None, job1.Serialize(), True) + job2 = jqueue._QueuedJob.Restore(None, job1.Serialize(), True, False) _Check(job2) self.assertEqual(job1.Serialize(), job2.Serialize()) @@ -323,6 +324,16 @@ class TestQueuedJob(unittest.TestCase): job = jqueue._QueuedJob(None, 1, [opcodes.OpTestDelay()], True) self.assertTrue(job.writable) + def testArchived(self): + job = jqueue._QueuedJob(None, 1, [opcodes.OpTestDelay()], False) + self.assertFalse(job.archived) + + newjob = jqueue._QueuedJob.Restore(None, job.Serialize(), True, True) + self.assertTrue(newjob.archived) + + newjob2 = jqueue._QueuedJob.Restore(None, newjob.Serialize(), True, False) + self.assertFalse(newjob2.archived) + def testPriority(self): job_id = 4283 ops = [ @@ -702,7 +713,7 @@ class TestJobProcessor(unittest.TestCase, _JobProcessorTestUtils): # Check job status self.assertEqual(job.CalcStatus(), constants.JOB_STATUS_ERROR) - self.assertEqual(job.GetInfo(["id"]), [str(job_id)]) + self.assertEqual(job.GetInfo(["id"]), [job_id]) self.assertEqual(job.GetInfo(["status"]), [constants.JOB_STATUS_ERROR]) # Check opcode status @@ -926,7 +937,7 @@ class TestJobProcessor(unittest.TestCase, _JobProcessorTestUtils): for i in range(3)] # Create job - job_id = str(28492) + job_id = 28492 job = self._CreateJob(queue, job_id, ops) self.assertEqual(job.CalcStatus(), constants.JOB_STATUS_QUEUED) @@ -994,7 +1005,7 @@ class TestJobProcessor(unittest.TestCase, _JobProcessorTestUtils): self.assert_(job.ops_iter) # Serialize and restore (simulates program restart) - newjob = jqueue._QueuedJob.Restore(queue, job.Serialize(), True) + newjob = jqueue._QueuedJob.Restore(queue, job.Serialize(), True, False) self.assertFalse(newjob.ops_iter) self._TestPartial(newjob, successcount) @@ -1039,7 +1050,7 @@ class TestJobProcessor(unittest.TestCase, _JobProcessorTestUtils): self.assertRaises(IndexError, queue.GetNextUpdate) # ... also after being restored - job2 = jqueue._QueuedJob.Restore(queue, job.Serialize(), True) + job2 = jqueue._QueuedJob.Restore(queue, job.Serialize(), True, False) # Calling the processor on a finished job should be a no-op self.assertEqual(jqueue._JobProcessor(queue, opexec, job2)(), jqueue._JobProcessor.FINISHED) @@ -1141,7 +1152,7 @@ class TestJobProcessor(unittest.TestCase, _JobProcessorTestUtils): self._CheckLogMessages(job, logmsgcount) # Serialize and restore (simulates program restart) - newjob = jqueue._QueuedJob.Restore(queue, job.Serialize(), True) + newjob = jqueue._QueuedJob.Restore(queue, job.Serialize(), True, False) self._CheckLogMessages(newjob, logmsgcount) # Check each message