Ejemplo n.º 1
0
 def test_existing_device_is_formatted(self):
     """
     make_filesystem() formats the given device if it exists with the
     specified filesystem.
     """
     device = '/dev/zero'
     fstype = 'xfs'
     ceph_utils.make_filesystem(device, fstype)
     self.check_call.assert_called_with(['mkfs', '-t', fstype, device])
     self.log.assert_called_with('Formatting block device %s as '
                                 'filesystem %s.' % (device, fstype),
                                 level='INFO')
Ejemplo n.º 2
0
    def test_device_is_formatted_if_it_appears(self):
        """
        The specified device is formatted if it appears before the timeout
        is reached.
        """
        def create_my_device(filename):
            with open(filename, "w") as device:
                device.write("hello\n")

        temp_dir = mkdtemp()
        self.addCleanup(rmtree, temp_dir)
        device = "%s/mydevice" % temp_dir
        fstype = 'xfs'
        timeout = 4
        t = Timer(2, create_my_device, [device])
        t.start()
        ceph_utils.make_filesystem(device, fstype, timeout)
        self.check_call.assert_called_with(['mkfs', '-t', fstype, device])
Ejemplo n.º 3
0
 def test_make_filesystem_default_filesystem(self):
     '''make_filesystem() uses ext4 as the default filesystem.'''
     device = '/dev/zero'
     ceph_utils.make_filesystem(device)
     self.check_call.assert_called_with(['mkfs', '-t', 'ext4', device])
Ejemplo n.º 4
0
 def test_make_filesystem_xfs(self, _exists):
     _exists.return_value = True
     ceph_utils.make_filesystem('/dev/sdd', 'xfs')
     self.log.assert_called()
     self.check_call.assert_called_with(['mkfs', '-t', 'xfs', '/dev/sdd'])