Esempio n. 1
0
def test_multi_state_set_from_host_actions(two_clusters: Tuple[Cluster,
                                                               Cluster],
                                           two_providers: Tuple[Provider,
                                                                Provider],
                                           sdk_client_fs: ADCMClient):
    """Test that host actions actually change multi state"""
    name = "first"
    with allure.step('Bind component to host'):
        component = (service :=
                     (cluster :=
                      two_clusters[0]).service(name=name)).component(name=name)
        host = two_providers[0].host_list()[0]
        cluster.host_add(host)
        cluster.hostcomponent_set((host, component))
    affected_objects = set()
    for obj in (cluster, service, component):
        classname = obj.__class__.__name__
        affected_objects.add(obj)
        with check_objects_multi_state_changed(
                sdk_client_fs, affected_objects
        ), allure.step(
                f'Check change {compose_name(obj)} multi state from host action'
        ):
            run_host_action_and_assert_result(
                host, f'set_{classname.lower()}_host_action')
Esempio n. 2
0
    def test_availability_at_state(self, cluster_with_components: Cluster,
                                   provider: Provider):
        """
        Test that component host action is available on specify service state
        """
        service = cluster_with_components.service_add(name=FIRST_SERVICE)
        component = service.component(name=FIRST_COMPONENT)
        adjacent_component = service.component(name=SECOND_COMPONENT)
        host = provider.host_create("host_in_cluster")
        cluster_with_components.host_add(host)
        cluster_with_components.hostcomponent_set((host, component))

        action_in_object_is_absent(ACTION_ON_HOST_STATE_REQUIRED, host)
        run_cluster_action_and_assert_result(cluster_with_components,
                                             SWITCH_CLUSTER_STATE)
        action_in_object_is_absent(ACTION_ON_HOST_STATE_REQUIRED, host)
        run_service_action_and_assert_result(service, SWITCH_SERVICE_STATE)
        action_in_object_is_absent(ACTION_ON_HOST_STATE_REQUIRED, host)
        run_host_action_and_assert_result(host, SWITCH_HOST_STATE)
        action_in_object_is_absent(ACTION_ON_HOST_STATE_REQUIRED, host)
        run_component_action_and_assert_result(adjacent_component,
                                               SWITCH_COMPONENT_STATE)
        action_in_object_is_absent(ACTION_ON_HOST_STATE_REQUIRED, host)
        run_component_action_and_assert_result(component,
                                               SWITCH_COMPONENT_STATE)
        action_in_object_is_present(ACTION_ON_HOST_STATE_REQUIRED, host)
        run_host_action_and_assert_result(host, ACTION_ON_HOST_STATE_REQUIRED)
Esempio n. 3
0
def test_forbidden_actions(sdk_client_fs: ADCMClient):
    """
    Check that forbidden caller-context combinations fail as actions
        and don't affect any ADCM objects
    """
    name = "first"
    with allure.step(f'Check forbidden from cluster "{name}" context actions'):
        cluster = sdk_client_fs.cluster(name=name)
        for forbidden_action in ('change_service', 'change_component'):
            with check_config_changed(sdk_client_fs):
                run_cluster_action_and_assert_result(cluster,
                                                     forbidden_action,
                                                     status='failed')
    with allure.step(f'Check forbidden from service "{name}" context actions'):
        service = cluster.service(name=name)
        with check_config_changed(sdk_client_fs):
            run_service_action_and_assert_result(service,
                                                 'change_component',
                                                 status='failed')
    with allure.step(
            f'Check forbidden from provider "{name}" context actions'):
        provider = sdk_client_fs.provider(name=name)
        with check_config_changed(sdk_client_fs):
            run_provider_action_and_assert_result(provider,
                                                  'change_host',
                                                  status='failed')
        first_host, second_host, *_ = provider.host_list()
        with check_config_changed(sdk_client_fs):
            run_host_action_and_assert_result(
                first_host,
                'change_host_from_provider',
                status='failed',
                config={'host_id': second_host.id})
