示例#1
0
 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(),
         )
     )
示例#2
0
def test_host_should_be_unlocked_after_host_action(
    cluster: Cluster,
    host_provider: Provider,
    adcm_object: str,
    host_action_postfix: str,
    run_on_host: str,
):
    """Test that host is unlocked after host action"""
    action_name = f"{adcm_object}_{host_action_postfix}"
    first_service = cluster.service_add(name="first_service")
    second_service = cluster.service_add(name="second_service")

    host_with_two_components = host_provider.host_create("host_with_two_components")
    host_with_one_component = host_provider.host_create("host_with_one_component")
    host_with_different_services = host_provider.host_create("host_with_different_services")

    cluster_hosts = [
        host_with_two_components,
        host_with_one_component,
        host_with_different_services,
    ]
    for host in cluster_hosts:
        cluster.host_add(host)

    cluster.hostcomponent_set(
        (host_with_two_components, second_service.component(name="second_service_component_1")),
        (host_with_two_components, second_service.component(name="second_service_component_2")),
        (host_with_one_component, second_service.component(name="second_service_component_1")),
        (host_with_different_services, first_service.component(name="first_service_component_2")),
        (host_with_different_services, second_service.component(name="second_service_component_1")),
    )
    host = cluster.host(fqdn=run_on_host)
    with allure.step(f"Run action {action_name} on {host}"):
        host.action(name=action_name).run().wait(timeout=30)
    for host in cluster_hosts:
        is_free(host)
示例#3
0
def _check_that_host_exists(cluster: Cluster, host: Host) -> None:
    assert len(cluster.host_list()) == 1, "Only one host expected to be"
    with catch_failed(ObjectNotFound, "Previously created host not found"):
        cluster.host(fqdn=host.fqdn)