def test_check_disk_space_for_deployment(self): min_size = 100000 volumes_metadata = self.env.get_default_volumes_metadata() volumes_roles_mapping = volumes_metadata['volumes_roles_mapping'] for role, space_info in six.iteritems(volumes_roles_mapping): node, min_installation_size = self.\ create_node_and_calculate_min_size( role, space_info, volumes_metadata) self.update_node_with_single_disk(node, min_size) vm = VolumeManager(node) with patch.object(vm, '_VolumeManager' '__calc_minimal_installation_size', return_value=min_size): vm.check_disk_space_for_deployment() self.update_node_with_single_disk(node, min_size - 1) vm = VolumeManager(node) with patch.object(vm, '_VolumeManager' '__calc_minimal_installation_size', return_value=min_size): self.assertRaises( errors.NotEnoughFreeSpace, vm.check_disk_space_for_deployment )
def test_allocates_all_free_space_for_vm_for_cinder_role(self): node = self.create_node('cinder') self.should_contain_os_with_minimal_size(VolumeManager(node)) self.all_free_space_except_os_for_volume( VolumeManager(node).volumes, 'cinder') self.check_disk_size_equal_sum_of_all_volumes( VolumeManagerExtension.get_node_volumes(node))
def test_allocates_space_single_disk_for_ceph_for_ceph_role(self): node = self.create_node('ceph-osd') self.update_node_with_single_disk(node, 30000) self.should_contain_os_with_minimal_size(VolumeManager(node)) self.all_free_space_except_os_for_volume( VolumeManager(node).volumes, 'ceph') self.check_disk_size_equal_sum_of_all_volumes( VolumeManagerExtension.get_node_volumes(node))
def test_multirole_controller_cinder_ceph(self): node = self.create_node('controller', 'cinder', 'ceph-osd') self.should_contain_os_with_minimal_size(VolumeManager(node)) self.should_allocates_same_size( VolumeManager(node).volumes, ['image', 'cinder', 'ceph']) self.logical_volume_sizes_should_equal_all_phisical_volumes( VolumeManagerExtension.get_node_volumes(node)) self.check_disk_size_equal_sum_of_all_volumes( VolumeManagerExtension.get_node_volumes(node))
def test_calc_minimal_installation_size(self): volumes_metadata = self.env.get_default_volumes_metadata() volumes_roles_mapping = volumes_metadata['volumes_roles_mapping'] for role, space_info in six.iteritems(volumes_roles_mapping): node = self.create_node(role) vm = VolumeManager(node) self.assertEqual( vm._VolumeManager__calc_minimal_installation_size(), self.__calc_minimal_installation_size(vm))
def test_calc_minimal_installation_size(self): volumes_metadata = self.env.get_default_volumes_metadata() volumes_roles_mapping = volumes_metadata['volumes_roles_mapping'] for role, space_info in six.iteritems(volumes_roles_mapping): node = self.create_node(role) vm = VolumeManager(node) self.assertEqual( vm._VolumeManager__calc_minimal_installation_size(), self.__calc_minimal_installation_size(vm) )
def test_check_volume_size_for_deployment(self): node = self.create_node('controller', 'ceph-osd') # First disk contains more than minimum size of all VGs self.update_node_with_single_disk(node, 116384) # Second is taken entirely by ceph self.add_disk_to_node(node, 65536) VolumeManager(node).check_volume_sizes_for_deployment() # First disk contains less than minimum size of all VGs self.update_node_with_single_disk(node, 16384) # Second is taken entirely by ceph self.add_disk_to_node(node, 65536) self.assertRaises( errors.NotEnoughFreeSpace, VolumeManager(node).check_volume_sizes_for_deployment)
def create_node_and_calculate_min_size(self, role, space_info, volumes_metadata): node = self.create_node(role) volume_manager = VolumeManager(node) min_installation_size = self.__calc_minimal_installation_size( volume_manager) return node, min_installation_size
def test_get_default_attrs(self): self.env.create_node(api=False) node_db = self.env.nodes[0] volumes_from_api = self.get(node_db.id) default_volumes = VolumeManager(node_db).gen_volumes_info() disks = only_disks(default_volumes) self.assertEqual(len(disks), len(volumes_from_api))
def _check_volumes(cls, cluster): try: for node in cluster.nodes: if cls._is_disk_checking_required(node): VolumeManager(node).check_volume_sizes_for_deployment() except errors.NotEnoughFreeSpace as e: raise errors.NotEnoughFreeSpace( u"Node '{}' has insufficient disk space\n{}".format( node.human_readable_name, e.message))
def GET(self, node_id): """:returns: JSONized node disks. :http: * 200 (OK) * 404 (node or its attributes not found in db) """ node = self.get_object_or_404(objects.Node, node_id) volumes = DisksFormatConvertor.format_disks_to_simple( VolumeManager(node).gen_volumes_info()) return volumes
def test_check_disk_space_for_deployment(self): min_size = 100000 volumes_metadata = self.env.get_default_volumes_metadata() volumes_roles_mapping = volumes_metadata['volumes_roles_mapping'] for role, space_info in six.iteritems(volumes_roles_mapping): node, min_installation_size = self.\ create_node_and_calculate_min_size( role, space_info, volumes_metadata) self.update_node_with_single_disk(node, min_size) vm = VolumeManager(node) with patch.object(vm, '_VolumeManager' '__calc_minimal_installation_size', return_value=min_size): vm.check_disk_space_for_deployment() self.update_node_with_single_disk(node, min_size - 1) vm = VolumeManager(node) with patch.object(vm, '_VolumeManager' '__calc_minimal_installation_size', return_value=min_size): self.assertRaises(errors.NotEnoughFreeSpace, vm.check_disk_space_for_deployment)
def test_allocates_all_free_space_for_os_for_controller_role(self): node = self.create_node('controller') disks = only_disks(VolumeManager(node).volumes) disks_size_sum = sum([disk['size'] for disk in disks]) os_sum_size = self.os_size(disks) mysql_sum_size = self.mysql_size(disks) glance_sum_size = self.glance_size(disks) horizon_sum_size = self.horizon_size(disks) logs_sum_size = self.logs_size(disks) reserved_size = self.reserved_size(disks) self.assertEqual( disks_size_sum - reserved_size, os_sum_size + glance_sum_size + mysql_sum_size + logs_sum_size + horizon_sum_size) self.logical_volume_sizes_should_equal_all_phisical_volumes( VolumeManagerExtension.get_node_volumes(node)) self.check_disk_size_equal_sum_of_all_volumes( VolumeManagerExtension.get_node_volumes(node))
def update_ram_and_assert_swap_size(self, node, size, swap_size): new_meta = deepcopy(node.meta) new_meta['memory']['total'] = (1024**2) * size node.meta = new_meta self.env.db.commit() self.assertEqual(VolumeManager(node)._calc_swap_size(), swap_size)
def test_find_existing_disk_empty_volumes(self): disk_info = {'disk': 'disk_id', 'extra': []} with patch.object(VolumeManager, '_build_disk_id_by_keys') \ as id_builder: self.assertIsNone(VolumeManager.find_existing_disk(disk_info, [])) self.assertEqual(0, id_builder.call_count)
def check_expected_volume_found_for_disk(self, disk_info, fake_volumes, expected_volume): self.assertEqual( expected_volume, VolumeManager.find_existing_disk(disk_info, fake_volumes)[0])
def test_allocates_full_disks_for_ceph_for_ceph_role(self): node = self.create_node('ceph-osd') self.should_contain_os_with_minimal_size(VolumeManager(node)) self.all_free_space_except_os_disks_for_volume(VolumeManager(node), 'ceph')
def check_expected_volume_found_for_disk(self, disk_info, fake_volumes, expected_volume): self.assertEqual(expected_volume, VolumeManager.find_existing_disk(disk_info, fake_volumes)[0])