Esempio n. 4
0
def test_from_host_actions(two_clusters: Tuple[Cluster, Cluster],
                           two_providers: Tuple[Provider, Provider],
                           sdk_client_fs: ADCMClient):
    """Test that host actions actually change config"""
    name = "first"
    affected_objects = set()
    check_config_changed_local = build_objects_checker(
        extractor=get_config,
        changed={
            **INITIAL_CONFIG, 'int': CHANGED_CONFIG['int']
        },
        field_name='Config')
    with allure.step('Bind component to host'):
        component = (service :=
                     (cluster :=
                      two_clusters[0]).service(name=name)).component(name=name)
        host = two_providers[0].host_list()[0]
        cluster.host_add(host)
        cluster.hostcomponent_set((host, component))
    for obj in (cluster, service, component):
        affected_objects.add(obj)
        classname = obj.__class__.__name__.lower()
        with check_config_changed_local(
                sdk_client_fs, affected_objects), allure.step(
                    f'Check change {compose_name(obj)} config from host action'
                ):
            run_host_action_and_assert_result(host, f'change_{classname}_host')
Esempio n. 5
0
    def test_two_clusters(self, action_name, cluster_with_components: Cluster,
                          provider: Provider):
        """
        Test that component actions on host works fine on two clusters
        """
        second_cluster = cluster_with_components.bundle().cluster_prototype(
        ).cluster_create(name="Second cluster")
        service_on_first_cluster = cluster_with_components.service_add(
            name=FIRST_SERVICE)
        component_on_first_cluster = service_on_first_cluster.component(
            name=FIRST_COMPONENT)
        service_on_second_cluster = second_cluster.service_add(
            name=FIRST_SERVICE)
        component_on_second_cluster = service_on_second_cluster.component(
            name=FIRST_COMPONENT)
        first_host = provider.host_create("host_in_first_cluster")
        second_host = provider.host_create("host_in_second_cluster")
        cluster_with_components.host_add(first_host)
        second_cluster.host_add(second_host)
        cluster_with_components.hostcomponent_set(
            (first_host, component_on_first_cluster))
        second_cluster.hostcomponent_set(
            (second_host, component_on_second_cluster))

        action_in_object_is_present(action_name, first_host)
        action_in_object_is_present(action_name, second_host)
        run_host_action_and_assert_result(first_host,
                                          action_name,
                                          status="success")
        run_host_action_and_assert_result(second_host,
                                          action_name,
                                          status="success")
Esempio n. 6
0
def test_ansible_set_on_prototype(cluster_obj_venv_9: Cluster,
                                  provider_obj_venv_9: Provider):
    """
    Check that we able to change ansible on prototype level, by tweaking venv
    property for object.
    """
    run_cluster_action_and_assert_result(cluster_obj_venv_9,
                                         "obj_venv_9",
                                         config=ANSIBLE_9)
    run_service_action_and_assert_result(
        cluster_obj_venv_9.service(name="obj_venv_9"),
        "obj_venv_9",
        config=ANSIBLE_9)
    run_component_action_and_assert_result(cluster_obj_venv_9.service(
        name="obj_venv_9").component(name="obj_venv_9"),
                                           "obj_venv_9",
                                           config=ANSIBLE_9)

    run_provider_action_and_assert_result(provider_obj_venv_9,
                                          "obj_venv_9",
                                          config=ANSIBLE_9)
    run_host_action_and_assert_result(
        provider_obj_venv_9.host(fqdn="obj_venv_9"),
        "obj_venv_9",
        config=ANSIBLE_9)
Esempio n. 7
0
def test_ansible_set_on_action(
    cluster_obj_venv_default_action_9: Cluster,
    cluster_obj_no_venv_action_9: Cluster,
    provider_obj_venv_default_action_9: Provider,
    provider_no_venv_action_9: Provider,
):
    """
    Check that we able to change ansible on action.
    """
    run_cluster_action_and_assert_result(cluster_obj_venv_default_action_9,
                                         "obj_venv_default_action_9",
                                         config=ANSIBLE_9)
    run_service_action_and_assert_result(
        cluster_obj_venv_default_action_9.service(
            name="obj_venv_default_action_9"),
        "obj_venv_default_action_9",
        config=ANSIBLE_9,
    )
    run_component_action_and_assert_result(
        cluster_obj_venv_default_action_9.service(
            name="obj_venv_default_action_9").component(
                name="obj_venv_default_action_9"),
        "obj_venv_default_action_9",
        config=ANSIBLE_9,
    )

    run_cluster_action_and_assert_result(cluster_obj_no_venv_action_9,
                                         "obj_no_venv_action_9",
                                         config=ANSIBLE_9)
    run_service_action_and_assert_result(
        cluster_obj_no_venv_action_9.service(name="obj_no_venv_action_9"),
        "obj_no_venv_action_9",
        config=ANSIBLE_9)
    run_component_action_and_assert_result(
        cluster_obj_no_venv_action_9.service(
            name="obj_no_venv_action_9").component(
                name="obj_no_venv_action_9"),
        "obj_no_venv_action_9",
        config=ANSIBLE_9,
    )

    run_provider_action_and_assert_result(provider_no_venv_action_9,
                                          "no_venv_action_9",
                                          config=ANSIBLE_9)
    run_host_action_and_assert_result(
        provider_no_venv_action_9.host(fqdn="no_venv_action_9"),
        "no_venv_action_9",
        config=ANSIBLE_9)

    run_provider_action_and_assert_result(provider_obj_venv_default_action_9,
                                          "obj_venv_default_action_9",
                                          config=ANSIBLE_9)
    run_host_action_and_assert_result(
        provider_obj_venv_default_action_9.host(
            fqdn="obj_venv_default_action_9"),
        "obj_venv_default_action_9",
        config=ANSIBLE_9,
    )
