示例#1
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")
示例#2
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,
    )
示例#3
0
 def test_get_host_list(self, sdk_client_fs: ADCMClient, provider: Provider):
     """
     Create multiple hosts and check that all hosts was created
     """
     actual, expected = [], []
     for fqdn in utils.random_string_list():
         provider.host_create(fqdn)
         expected.append(fqdn)
     for host in sdk_client_fs.host_list():
         actual.append(host.fqdn)
     with allure.step("Check created hosts with the data from the API"):
         assert all(expected_host in actual for expected_host in expected)
示例#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_create_one_host(second_p: Provider):
    """Test scenario:

    1. Create three providers
    2. Create host on one of the providers
    3. Ensure host exists
    """
    hostname = "second_h"
    with allure.step('Run action create host'):
        second_p.action(name="create_host").run(config_diff={'fqdn': hostname}).try_wait()
        second_h = second_p.host(fqdn=hostname)
    with allure.step('Check if host is created'):
        assert second_h.provider().id == second_p.id
        assert second_h.fqdn == hostname
示例#6
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)
示例#7
0
 def test_invoker_object_url(self, cluster: Cluster, provider: Provider,
                             page: JobListPage):
     """Check link to object that invoked action is correct"""
     host_fqdn = 'run-on-me'
     host_job_link = f'{provider.name}/{host_fqdn}'
     component_link = f'{CLUSTER_NAME}/{SERVICE_NAME}/{COMPONENT_NAME}'
     host_component_link = f'{component_link}/{host_fqdn}'
     with allure.step('Run action on component and check job link to it'):
         service: Service = cluster.service(name=SERVICE_NAME)
         component: Component = service.component(name=COMPONENT_NAME)
         component_action = component.action(
             display_name=COMPONENT_ACTION_DISPLAY_NAME)
         _check_link_to_invoker_object(component_link, page,
                                       component_action)
     with allure.step(
             'Create host, run action on host and check job link to it'):
         host = provider.host_create(host_fqdn)
         host_action = host.action(display_name=FAIL_ACTION_DISPLAY_NAME)
         _check_link_to_invoker_object(host_job_link, page, host_action)
     with allure.step('Add host to the cluster, assign component on it'):
         cluster.host_add(host)
         cluster.hostcomponent_set((host, component))
     with allure.step(
             'Run component host action on host and check job link to it'):
         host_action = _wait_and_get_action_on_host(
             host, ON_HOST_ACTION_DISPLAY_NAME)
         _check_link_to_invoker_object(host_component_link, page,
                                       host_action)
示例#8
0
 def test_no_horizontal_lock(self, host_provider: Provider, host: Host, lock_action):
     """
     Test that no horizontal lock when host locked
     """
     second_host = host_provider.host_create(fqdn=random_string())
     _lock_obj(host, lock_action)
     is_free(second_host)
示例#9
0
 def test_no_horizontal_lock(self, host_provider: Provider, lock_action):
     """
     Test that no horizontal lock when host locked
     """
     second_provider = host_provider.prototype().provider_create(name=random_string())
     _lock_obj(host_provider, lock_action)
     is_free(second_provider)
示例#10
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)
示例#11
0
def test_config_not_presented(cluster: Cluster, provider: Provider,
                              sdk_client_fs: ADCMClient):
    """
    Action's configuration not presented
    Run action with config
    """
    job_count = len(sdk_client_fs.job_list())
    component = (service := cluster.service()).component()
    host = provider.host()
    for obj in (cluster, service, component, provider, host):
        with allure.step(
                f'Check no config with action on {obj.__class__.__name__}'):
            with allure.step(
                    'Run action without config and expect it to fail with ansible error'
            ):
                try:
                    ACTION_MAP[obj.__class__](obj,
                                              'no_config',
                                              'failed',
                                              config={
                                                  'some_param': "1"
                                              })
                except ErrorMessage as e:
                    CONFIG_VALUE_ERROR.equal(e)
                else:
                    raise AssertionError("Action run request should've failed")
            with allure.step("Check that job wasn't launched"):
                _check_job_count_equal_to(job_count, sdk_client_fs)
示例#12
0
def test_incorrect_config(cluster: Cluster, provider: Provider,
                          sdk_client_fs: ADCMClient):
    """
    Action's configuration not presented
    Run action with "incorrect" config
    """
    job_count = len(sdk_client_fs.job_list())
    component = (service := cluster.service()).component()
    host = provider.host()
    for obj in (cluster, service, component, provider, host):
        with allure.step(
                f'Check "incorrect" config with action on {obj.__class__.__name__}'
        ):
            with allure.step(
                    'Run action with "incorrect" config and expect ADCM response with non 500 status code'
            ):
                try:
                    ACTION_MAP[obj.__class__](obj,
                                              'with_config',
                                              'failed',
                                              config={
                                                  'no_such_param': "1"
                                              })
                except ErrorMessage as e:
                    CONFIG_KEY_ERROR.equal(e)
                else:
                    raise AssertionError("Action should've failed")
            with allure.step("Check that job wasn't launched"):
                _check_job_count_equal_to(job_count, sdk_client_fs)
示例#13
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)
示例#14
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)
示例#15
0
 def test_host_belong_to_cluster_should_not_deleted(self, cluster: Cluster, provider: Provider):
     """Test that we should be unable to delete host bounded to cluster"""
     host = provider.host_create(utils.random_string())
     cluster.host_add(host)
     with pytest.raises(coreapi.exceptions.ErrorMessage) as e:
         host.delete()
     with allure.step("Check error host belong to cluster"):
         err.HOST_CONFLICT.equal(e, "Host", "belong to cluster")
