示例#1
0
文件: v2v_test.py 项目: vjuranek/vdsm
    def testV2VOutput(self):
        cmd = [FAKE_VIRT_V2V.cmd,
               '-v',
               '-x',
               '-ic', self.vpx_url,
               '-o', 'vdsm',
               '-of', 'raw',
               '-oa', 'sparse',
               '--vdsm-image-uuid', self.image_id_a,
               '--vdsm-vol-uuid', self.volume_id_a,
               '--vdsm-image-uuid', self.image_id_b,
               '--vdsm-vol-uuid', self.volume_id_b,
               '--password-file', '/tmp/mypass',
               '--vdsm-vm-uuid', self.job_id,
               '--vdsm-ovf-output', '/usr/local/var/run/vdsm/v2v',
               '--machine-readable',
               '-os', '/rhev/data-center/%s/%s' % (self.pool_id,
                                                   self.domain_id),
               self.vm_name]

        rc, output, error = exec_cmd(cmd)
        self.assertEqual(rc, 0)

        with io.open('fake-virt-v2v.out', 'rb') as f:
            self.assertEqual(output, f.read())

        with io.open('fake-virt-v2v.err', 'rb') as f:
            self.assertEqual(error, f.read())
示例#2
0
    def test_kill_grandkids(self):
        # watch a bash process that starts a grandchild bash process.
        # The grandkid bash echoes its pid and sleeps a lot.
        # on timeout, py-watch should kill the process session spawned by it.
        rc, out, err = exec_cmd([
            './py-watch', '0.2', 'bash',
            '-c', 'bash -c "readlink /proc/self; sleep 10"'])

        # assert that the internal bash no longer exist
        grandkid_pid = int(out.splitlines()[0])
        with pytest.raises(OSError) as excinfo:
            assert os.kill(grandkid_pid, 0)
        assert excinfo.value.errno == errno.ESRCH
示例#3
0
    def test_timeout_backtrace(self):
        script = '''
import time

def outer():
    inner()

def inner():
    time.sleep(10)

outer()
'''
        rc, out, err = exec_cmd(['./py-watch', '0.1', 'python', '-c', script])
        assert b'in inner ()' in out
        assert b'in outer ()' in out
示例#4
0
文件: pywatch_test.py 项目: nirs/vdsm
    def test_timeout_backtrace(self):
        script = '''
import time

def outer():
    inner()

def inner():
    time.sleep(10)

outer()
'''
        rc, out, err = exec_cmd(['./py-watch', '0.1', 'python', '-c', script])
        assert b'in inner ()' in out
        assert b'in outer ()' in out
示例#5
0
 def test_exec_cmd_with_env(self):
     rc, out, err = cmdutils.exec_cmd(
         ('sh', '-c', 'echo $XXX'), env={'XXX': 'hello'})
     self.assertEqual(rc, 0)
     self.assertEqual(out, b'hello\n')
示例#6
0
 def test_exec_cmd_with_error_output(self):
     rc, out, err = cmdutils.exec_cmd(('ls', 'no such prog'))
     self.assertNotEqual(rc, 0)
     self.assertIn(b'No such file or directory', err)
     self.assertEqual(out, b'')
示例#7
0
 def test_exec_cmd_with_success_output(self):
     rc, out, err = cmdutils.exec_cmd(('echo', 'hello world'))
     self.assertEqual(rc, 0, err)
     self.assertEqual(out, b'hello world\n')
     self.assertEqual(err, b'')
示例#8
0
 def test_exec_cmd_with_no_output(self):
     rc, out, err = cmdutils.exec_cmd(('true',))
     self.assertEqual(rc, 0)
     self.assertEqual(out, b'')
     self.assertEqual(err, b'')
示例#9
0
 def test_timeout_output(self):
     rc, out, err = exec_cmd(['./py-watch', '0.1', 'sleep', '10'])
     assert b'Watched process timed out' in out
     assert b'Terminating watched process' in out
     assert rc == 128 + signal.SIGTERM
示例#10
0
 def test_short_failure(self):
     rc, _, _ = exec_cmd(['./py-watch', '0.2', 'false'])
     assert rc == 1
示例#11
0
 def test_short_success(self):
     rc, _, _ = exec_cmd(['./py-watch', '0.2', 'true'])
     assert rc == 0
示例#12
0
文件: pywatch_test.py 项目: nirs/vdsm
 def test_timeout_output(self):
     rc, out, err = exec_cmd(['./py-watch', '0.1', 'sleep', '10'])
     assert b'Watched process timed out' in out
     assert b'Terminating watched process' in out
     assert rc == 128 + signal.SIGTERM
示例#13
0
文件: pywatch_test.py 项目: nirs/vdsm
 def test_short_failure(self):
     rc, _, _ = exec_cmd(['./py-watch', '0.2', 'false'])
     assert rc == 1
示例#14
0
文件: pywatch_test.py 项目: nirs/vdsm
 def test_short_success(self):
     rc, _, _ = exec_cmd(['./py-watch', '0.2', 'true'])
     assert rc == 0