Esempio n. 8
0
 def test_availability_at_state(self, cluster: Cluster, provider: Provider):
     """
     Test that cluster host action is available on specify cluster state
     """
     host = provider.host_create("host_in_cluster")
     cluster.host_add(host)
     action_in_object_is_absent(ACTION_ON_HOST_STATE_REQUIRED, host)
     run_cluster_action_and_assert_result(cluster, SWITCH_CLUSTER_STATE)
     action_in_object_is_present(ACTION_ON_HOST_STATE_REQUIRED, host)
     run_host_action_and_assert_result(host, ACTION_ON_HOST_STATE_REQUIRED)
Esempio n. 9
0
def test_missing_ok_multi_state_unset(two_providers: Tuple[Provider, Provider],
                                      two_clusters: Tuple[Cluster, Cluster],
                                      sdk_client_fs: ADCMClient):
    """
    Checking behaviour of flag "missing_ok":
        - Job fails when flag is "false" and state is not in multi_state
        - Job succeed when flag is "true" and state is not in multi_state
    """
    host = (provider := two_providers[0]).host()
    component = (service := (cluster := two_clusters[0]).service()).component()
    with allure.step(
            'Check job fails with "missing_ok: false" and state not in multi_state'
    ):
        for forbidden_action in ('unset_provider', 'unset_host'):
            with check_objects_multi_state_changed(sdk_client_fs):
                run_host_action_and_assert_result(host, forbidden_action,
                                                  'failed')
        with check_objects_multi_state_changed(sdk_client_fs):
            run_provider_action_and_assert_result(provider,
                                                  'unset_host_from_provider',
                                                  status='failed',
                                                  config={'host_id': host.id})
        with check_objects_multi_state_changed(sdk_client_fs):
            run_cluster_action_and_assert_result(cluster,
                                                 'unset_cluster',
                                                 status='failed')
        with check_objects_multi_state_changed(sdk_client_fs):
            run_service_action_and_assert_result(service,
                                                 'unset_service',
                                                 status='failed')
        with check_objects_multi_state_changed(sdk_client_fs):
            run_component_action_and_assert_result(component,
                                                   'unset_component',
                                                   status='failed')

    with allure.step(
            'Check job succeed with "missing_ok: true" without changing multi_state of any object'
    ):
        for allowed_action in ('unset_provider_missing', 'unset_host_missing'):
            with check_objects_multi_state_changed(sdk_client_fs):
                run_host_action_and_assert_result(host, allowed_action)
        with check_objects_multi_state_changed(sdk_client_fs):
            run_provider_action_and_assert_result(
                provider,
                'unset_host_from_provider_missing',
                config={'host_id': host.id})
        with check_objects_multi_state_changed(sdk_client_fs):
            run_cluster_action_and_assert_result(cluster,
                                                 'unset_cluster_missing')
        with check_objects_multi_state_changed(sdk_client_fs):
            run_service_action_and_assert_result(service,
                                                 'unset_service_missing')
        with check_objects_multi_state_changed(sdk_client_fs):
            run_component_action_and_assert_result(component,
                                                   'unset_component_missing')
Esempio n. 10
0
 def test_availability(self, cluster: Cluster, provider: Provider,
                       action_name):
     """
     Test that cluster host action is available on cluster host and is absent on cluster
     """
     host1 = provider.host_create("host_in_cluster")
     host2 = provider.host_create("host_not_in_cluster")
     cluster.host_add(host1)
     action_in_object_is_present(action_name, host1)
     action_in_object_is_absent(action_name, host2)
     action_in_object_is_absent(action_name, cluster)
     run_host_action_and_assert_result(host1, action_name, status="success")
