Пример #1
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)
Пример #2
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")
Пример #3
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)
Пример #4
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")
Пример #5
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"
Пример #6
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)
Пример #7
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")
Пример #8
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)
Пример #9
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)