Exemplo n.º 1
0
 def test_backup_base(self):
     """This test is for
        guestagent/strategies/backup/base
     """
     BackupRunner.cmd = "%s"
     backup_runner = BackupRunner('sample', cmd='echo command')
     if backup_runner.is_zipped:
         self.assertEqual('.gz', backup_runner.zip_manifest)
         self.assertIsNotNone(backup_runner.zip_manifest)
         self.assertIsNotNone(backup_runner.zip_cmd)
         self.assertEqual(' | gzip', backup_runner.zip_cmd)
     else:
         self.assertIsNone(backup_runner.zip_manifest)
         self.assertIsNone(backup_runner.zip_cmd)
     self.assertEqual('BackupRunner', backup_runner.backup_type)
Exemplo n.º 2
0
    def test_backup_runner_exits_with_exception(self, mock_kill_pg):
        """This test is for
           guestagent/strategies/backup/base,
           ensures that when backup runner exits with an exception,
           all child processes are also killed.
        """
        BackupRunner.cmd = "%s"
        backup_runner = BackupRunner('sample', cmd='echo command')

        def test_backup_runner_reraise_exception():
            mock_func = mock.Mock(side_effect=RuntimeError)

            with backup_runner:
                mock_func()

        self.assertRaises(RuntimeError, test_backup_runner_reraise_exception)
        self.assertTrue(mock_kill_pg.called)
Exemplo n.º 3
0
 def test_backup_base(self):
     """This test is for
        guestagent/strategies/backup/base
     """
     BackupRunner.cmd = "%s"
     backup_runner = BackupRunner('sample', cmd='echo command')
     if backup_runner.is_zipped:
         self.assertEqual(backup_runner.zip_manifest, '.gz')
         self.assertIsNotNone(backup_runner.zip_manifest)
         self.assertIsNotNone(backup_runner.zip_cmd)
         self.assertEqual(backup_runner.zip_cmd, ' | gzip')
     else:
         self.assertIsNone(backup_runner.zip_manifest)
         self.assertIsNone(backup_runner.zip_cmd)
     self.assertIsNotNone(backup_runner.prefix)
     self.assertEqual(backup_runner.prefix, 'database_backups/sample_')
     self.assertIsNotNone(backup_runner.segment)
     self.assertEqual(backup_runner.segment, 'sample_00000000')
     self.assertIsNotNone(backup_runner.backup_type)
     self.assertEqual(backup_runner.backup_type, 'BackupRunner')