Esempio n. 11
0
def test_host_action_availability_at_state(provider: Provider):
    """
    Test that host action is available on specific host state
    """
    host_1 = provider.host_create("host-1-fqdn")
    host_2 = provider.host_create("host-2-fqdn")
    _assert_actions_state_created(host_1)
    run_provider_action_and_assert_result(provider, SWITCH_PROVIDER_STATE)
    _assert_actions_state_created(host_1)
    run_host_action_and_assert_result(host_1, SWITCH_HOST_STATE)
    _assert_actions_state_installed(host_1)
    _assert_actions_state_created(host_2)
    run_host_action_and_assert_result(host_1, ACTION_STATE_INSTALLED)
Esempio n. 12
0
def test_target_group_in_inventory(cluster_with_target_group_action: Cluster,
                                   provider: Provider, sdk_client_fs):
    """
    Test that target group action has inventory_hostname info
    """
    hostname = "host_in_cluster"
    host = provider.host_create(hostname)
    cluster_with_target_group_action.host_add(host)
    action_in_object_is_present(ACTION_ON_HOST, host)
    run_host_action_and_assert_result(host, ACTION_ON_HOST)
    with allure.step("Assert that hostname in job log is present"):
        assert (f"We are on host: {hostname}" in sdk_client_fs.job().log(
            type="stdout").content), "No hostname info in the job log"
Esempio n. 13
0
def test_actions(sdk_client_fs: ADCMClient):
    """
    Tests that action works on latest adcm client and old adcm versions
    """
    cluster_bundle = sdk_client_fs.upload_from_fs(get_data_dir(__file__, "cluster"))
    provider_bundle = sdk_client_fs.upload_from_fs(get_data_dir(__file__, 'provider'))
    cluster = cluster_bundle.cluster_prototype().cluster_create(name="Some cluster")
    service = cluster.service_add(name="dummy")
    provider = provider_bundle.provider_create("provider_with_actions")
    host = provider.host_create(fqdn="localhost")
    run_cluster_action_and_assert_result(cluster, "dummy")
    run_service_action_and_assert_result(service, "dummy")
    run_host_action_and_assert_result(host, "dummy")
    assert provider.action(name="dummy").run().wait() == "success"
Esempio n. 14
0
def test_default_ansible(
    cluster_no_venv: Cluster,
    cluster_obj_venv_default: Cluster,
    provider_no_venv: Provider,
    provider_obj_venv_default: Provider,
):
    """
    Check that by default (if developer write nothing) we have Ansible 2.8.
    """
    run_cluster_action_and_assert_result(cluster_no_venv,
                                         "no_venv",
                                         config=DEFAULT_ANSIBLE_VER)
    run_service_action_and_assert_result(
        cluster_no_venv.service(name="no_venv"),
        "no_venv",
        config=DEFAULT_ANSIBLE_VER)
    run_component_action_and_assert_result(
        cluster_no_venv.service(name="no_venv").component(name="no_venv"),
        "no_venv",
        config=DEFAULT_ANSIBLE_VER)

    run_cluster_action_and_assert_result(cluster_obj_venv_default,
                                         "obj_venv_default",
                                         config=DEFAULT_ANSIBLE_VER)
    run_service_action_and_assert_result(
        cluster_obj_venv_default.service(name="obj_venv_default"),
        "obj_venv_default",
        config=DEFAULT_ANSIBLE_VER)
    run_component_action_and_assert_result(
        cluster_obj_venv_default.service(name="obj_venv_default").component(
            name="obj_venv_default"),
        "obj_venv_default",
        config=DEFAULT_ANSIBLE_VER,
    )

    run_provider_action_and_assert_result(provider_no_venv,
                                          "no_venv",
                                          config=DEFAULT_ANSIBLE_VER)
    run_host_action_and_assert_result(provider_no_venv.host(fqdn="no_venv"),
                                      "no_venv",
                                      config=DEFAULT_ANSIBLE_VER)

    run_provider_action_and_assert_result(provider_obj_venv_default,
                                          "obj_venv_default",
                                          config=DEFAULT_ANSIBLE_VER)
    run_host_action_and_assert_result(
        provider_obj_venv_default.host(fqdn="obj_venv_default"),
        "obj_venv_default",
        config=DEFAULT_ANSIBLE_VER)
