Пример #1
0
 def test_write_full(self):
     self.assertEqual(STATE.state_file, None)
     STATE.state_file = tempfile.mkstemp(prefix='vchtest')[1]
     STATE.disks = [Disk('/some/path'), Disk('/some/other/path', 12.34)]
     STATE.last_message = b'Byte data being saved'
     STATE.write()
     with open(STATE.state_file, 'rb') as f:
         json.loads(f.read())
Пример #2
0
 def test_locate_disk(self):
     with wrapper.log_parser() as parser:
         parser._current_disk = 0
         parser._current_path = '[store1] path1.vmdk'
         STATE.disks = [
             Disk('[store1] path2.vmdk'),
             Disk('[store1] path1.vmdk'),
             Disk('[store1] path3.vmdk'),
         ]
         parser._locate_disk()
         self.assertEqual(STATE.disks[0].path, '[store1] path1.vmdk')
         self.assertEqual(STATE.disks[1].path, '[store1] path2.vmdk')
         self.assertEqual(STATE.disks[2].path, '[store1] path3.vmdk')
Пример #3
0
 def test_disk_number(self):
     with wrapper.log_parser() as parser:
         parser._current_disk = 0
         parser._current_path = '/path1'
         STATE.disks = [
             Disk('[store1] path1.vmdk'),
             Disk('[store1] path2.vmdk'),
             Disk('[store1] path3.vmdk'),
         ]
         parser.parse_line(b'Copying disk 2/3 to /some/path')
         self.assertEqual(parser._current_disk, 1)
         self.assertIsNone(parser._current_path)
         self.assertEqual(STATE.disk_count, 3)
Пример #4
0
 def test_locate_disk(self):
     STATE.v2v_log = '/dev/null'
     STATE.machine_readable_log = '/dev/null'
     with wrapper.log_parser() as parser:
         parser._current_disk = 0
         parser._current_path = '[store1] path1.vmdk'
         STATE.disks = [
             Disk('[store1] path2.vmdk'),
             Disk('[store1] path1.vmdk'),
             Disk('[store1] path3.vmdk'),
             ]
         parser._locate_disk()
         self.assertEqual(STATE.disks[0].path, '[store1] path1.vmdk')
         self.assertEqual(STATE.disks[1].path, '[store1] path2.vmdk')
         self.assertEqual(STATE.disks[2].path, '[store1] path3.vmdk')
Пример #5
0
 def test_progress(self):
     with wrapper.log_parser() as parser:
         parser._current_disk = 0
         parser._current_path = '/path1'
         STATE.disks = [Disk('/path1', 0.0)]
         parser.parse_line(b'  (10.42/100%)')
         self.assertEqual(STATE.disks[0].progress, 10.42)
Пример #6
0
 def test_progress(self):
     STATE.v2v_log = '/dev/null'
     STATE.machine_readable_log = '/dev/null'
     with wrapper.log_parser() as parser:
         parser._current_disk = 0
         parser._current_path = '/path1'
         STATE.disks = [Disk('/path1', 0.0)]
         parser.parse_line(b'  (10.42/100%)')
         self.assertEqual(STATE.disks[0].progress, 10.42)
Пример #7
0
    def test_two_phase(self):
        # For two-phase conversion the log parser should not update anything
        STATE.pre_copy = True

        with wrapper.log_parser() as parser:
            parser._current_disk = 0
            parser._current_path = '/path1'
            STATE.disks = [
                Disk('[store1] path1.vmdk'),
                Disk('[store1] path2.vmdk'),
                Disk('[store1] path3.vmdk'),
            ]
            parser.parse_line(b'Copying disk 2/3 to /some/path')
            self.assertEqual(parser._current_disk, 0)

            parser._current_path = '/path1'
            STATE.disks = [Disk('/path1', 0.0)]
            parser.parse_line(b'  (10.42/100%)')
            self.assertEqual(STATE.disks[0].progress, 0)
Пример #8
0
 def test_rhv_disk_uuid(self):
     with wrapper.log_parser() as parser:
         parser._current_disk = 0
         path = '/path1'
         STATE.disks = [Disk(path)]
         parser.parse_line(
             b'disk.id = \'11111111-1111-1111-1111-111111111111\'')
         self.assertIn(path, STATE.internal['disk_ids'])
         self.assertEqual(STATE.internal['disk_ids'][path],
                          b'11111111-1111-1111-1111-111111111111')