diff options
-rw-r--r-- | obnamlib/plugins/force_lock_plugin.py | 31 | ||||
-rw-r--r-- | yarns/0090-lock-handling.yarn | 2 |
2 files changed, 32 insertions, 1 deletions
diff --git a/obnamlib/plugins/force_lock_plugin.py b/obnamlib/plugins/force_lock_plugin.py index fad8a240..010d1552 100644 --- a/obnamlib/plugins/force_lock_plugin.py +++ b/obnamlib/plugins/force_lock_plugin.py @@ -29,9 +29,11 @@ class ForceLockPlugin(obnamlib.ObnamPlugin): def enable(self): self.app.add_subcommand('force-lock', self.force_lock) + self.app.add_subcommand('_lock', self.lock, hidden=True) def force_lock(self, args): '''Force a locked repository to be open.''' + self.app.settings.require('repository') self.app.settings.require('client-name') @@ -62,3 +64,32 @@ class ForceLockPlugin(obnamlib.ObnamPlugin): repo.close() return 0 + + def lock(self, args): + '''Add locks to the repository. + + This is a hidden command meant for use in testing only. + + ''' + + self.app.settings.require('repository') + + repourl = self.app.settings['repository'] + client_name = self.app.settings['client-name'] + logging.info('Creating lock') + logging.info('Repository: %s' % repourl) + logging.info('Client: %s' % client_name) + + try: + repo = self.app.get_repository_object() + except OSError, e: + raise RepositoryAccessError(error=str(e)) + + repo.lock_client_list() + if client_name: + repo.lock_client(client_name) + repo.lock_chunk_indexes() + + repo.close() + + return 0 diff --git a/yarns/0090-lock-handling.yarn b/yarns/0090-lock-handling.yarn index 2c88a0a1..fe509c53 100644 --- a/yarns/0090-lock-handling.yarn +++ b/yarns/0090-lock-handling.yarn @@ -25,7 +25,7 @@ We then lock the repository, and verify that a backup now fails. AND user U locks repository R AND user U attempts to back up directory L to repository R THEN the attempt failed with exit code 1 - AND the error message matches "xxxxx" + AND the error message matches "R681AEX" Now we can force the lock open and verify that a backup now succeeds. |