Ejemplo n.º 1
0
    def test_safe_kill(self, owner_mocked, kill_mocked):
        owner_id = 1
        process_id = 123
        signal = 1
        owner_mocked.return_value = owner_id

        killed = process.safe_kill(process_id, signal)
        self.assertTrue(killed)
        kill_mocked.assert_called_with(process_id, signal)
Ejemplo n.º 2
0
    def test_safe_kill(self, owner_mocked, kill_mocked):
        owner_id = 1
        process_id = 123
        signal = 1
        owner_mocked.return_value = owner_id

        killed = process.safe_kill(process_id, signal)
        self.assertTrue(killed)
        kill_mocked.assert_called_with(process_id, signal)
Ejemplo n.º 3
0
    def test_safe_kill_sudo_enabled(self, owner_mocked, run_mocked):
        owner_id = 0
        process_id = 123
        signal = 1
        owner_mocked.return_value = owner_id
        expected_cmd = 'kill -%d %d' % (signal, process_id)

        killed = process.safe_kill(process_id, signal)
        self.assertTrue(killed)
        run_mocked.assert_called_with(expected_cmd, sudo=True)
Ejemplo n.º 4
0
    def test_safe_kill_with_exception(self, owner_mocked, kill_mocked):
        owner_id = 1
        process_id = 123
        signal = 1
        owner_mocked.return_value = owner_id
        kill_mocked.side_effect = Exception()

        killed = process.safe_kill(process_id, signal)
        self.assertFalse(killed)
        kill_mocked.assert_called_with(process_id, signal)
Ejemplo n.º 5
0
    def test_safe_kill_sudo_enabled(self, owner_mocked, run_mocked):
        owner_id = 0
        process_id = 123
        signal = 1
        owner_mocked.return_value = owner_id
        expected_cmd = 'kill -%d %d' % (signal, process_id)

        killed = process.safe_kill(process_id, signal)
        self.assertTrue(killed)
        run_mocked.assert_called_with(expected_cmd, sudo=True)
Ejemplo n.º 6
0
    def test_safe_kill_with_exception(self, owner_mocked, kill_mocked):
        owner_id = 1
        process_id = 123
        signal = 1
        owner_mocked.return_value = owner_id
        kill_mocked.side_effect = Exception()

        killed = process.safe_kill(process_id, signal)
        self.assertFalse(killed)
        kill_mocked.assert_called_with(process_id, signal)
Ejemplo n.º 7
0
    def test_safe_kill_sudo_enabled_with_exception(self, owner_mocked, run_mocked):
        owner_id = 0
        process_id = 123
        signal = 1
        owner_mocked.return_value = owner_id
        expected_cmd = 'kill -%d %d' % (signal, process_id)
        run_mocked.side_effect = process.CmdError()

        killed = process.safe_kill(process_id, signal)
        self.assertFalse(killed)
        run_mocked.assert_called_with(expected_cmd, sudo=True)
Ejemplo n.º 8
0
        nc_process_pid = None
        if test_params['spice_port_closed'] == "yes":
            cmd = "nc -l %s" % test_params['spice_port']
            nc_process_cl = process.get_sub_process_klass(cmd)
            nc_process = nc_process_cl(cmd)
            nc_process_pid = nc_process.start()
        error.context("Start guest VM with invalid parameters.")
        try:
            env_process.preprocess_vm(vt_test, test_params, env, vmname)
        except virt_vm.VMCreateError, emsg:
            error_s = test_params['error_msg']
            if '%s,%s' in error_s:
                s_port = env.get_vm(vmname).spice_port
                error_s = error_s % (test_params['spice_addr'], s_port)
            if error_s in emsg.output and emsg.status == 1:
                logging.info("Guest terminated as expected: %s", emsg.output)
                return
            else:
                raise error.TestFail("Guest creation failed, bad error"
                                     "message: %s and/or exit status: %s" %
                                     (emsg.output, emsg.status))
        finally:
            if nc_process_pid is not None:
                process.safe_kill(nc_process_pid, signal.SIGKILL)
        raise error.TestFail("Guest start normally, didn't quit as expected.")
    else:
        test = stest.GuestTest(vt_test, test_params, env)
        vmi = test.vmi
        act.x_active(vmi)
        act.verify_listen(vmi)