Exemple #1
0
def _test_successful_multi_state_set_unset(
    set_action_name: str,
    object_to_be_changed: Tuple[str, ...],
    action_owner: Tuple[str, ...],
    sdk_client_fs: ADCMClient,
    get_object_func: Callable[..., AnyADCMObject],
):
    """Test successful multi state of one object set and then unset"""
    action_owner_object = get_object_func(sdk_client_fs, *action_owner)
    action_owner_name = compose_name(action_owner_object)
    object_to_be_changed = get_object_func(sdk_client_fs,
                                           *object_to_be_changed)
    changed_object_name = compose_name(object_to_be_changed)
    with allure.step(SET_STEP_TITLE):
        with check_objects_multi_state_changed(
                sdk_client_fs,
            {object_to_be_changed}), allure.step(
                f'Set multi state of {changed_object_name} with action from {action_owner_name}'
            ):
            run_successful_task(
                action_owner_object.action(name=set_action_name),
                action_owner_name)
    with allure.step(UNSET_STEP_TITLE):
        with check_multi_state_was_unset(
                sdk_client_fs,
            {object_to_be_changed}), allure.step(
                f'Unset multi state of {changed_object_name} with action from {action_owner_name}'
            ):
            run_successful_task(
                action_owner_object.action(name=f'un{set_action_name}'),
                action_owner_name)
Exemple #2
0
def test_multi_state_set_unset_from_different_objects(
        two_clusters: Tuple[Cluster, Cluster], sdk_client_fs: ADCMClient):
    """
    Check that one object change multi-state of another object
        and another object can unset this multi-state
    """
    cluster = two_clusters[0]
    cluster_name = compose_name(cluster)
    service = cluster.service()
    service_name = compose_name(service)
    with check_objects_multi_state_changed(sdk_client_fs, {
            service
    }), allure.step(f'Set multi_state of {service_name} from {cluster_name}'):
        run_cluster_action_and_assert_result(cluster,
                                             f'set_{service.name}_service')

    with check_multi_state_was_unset(
            sdk_client_fs,
        {service
         }), allure.step(f'Unset multi_state of {service_name} from itself'):
        run_service_action_and_assert_result(service, 'unset_service')

    with check_objects_multi_state_changed(
            sdk_client_fs,
        {cluster
         }), allure.step(f'Set multi_state of {cluster_name} from itself'):
        run_cluster_action_and_assert_result(cluster, 'set_cluster')

    with check_multi_state_was_unset(sdk_client_fs, {cluster}), allure.step(
            f'Unset multi_state of {cluster_name} from {service_name}'):
        run_service_action_and_assert_result(service, 'unset_cluster')
Exemple #3
0
def test_host_from_provider(two_providers: Tuple[Provider, Provider],
                            sdk_client_fs: ADCMClient):
    """Change host state from provider"""
    provider = two_providers[0]
    host = provider.host_list()[0]
    provider_name = compose_name(provider)
    host_name = compose_name(host)
    with check_objects_state_changed(sdk_client_fs, {host}), allure.step(
            f'Set state of {host_name} with action from {provider_name}'):
        run_provider_action_and_assert_result(provider,
                                              'set_host_from_provider',
                                              config={'host_id': host.id})
Exemple #4
0
def _test_successful_config_change(
    action_name: str,
    object_to_be_changed: Tuple[str, ...],
    action_owner: Tuple[str, ...],
    sdk_client_fs: ADCMClient,
    get_object_func: Callable[..., AnyADCMObject],
):
    """Test successful change of config of one object"""
    object_to_be_changed = get_object_func(sdk_client_fs,
                                           *object_to_be_changed)
    changed_object_name = compose_name(object_to_be_changed)
    action_owner_object = get_object_func(sdk_client_fs, *action_owner)
    action_owner_name = compose_name(action_owner_object)
    with check_config_changed(
            sdk_client_fs,
        {object_to_be_changed}), allure.step(
            f'Change config of {changed_object_name} with action from {action_owner_name}'
        ):
        run_successful_task(action_owner_object.action(name=action_name),
                            action_owner_name)
Exemple #5
0
def test_cluster_related_objects(
    action_name: str,
    object_to_be_changed: Tuple[str, ...],
    action_owner: Tuple[str, ...],
    sdk_client_fs: ADCMClient,
):
    """
    Check that correct set state calls can run successfully
        with Cluster, Service, Component
        and change only the objects that must be changed
    """
    object_to_be_changed = get_cluster_related_object(sdk_client_fs,
                                                      *object_to_be_changed)
    changed_object_name = compose_name(object_to_be_changed)
    action_owner_object = get_cluster_related_object(sdk_client_fs,
                                                     *action_owner)
    action_owner_name = compose_name(action_owner_object)
    with check_objects_state_changed(
            sdk_client_fs,
        {object_to_be_changed}), allure.step(
            f'Set state of {changed_object_name} with action from {action_owner_name}'
        ):
        run_successful_task(action_owner_object.action(name=action_name),
                            action_owner_name)
Exemple #6
0
def test_multijob(two_clusters: Tuple[Cluster, Cluster],
                  two_providers: Tuple[Provider,
                                       Provider], sdk_client_fs: ADCMClient):
    """Check that multijob actions change config or object itself"""
    component = (service := (cluster := two_clusters[0]).service()).component()
    host = (provider := two_providers[0]).host()
    affected_objects = set()
    for obj in (cluster, service, component, provider, host):
        classname = obj.__class__.__name__.lower()
        affected_objects.add(obj)
        object_name = compose_name(obj)
        with check_config_changed(
                sdk_client_fs, affected_objects), allure.step(
                    f'Change {object_name} state with multijob action'):
            run_successful_task(
                obj.action(name=f'change_{classname}_multijob'), object_name)