def test_cleanup_fail(self, mock_sp, mock_shutil, mock_os_path_exists): benchmark = tempest.Tempest(self.context) benchmark.verifier = mock.MagicMock() benchmark.results_dir = "/tmp/path" mock_sp.side_effect = subprocess.CalledProcessError(0, None) self.assertRaises(exceptions.CleanUpException, benchmark.cleanup)
def test_cleanup_fail(self, mock_sp, mock_shutil, mock_os_path_exists): benchmark = tempest.Tempest(self.context) benchmark.verifier = mock.MagicMock() benchmark.results_dir = "/tmp/path" benchmark.cleanup() mock_sp.check_call.side_effect = subprocess.CalledProcessError(0, '') self.assertRaises(subprocess.CalledProcessError, benchmark.cleanup)
def test_setup_with_no_configuration(self, mock_gen, mock_is_installed, mock_is_cfg, mock_mkdir): benchmark = tempest.Tempest(self.context) benchmark.setup() self.assertEqual(1, mock_is_installed.call_count) self.assertEqual('/dev/null', benchmark.verifier.log_file_raw) self.assertEqual(1, mock_gen.call_count)
def test_cleanup(self, mock_shutil, mock_os_path_exists): benchmark = tempest.Tempest(self.context) benchmark.verifier = mock.MagicMock() benchmark.results_dir = "/tmp/path" benchmark.cleanup() mock_shutil.rmtree.assert_called_once_with("/tmp/path")
def test_setup_failure_on_tempest_configuration( self, mock_gen, mock_is_installed, mock_is_cfg, mock_mkdir): mock_gen.side_effect = config.TempestConfigCreationFailure() benchmark = tempest.Tempest(self.context) self.assertRaises(exceptions.BenchmarkSetupFailure, benchmark.setup) self.assertEqual(1, mock_is_cfg.call_count)
def test_setup_failure_on_tempest_installation( self, mock_install, mock_is_installed, mock_is_cfg, mock_mkdir): mock_install.side_effect = tempest_verifier.TempestSetupFailure() benchmark = tempest.Tempest(self.context) self.assertRaises(exceptions.BenchmarkSetupFailure, benchmark.setup) self.assertEqual(0, mock_is_cfg.call_count)
def test_setup(self, mock_is_install, mock_install, mock_is_cfg, mock_cfg, mock_mkdir): benchmark = tempest.Tempest(self.context) benchmark.setup() self.assertEqual(0, mock_install.call_count) self.assertEqual(0, mock_cfg.call_count) self.assertEqual('/dev/null', benchmark.verifier.log_file_raw)
def test_setup_failure_on_tempest_installation(self, mock_install, mock_is_installed, mock_is_cfg): mock_is_installed.return_value = False mock_install.side_effect = exceptions.TempestSetupFailure() benchmark = tempest.Tempest(self.context) self.assertRaises(exceptions.BenchmarkSetupFailure, benchmark.setup) self.assertEqual(0, mock_is_cfg.call_count)
def test_setup(self, mock_is_install, mock_install, mock_is_cfg, mock_cfg): mock_is_install.return_value = True mock_is_cfg.return_value = False benchmark = tempest.Tempest(self.context) benchmark.setup() self.assertEqual(0, mock_install.call_count) self.assertEqual(1, mock_cfg.call_count) self.assertEqual('/dev/null', benchmark.verifier.log_file)
def test_cleanup(self, mock_sp): benchmark = tempest.Tempest(self.context) benchmark.verifier = mock.MagicMock() benchmark.cleanup() mock_sp.check_call.assert_called_once_with( "cd %s && %s python tempest/stress/tools/cleanup.py" % (benchmark.verifier.tempest_path, benchmark.verifier.venv_wrapper), shell=True, cwd=benchmark.verifier.tempest_path, env=benchmark.verifier.env)
def test_cleanup(self, mock_sp, mock_shutil, mock_os_path_exists): benchmark = tempest.Tempest(self.context) benchmark.verifier = mock.MagicMock() benchmark.results_dir = "/tmp/path" benchmark.cleanup() mock_sp.check_call.assert_called_once_with( "cd %s && %s python tempest/stress/tools/cleanup.py" % (benchmark.verifier.path(), benchmark.verifier.venv_wrapper), shell=True, cwd=benchmark.verifier.path(), env=benchmark.verifier.env) mock_shutil.rmtree.assert_called_once_with("/tmp/path")