Ejemplo n.º 1
0
    def test_execd_run_dies_with_return_code(self, exit_, log):
        self.make_preinstall_executable(module_dir='basenode',
                                        error_on_preinstall=True)

        with open(os.devnull, 'wb') as devnull:
            execd.execd_run('charm-pre-install', stderr=devnull)

        exit_.assert_called_with(1)
Ejemplo n.º 2
0
    def test_execd_run(self):
        modules = ['basenode', 'mod2', 'c']
        for module in modules:
            self.make_preinstall_executable(module_dir=module)

        execd.execd_run('charm-pre-install')

        self.assert_preinstall_called_for_mod('basenode')
        self.assert_preinstall_called_for_mod('mod2')
        self.assert_preinstall_called_for_mod('c')
Ejemplo n.º 3
0
    def test_execd_run_logs_exception(self, log_):
        self.make_preinstall_executable(module_dir='basenode',
                                        error_on_preinstall=True)

        with open(os.devnull, 'wb') as devnull:
            execd.execd_run('charm-pre-install', stderr=devnull)

        expected_log = ('Error (126) running  {}/exec.d/basenode/'
                        'charm-pre-install. Output: None'.format(
                            self.test_charm_dir))
        log_.assert_called_with(expected_log)
Ejemplo n.º 4
0
    def test_execd_run_logs_exception(self, log_):
        self.make_preinstall_executable(module_dir='basenode',
                                        error_on_preinstall=True)

        execd.execd_run('charm-pre-install', die_on_error=False)

        expected_log = ('Error (1) running  {}/exec.d/basenode/'
                        'charm-pre-install. Output: '
                        'stdout_from_pre_install\n'
                        'stderr_from_pre_install\n'.format(
                            self.test_charm_dir))
        log_.assert_called_with(expected_log)
def preinstall():
    with maintenance_status('Running preinstallation hooks',
                            'Preinstallation hooks finished'):
        execd_run('charm-pre-install', die_on_error=True)