def _run_actions_on_components(self, cluster: Cluster, service: Service, components: dict, hosts: tuple): """Utility function to run actions on components (host actions too)""" cluster.action(name='make_sauce').run( hc=tuple( ( {'host_id': host_id, 'service_id': service.id, 'component_id': component_id} for host_id, component_id in ( (hosts[1].id, components[self.SPICE_COMPONENT].id), (hosts[1].id, components[self.LEMON_COMPONENT].id), (hosts[2].id, components[self.TOMATO_COMPONENT].id), ) ) ) ).wait() cluster.hostcomponent_set( (hosts[0], components[self.MILK_COMPONENT]), *[ (cluster.host(id=hc['host_id']), service.component(id=hc['component_id'])) for hc in cluster.hostcomponent() ], ) _wait_for_tasks( ( components[self.TOMATO_COMPONENT].action(name='add_more').run(), components[self.SPICE_COMPONENT].action(name='add_more').run(), ) )
def enable_cluster(self, cluster: Cluster) -> None: """Enable cluster by setting positive status for each host and component""" hosts = set() for hostcomponent in cluster.hostcomponent(): host_id, component_id = hostcomponent['host_id'], hostcomponent[ 'component_id'] self._set_component_status(host_id, component_id, POSITIVE_STATUS) if host_id not in hosts: self._set_host_status(host_id, POSITIVE_STATUS) hosts.add(host_id)
def test_down_lock(self, complete_cluster: Cluster, sdk_client_fs: ADCMClient, lock_action): """ Test that cluster lock also locks: - all cluster services - all service components - all hosts with components """ task = _lock_obj(complete_cluster, lock_action) for service in complete_cluster.service_list(): is_locked(service) for component in service.component_list(): is_locked(component) for hc_map in complete_cluster.hostcomponent(): is_locked(sdk_client_fs.host(id=hc_map["host_id"])) task.wait() for service in complete_cluster.service_list(): is_free(service) for component in service.component_list(): is_free(component) for hc_map in complete_cluster.hostcomponent(): is_free(sdk_client_fs.host(id=hc_map["host_id"]))
def test_get_hostcomponent_list(self, cluster: Cluster, provider: Provider): """ Check that hostcomponent map retrieved successfully """ service = cluster.service_add(name="ZOOKEEPER") components = service.component_list() hc_map_temp = [] for fqdn in utils.random_string_list(): host = provider.host_create(fqdn=fqdn) cluster.host_add(host) component = random.choice(components) hc_map_temp.append((host, component)) hc_map_expected = cluster.hostcomponent_set(*hc_map_temp) with allure.step("Check created data with data from API"): hc_map_actual = cluster.hostcomponent() assert hc_map_actual == hc_map_expected