Example #1
0
    def test_run(self):
        zookeeper = flexmock()
        ds_factory = flexmock(appscale_datastore_batch.DatastoreFactory)
        ds_factory.should_receive("getDatastore").and_return(FakeDatastore())
        flexmock(datastore_distributed).should_receive(
            'DatastoreDistributed').and_return()
        fake_restore = flexmock(
            DatastoreRestore('app_id', 'backup/dir', zookeeper, "cassandra"))

        # Test with failure to get the restore lock.
        fake_restore.should_receive('get_restore_lock').and_return(False)
        flexmock(time).should_receive('sleep').and_return()

        # Test with successfully obtaining the restore lock.
        fake_restore.should_receive('get_restore_lock').and_return('some/path')
        fake_restore.should_receive('run_restore').and_return()

        # ... and successfully releasing the lock.
        zookeeper.should_receive('release_lock_with_path').and_return(True)
        self.assertEquals(None, fake_restore.run())

        # ... and failure to release the lock.
        zookeeper.should_receive('release_lock_with_path').\
          and_raise(ZKTransactionException)
        self.assertEquals(None, fake_restore.run())
Example #2
0
    def test_get_restore_lock(self):
        zookeeper = flexmock()
        zookeeper.should_receive("get_lock_with_path").and_return(True)
        fake_restore = flexmock(
            DatastoreRestore('app_id', 'backup/dir', zookeeper, "cassandra"))

        # Test with successfully obtaining the restore lock.
        self.assertEquals(True, fake_restore.get_restore_lock())
Example #3
0
    def test_run_restore(self):
        zookeeper = flexmock()
        fake_restore = flexmock(
            DatastoreRestore('app_id', 'backup/dir', zookeeper, "cassandra"))

        flexmock(glob).should_receive('glob').and_return(['some/file.backup'])
        fake_restore.should_receive('read_from_file_and_restore').and_return()

        fake_restore.run_restore()
Example #4
0
 def test_init(self):
     zookeeper = flexmock()
     fake_restore = flexmock(
         DatastoreRestore('app_id', 'backup/dir', zookeeper, "cassandra"))