示例#16
0
def cluster_with_two_hosts(cluster: Cluster, host_provider: Provider) -> Tuple[Cluster, List[Host]]:
    """Add service, component and host to cluster twice"""
    hosts = []
    for i in range(2):
        host = host_provider.host_create(f"host_{i}")
        hosts.append(host)
        cluster.host_add(host)
    return cluster, hosts
示例#17
0
def test_check_host_lock_during_operations(forth_p: Provider):
    """Test scenario:

    1. Create provider
    2. Create host first host on provider
    3. Run job that creates the second host on provider
    4. Wait until second host will be created.
    5. Check that both host is locked
    6. Wait for job to be finished without errors
    7. Check that both hosts is free
    8. Run remove action on one of hosts
    9. Check that host under action is locked, while other host is free
    10. Wait for job to be finished without errors
    11. Check that remaining host is free.
    """
    with allure.step('Create host first host on provider'):
        forth_p.action(name="create_host").run(config_diff={'fqdn': "forth_one"}).try_wait()
    with allure.step('Run job that creates the second host on provider'):
        job = forth_p.action(name="create_host").run(config={'fqdn': "forth_two", 'sleep': 2})
    with allure.step('Wait until second host will be created'):
        wait_until_step_succeeds(_assert_that_object_exists, period=0.5, get_object_func=forth_p.host, fqdn="forth_two")
        forth_two_h = forth_p.host(fqdn="forth_two")
        forth_one_h = forth_p.host(fqdn='forth_one')
    with allure.step('Check that both host has is locked'):
        assert forth_one_h.locked is True
        assert forth_two_h.locked is True
    with allure.step('Wait for job to be finished without errors'):
        job.try_wait()
    with allure.step('Check that both hosts is free'):
        forth_one_h.reread()
        forth_two_h.reread()
        assert forth_one_h.locked is False
        assert forth_two_h.locked is False
    with allure.step('Run remove action on one of hosts'):
        job = forth_one_h.action(name="remove_host").run(config={"sleep": 2})
    with allure.step('Check that host under action is locked, while other host is free'):
        forth_one_h.reread()
        forth_two_h.reread()
        assert forth_one_h.locked is True
        assert forth_two_h.locked is False
    with allure.step('Wait for job to be finished without errors'):
        job.try_wait()
    with allure.step('Check that remaining host is free'):
        forth_two_h.reread()
        assert forth_two_h.locked is False
示例#18
0
 def test_get_cluster_host_info(self, cluster: Cluster, provider: Provider):
     """Test get cluster host info"""
     host = provider.host_create(utils.random_string())
     with allure.step("Create mapping between cluster and host"):
         expected = cluster.host_add(host)
     with allure.step("Get cluster host info"):
         host.reread()
     with allure.step("Check test results"):
         _check_hosts(host, expected)
示例#19
0
 def test_adding_host_to_cluster(self, cluster: Cluster, provider: Provider):
     """Test add host to cluster"""
     host = provider.host_create(utils.random_string())
     expected = cluster.host_add(host)
     with allure.step("Get cluster host info"):
         host_list = cluster.host_list()
         assert len(host_list) == 1
         actual = host_list[0]
     with allure.step("Check mapping"):
         _check_hosts(actual, expected)
示例#20
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)
示例#21
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")
示例#22
0
 def test_delete_host_from_cluster(self, cluster: Cluster, provider: Provider):
     """Test delete host from cluster"""
     host = provider.host_create(utils.random_string())
     expected = cluster.host_list()
     with allure.step("Create mapping between cluster and host"):
         cluster.host_add(host)
     with allure.step("Deleting host from cluster"):
         cluster.host_delete(host)
     actual = cluster.host_list()
     with allure.step("Check host removed from cluster"):
         assert actual == expected
示例#23
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)
示例#24
0
 def test_get_cluster_hosts_list(self, cluster: Cluster, provider: Provider):
     """Test get cluster hosts list"""
     actual, expected = [], []
     with allure.step("Create host list in cluster"):
         for fqdn in utils.random_string_list():
             host = provider.host_create(fqdn)
             cluster.host_add(host)
             expected.append(host.id)
     for host in cluster.host_list():
         actual.append(host.id)
     with allure.step("Check test data"):
         assert actual == expected
示例#25
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"
示例#26
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)
示例#27
0
def _expect_correct_fail_on_config(cluster: Cluster, provider: Provider,
                                   config: dict, error: ADCMError):
    """Check that config_set fails with CONFIG_VALUE_ERROR"""
    component = (service := cluster.service()).component()
    host = provider.host()
    for obj in (cluster, service, component, provider, host):
        with allure.step(
                f'Try to change config of {obj.__class__.__name__} and expect {error}'
        ):
            try:
                obj.config_set(config)
            except ErrorMessage as e:
                error.equal(e)
            else:
                raise AssertionError("Config set should've failed")
示例#28
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)
示例#29
0
 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
示例#30
0
 def test_create_hostcomponent(self, sdk_client_fs: ADCMClient, provider: Provider):
     """
     Check that hostcomponent is set
     """
     bundle = sdk_client_fs.upload_from_fs(get_data_dir(__file__, "cluster_service_hostcomponent"))
     cluster = bundle.cluster_create(utils.random_string())
     host = provider.host_create(utils.random_string())
     cluster.host_add(host)
     service = cluster.service_add(name="ZOOKEEPER")
     component = service.component(name="ZOOKEEPER_CLIENT")
     cluster.hostcomponent_set((host, component))
     with allure.step("Check host component map"):
         hc_map = cluster.hostcomponent()
         assert len(hc_map) == 1
         assert hc_map[0]["host_id"] == host.id
         assert hc_map[0]["component_id"] == component.id