def test_queue_job(self): job = simcity.queue_job(Job({'_id': 'aaaa'}), 'ssh') assert_true(job['queue'] > 0) assert_equals(len(self.db.saved), 1) job = simcity.queue_job(simcity.get_job(), 'ssh') assert_true(job['queue'] > 0) assert_true(simcity.get_job()['queue'] > 0) job = simcity.finish_job(job) assert_true(job['archive'] > 0)
def test_finish_job(self): job = simcity.start_job() simcity.finish_job(job) assert_true(job['start'] > 0) assert_true(job['done'] > 0) assert_true(simcity.get_job()['done'] > 0) job = simcity.queue_job(job, 'ssh') assert_true(job['archive'] > 0)
def submit(self, command): job_id = 'job_' + self.prefix + uuid4().hex job = simcity.queue_job(Job({'_id': job_id}), self.method, host=self.host, database=self.database) try: job['batch_id'] = self._do_submit(job, command) except: simcity.archive_job(job, database=self.database) raise else: self.database.save(job) return job