Esempio n. 15
0
 def run_immediate_change_test(self, provider_host: Tuple[Provider, Host],
                               cluster_service_component: Tuple[Cluster,
                                                                Service,
                                                                Component]):
     """
     Run the same action (self._action) for cluster, service, component, provider, host
         and expect them to succeed
     """
     cluster, service, component = cluster_service_component
     provider, host = provider_host
     run_cluster_action_and_assert_result(cluster, self._action)
     run_service_action_and_assert_result(service, self._action)
     run_component_action_and_assert_result(component, self._action)
     run_provider_action_and_assert_result(provider, self._action)
     run_host_action_and_assert_result(host, self._action)
Esempio n. 16
0
 def test_host_state_after_action(self, sdk_client_fs: ADCMClient,
                                  provider_and_states_checker):
     """Test host state after action"""
     provider_obj, check_objects_state_changed = provider_and_states_checker
     object_to_be_changed = provider_obj.host(fqdn=provider_obj.name)
     with check_objects_state_changed(
             sdk_client_fs,
         {object_to_be_changed
          }), allure.step(f'Run host action: {ACTION_NAME}'):
         run_host_action_and_assert_result(
             object_to_be_changed,
             action=ACTION_NAME,
             status="success"
             if "fail" not in provider_obj.name else "failed",
         )
Esempio n. 17
0
    def test_availability_at_host_state(self, cluster_with_service: Cluster,
                                        provider: Provider):
        """
        Test that service host action isn't available on specify host state
        """
        service = cluster_with_service.service_add(name=FIRST_SERVICE)
        host = provider.host_create("host_in_cluster")
        cluster_with_service.host_add(host)
        cluster_with_service.hostcomponent_set(
            (host, service.component(name=FIRST_COMPONENT)))

        action_in_object_is_absent(ACTION_ON_HOST_STATE_REQUIRED, host)
        run_host_action_and_assert_result(host, SWITCH_HOST_STATE)
        action_in_object_is_absent(ACTION_ON_HOST_STATE_REQUIRED, host)
        run_service_action_and_assert_result(service, SWITCH_SERVICE_STATE)
        action_in_object_is_present(ACTION_ON_HOST_STATE_REQUIRED, host)
        run_host_action_and_assert_result(host, ACTION_ON_HOST_STATE_REQUIRED)
Esempio n. 18
0
 def test_two_clusters(self, action_name, cluster: Cluster,
                       provider: Provider):
     """
     Test that cluster actions on host works fine on two clusters
     """
     second_cluster = cluster.bundle().cluster_prototype().cluster_create(
         name="Second cluster")
     first_host = provider.host_create("host_in_first_cluster")
     second_host = provider.host_create("host_in_second_cluster")
     cluster.host_add(first_host)
     second_cluster.host_add(second_host)
     action_in_object_is_present(action_name, first_host)
     action_in_object_is_present(action_name, second_host)
     run_host_action_and_assert_result(first_host,
                                       action_name,
                                       status="success")
     run_host_action_and_assert_result(second_host,
                                       action_name,
                                       status="success")
Esempio n. 19
0
 def test_host_multi_state_after_action(self, sdk_client_fs: ADCMClient,
                                        provider_and_multi_states_checker):
     """
     Test host and multi states after action
     Before action add multi state that should be unset via action
     """
     provider_obj, check_objects_state_changed = provider_and_multi_states_checker
     object_to_be_changed = provider_obj.host(fqdn=provider_obj.name)
     run_host_action_and_assert_result(object_to_be_changed,
                                       ACTION_SET_MULTISTATE_NAME)
     with check_objects_state_changed(
             sdk_client_fs,
         {object_to_be_changed
          }), allure.step(f'Run host action: {ACTION_NAME}'):
         run_host_action_and_assert_result(
             object_to_be_changed,
             action=ACTION_NAME,
             status="success"
             if "fail" not in provider_obj.name else "failed",
         )
