Пример #1
0
def get_provider_related_object(
        client: ADCMClient,
        provider: str = 'first',
        host: Optional[str] = None) -> ProviderRelatedObject:
    """
    Get function to get one of ADCM provider objects:

    - Provider (host is None)
    - Host (host FQDN is provided)
    """
    if host is None:
        return client.provider(name=provider)
    return client.provider(name=provider).host(fqdn=host)
Пример #2
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})
Пример #3
0
def test_forbidden_multi_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"
    with allure.step(f'Check forbidden from cluster "{name}" context actions'):
        cluster = sdk_client_fs.cluster(name=name)
        # missing is used because it should fail for misconfiguration reasons, not because state not set
        for forbidden_action in ('set_service', 'set_component',
                                 'unset_service_missing',
                                 'unset_component_missing'):
            with check_objects_multi_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)
        for forbidden_action in ('set_component', 'unset_component_missing'):
            with check_objects_multi_state_changed(sdk_client_fs):
                run_service_action_and_assert_result(service,
                                                     forbidden_action,
                                                     status='failed')
    with allure.step(
            f'Check forbidden from provider "{name}" context actions'):
        provider = sdk_client_fs.provider(name=name)
        for forbidden_action in ('set_host', 'unset_host_missing'):
            with check_objects_multi_state_changed(sdk_client_fs):
                run_provider_action_and_assert_result(provider,
                                                      forbidden_action,
                                                      status='failed')
def test_upgrade_infrastructure_bundle(user_policy, user_sdk: ADCMClient,
                                       prepare_objects, sdk_client_fs, user):
    """Test that Upgrade infrastructure bundle role is ok"""
    cluster, *_, provider, _ = as_user_objects(user_sdk, *prepare_objects)
    *_, provider_via_admin, _ = prepare_objects
    second_provider = user_sdk.provider(
        id=provider_via_admin.bundle().provider_create(
            name="Second provider").id)

    is_allowed(provider, BR.UpgradeProviderBundle)
    is_denied(cluster, BR.UpgradeProviderBundle)
    is_denied(second_provider, BR.UpgradeProviderBundle)

    new_policy = create_policy(sdk_client_fs,
                               BR.UpgradeProviderBundle,
                               objects=[second_provider],
                               users=[user],
                               groups=[])
    delete_policy(new_policy)
    is_denied(second_provider, BR.UpgradeProviderBundle)
Пример #5
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')
Пример #6
0
def test_provider_state_after_multijob(sdk_client_ms: ADCMClient, provider):
    with allure.step('Run provider action: multi'):
        provider.action_run(name="multi").wait()
    with allure.step('Check provider state'):
        assert sdk_client_ms.provider(name=provider.name).state == provider.name