예제 #1
0
    def test_trashing_claimed_job(self):

        with base.connect_close(self.board):
            with base.flush(self.client):
                j = self.board.post('test', p_utils.temporary_log_book())
            self.assertEqual(states.UNCLAIMED, j.state)
            with base.flush(self.client):
                self.board.claim(j, self.board.name)
            self.assertEqual(states.CLAIMED, j.state)

            with base.flush(self.client):
                self.board.trash(j, self.board.name)

            trashed = []
            jobs = []
            paths = list(six.iteritems(self.client.storage.paths))
            for (path, value) in paths:
                if path in self.bad_paths:
                    continue
                if path.find(impl_zookeeper.TRASH_FOLDER) > -1:
                    trashed.append(path)
                elif (path.find(self.board._job_base) > -1
                        and not path.endswith(impl_zookeeper.LOCK_POSTFIX)):
                    jobs.append(path)

            self.assertEqual(len(trashed), 1)
            self.assertEqual(len(jobs), 0)
예제 #2
0
    def test_posting_state_lock_lost(self):

        with base.connect_close(self.board):
            with base.flush(self.client):
                j = self.board.post('test', p_utils.temporary_log_book())
            self.assertEqual(states.UNCLAIMED, j.state)
            with base.flush(self.client):
                self.board.claim(j, self.board.name)
            self.assertEqual(states.CLAIMED, j.state)

            # Forcefully delete the lock from the backend storage to make
            # sure the job becomes unclaimed (this may happen if some admin
            # manually deletes the lock).
            paths = list(six.iteritems(self.client.storage.paths))
            for (path, value) in paths:
                if path in self.bad_paths:
                    continue
                if path.endswith("lock"):
                    self.client.storage.pop(path)
            self.assertEqual(states.UNCLAIMED, j.state)