Esempio n. 20
0
    def test_availability(self, cluster_with_components: Cluster,
                          provider: Provider, action_name):
        """
        Test that component host action is available on a component host
        """
        service = cluster_with_components.service_add(name=FIRST_SERVICE)
        component_with_action = service.component(name=FIRST_COMPONENT)
        component_without_action = service.component(name=SECOND_COMPONENT)

        host_single_component = provider.host_create(
            "host_with_single_component")
        host_two_components = provider.host_create("host_with_two_components")
        host_component_without_action = provider.host_create(
            "host_component_without_action")
        host_without_components = provider.host_create(
            "host_without_components")
        host_outside_cluster = provider.host_create("host_outside_cluster")
        for host in [
                host_single_component,
                host_two_components,
                host_component_without_action,
                host_without_components,
        ]:
            cluster_with_components.host_add(host)
        cluster_with_components.hostcomponent_set(
            (host_single_component, component_with_action),
            (host_two_components, component_with_action),
            (host_two_components, component_without_action),
            (host_component_without_action, component_without_action),
        )
        action_in_object_is_present(action_name, host_single_component)
        action_in_object_is_present(action_name, host_two_components)
        action_in_object_is_absent(action_name, host_component_without_action)
        action_in_object_is_absent(action_name, host_without_components)
        action_in_object_is_absent(action_name, host_outside_cluster)
        action_in_object_is_absent(action_name, cluster_with_components)
        action_in_object_is_absent(action_name, service)
        action_in_object_is_absent(action_name, component_with_action)
        action_in_object_is_absent(action_name, component_without_action)
        run_host_action_and_assert_result(host_single_component, action_name)
        run_host_action_and_assert_result(host_two_components, action_name)
Esempio n. 21
0
def test_forbidden_state_set_actions(sdk_client_fs: ADCMClient):
    """
    Check that forbidden caller-context combinations fail as actions
        and don't affect any ADCM objects
    """
    name = "first"
    first_first_fqdn = "first-first"
    first_second_fqdn = "first-second"
    with allure.step(f'Check forbidden from cluster "{name}" context actions'):
        cluster = sdk_client_fs.cluster(name=name)
        for forbidden_action in ('set_service', 'set_component'):
            with check_objects_state_changed(sdk_client_fs):
                run_cluster_action_and_assert_result(cluster,
                                                     forbidden_action,
                                                     status='failed')
    with allure.step(f'Check forbidden from service "{name}" context actions'):
        service = cluster.service(name=name)
        with check_objects_state_changed(sdk_client_fs):
            run_service_action_and_assert_result(service,
                                                 'set_component',
                                                 status='failed')
    with allure.step(
            f'Check forbidden from provider "{name}" context actions'):
        provider = sdk_client_fs.provider(name=name)
        with check_objects_state_changed(sdk_client_fs):
            run_provider_action_and_assert_result(provider,
                                                  'set_host',
                                                  status='failed')
    with allure.step(
            f'Check forbidden from host "{first_first_fqdn}" context actions'):
        host_first = sdk_client_fs.host(fqdn=first_first_fqdn)
        host_second = sdk_client_fs.host(fqdn=first_second_fqdn)
        with check_objects_state_changed(sdk_client_fs):
            run_host_action_and_assert_result(
                host_first,
                'set_host_from_provider',
                config={'host_id': host_second.id},
                status='failed')
Esempio n. 22
0
    def test_availability(self, cluster_with_service: Cluster,
                          provider: Provider, action_name):
        """
        Test that service host action is available on a service host and is absent on cluster
        """
        service = cluster_with_service.service_add(name=FIRST_SERVICE)
        second_service = cluster_with_service.service_add(name=SECOND_SERVICE)
        host_with_two_components = provider.host_create(
            "host_with_two_components")
        host_with_one_component = provider.host_create(
            "host_with_one_component")
        host_without_component = provider.host_create("host_without_component")
        host_with_different_services = provider.host_create(
            "host_with_different_services")
        host_outside_cluster = provider.host_create("host_outside_cluster")
        for host in [
                host_with_two_components,
                host_with_one_component,
                host_without_component,
                host_with_different_services,
        ]:
            cluster_with_service.host_add(host)
        cluster_with_service.hostcomponent_set(
            (host_with_two_components,
             service.component(name=FIRST_COMPONENT)),
            (host_with_two_components,
             service.component(name=SECOND_COMPONENT)),
            (host_with_one_component, service.component(name=FIRST_COMPONENT)),
            (host_with_different_services,
             service.component(name=SECOND_COMPONENT)),
            (host_with_different_services,
             second_service.component(name=FIRST_COMPONENT)),
        )

        action_in_object_is_present(action_name, host_with_one_component)
        action_in_object_is_present(action_name, host_with_two_components)
        action_in_object_is_present(action_name, host_with_different_services)
        action_in_object_is_absent(action_name, host_without_component)
        action_in_object_is_absent(action_name, host_outside_cluster)
        action_in_object_is_absent(action_name, cluster_with_service)
        action_in_object_is_absent(action_name, service)
        run_host_action_and_assert_result(host_with_one_component, action_name)
        run_host_action_and_assert_result(host_with_two_components,
                                          action_name)
        run_host_action_and_assert_result(host_with_different_services,
                                          action_name)