Beispiel #1
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})
Beispiel #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)
Beispiel #3
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')
Beispiel #4
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')
Beispiel #5
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)
Beispiel #6
0
 def test_correct_hc_change(self, cluster_with_service: Tuple[Cluster, Service]):
     """
     Check that correct "break" of HC constraints works.
     Correct "break" is when constraints are satisfied after the action's end
     but was "broken" during action execution.
     """
     cluster, _ = cluster_with_service
     run_cluster_action_and_assert_result(cluster, 'correct_hc_map_change')
Beispiel #7
0
def test_double_call_to_state_set(two_clusters: Tuple[Cluster, Cluster],
                                  sdk_client_fs: ADCMClient):
    """Test that double call to plugin from two files doesn't fail"""
    cluster = two_clusters[0]
    run_cluster_action_and_assert_result(cluster, 'double_call_two_playbooks')
    with allure.step(
            f'Check only state of Cluster "{cluster.name}" was changed'):
        check_objects_state_changed(sdk_client_fs, {cluster})
Beispiel #8
0
def test_cluster_action_availability_at_state(cluster: Cluster):
    """
    Test that cluster host action is available on a specific cluster state
    """
    _assert_actions_state_created(cluster)
    run_cluster_action_and_assert_result(cluster, SWITCH_CLUSTER_STATE)
    _assert_actions_state_installed(cluster)
    run_cluster_action_and_assert_result(cluster, ACTION_STATE_INSTALLED)
Beispiel #9
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,
    )
Beispiel #10
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)
Beispiel #11
0
def test_default_ansible_forks(testing_cluster):
    """
    Check that default ansible fork count is 5
    """
    run_cluster_action_and_assert_result(testing_cluster,
                                         "assert_fork",
                                         config=dict(fork_count=5))
    run_cluster_action_and_assert_result(testing_cluster,
                                         "assert_fork_multijob",
                                         config=dict(fork_count=5))
Beispiel #12
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')
def test_fail_action(sdk_client_fs, bundle_dir):
    """Run fail action and assert result"""
    bundle_dir_full = get_data_dir(__file__, bundle_dir)
    bundle = sdk_client_fs.upload_from_fs(bundle_dir_full)
    cluster = bundle.cluster_create("test_cluster")
    with pytest.raises(AssertionError) as action_run_exception:
        run_cluster_action_and_assert_result(cluster=cluster,
                                             action="fail_action")
    assert "Meant to fail" in str(
        action_run_exception.value
    ), "No ansible error in AssertionError message"
def test_fail_action_with_error_matching(sdk_client_fs, bundle_dir):
    """Run fail action and assert that result is matched with custom assert errors"""
    bundle_dir_full = get_data_dir(__file__, bundle_dir)
    bundle = sdk_client_fs.upload_from_fs(bundle_dir_full)
    cluster = bundle.cluster_create("test_cluster")
    with pytest.raises(BundleError):
        run_cluster_action_and_assert_result(
            cluster=cluster, action="fail_action_with_bundle_error")
    with pytest.raises(InfrastructureProblem):
        run_cluster_action_and_assert_result(
            cluster=cluster, action="fail_action_with_infrastructure_problem")
Beispiel #15
0
 def run_actions_after_upgrade(
     self, cluster_all_services: Cluster, cluster_config_history: Cluster, simple_provider: Provider
 ) -> None:
     """
     Run successful actions on: cluster, service, component.
     Run failed action on provider.
     """
     sauce_service = cluster_config_history.service(name=self.SAUCE_SERVICE)
     run_cluster_action_and_assert_result(cluster_all_services, 'eat_sandwich')
     run_service_action_and_assert_result(sauce_service, 'put_on_bread')
     run_component_action_and_assert_result(sauce_service.component(name=self.SPICE_COMPONENT), 'add_more')
     run_provider_action_and_assert_result(simple_provider, 'validate', status='failed')
 def test_check_that_file_field_put_correct_data_in_file_inside_docker(
         self, cluster: Cluster):
     """Another mysterious type checking test"""
     test_data = "lorem ipsum"
     with allure.step("Create config data"):
         config_data = utils.ordered_dict_to_dict(cluster.config())
         config_data["input_file"] = test_data
         config_data["required"] = 42
     with allure.step("Create config history"):
         cluster.config_set(config_data)
     with allure.step("Check file type"):
         run_cluster_action_and_assert_result(cluster=cluster,
                                              action="check-file-type")
def test_verbose_actions_option_with_custom_verbose(sdk_client_fs, bundle_dir):
    """
    Test that custom verbose param for action
    has higher priority then verbose_actions option
    """
    bundle_dir_full = get_data_dir(__file__, bundle_dir)
    bundle = sdk_client_fs.upload_from_fs(bundle_dir_full)
    cluster = bundle.cluster_create("test_cluster")
    options.verbose_actions = True
    run_cluster_action_and_assert_result(cluster=cluster,
                                         action="simple_action",
                                         verbose=False)
    assert "verbosity: 4" not in sdk_client_fs.job_list()[0].log_list(
    )[0].content
Beispiel #18
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"
Beispiel #19
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)
Beispiel #20
0
def test_service_action_availability_at_state(cluster_with_service: Cluster):
    """
    Test that service action is available on specific service state
    """
    service_1 = cluster_with_service.service_add(name=FIRST_SERVICE)
    service_2 = cluster_with_service.service_add(name=SECOND_SERVICE)

    _assert_actions_state_created(service_1)
    run_cluster_action_and_assert_result(cluster_with_service,
                                         SWITCH_CLUSTER_STATE)
    _assert_actions_state_created(service_1)
    run_service_action_and_assert_result(service_1, SWITCH_SERVICE_STATE)
    _assert_actions_state_installed(service_1)
    _assert_actions_state_created(service_2)
    run_service_action_and_assert_result(service_1, ACTION_STATE_INSTALLED)
Beispiel #21
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)
Beispiel #22
0
 def test_cluster_state_after_action(self, sdk_client_fs: ADCMClient,
                                     cluster_and_states_checker):
     """Test cluster state after action"""
     cluster_obj, check_objects_state_changed = cluster_and_states_checker
     object_to_be_changed = cluster_obj
     with check_objects_state_changed(
             sdk_client_fs,
         {object_to_be_changed
          }), allure.step(f'Run cluster action: {ACTION_NAME}'):
         run_cluster_action_and_assert_result(
             object_to_be_changed,
             action=ACTION_NAME,
             status="success"
             if "fail" not in cluster_obj.name else "failed",
         )
Beispiel #23
0
def test_all_fields(sdk_client_fs: ADCMClient, name, result):
    """Check that we can run jobs with all fields for
    adcm_check task and check all fields after action
    execution.
    """
    group_msg, task_msg, group_result, task_result = result
    params = {
        "action": "adcm_check",
        "expected_state": States.success,
        "expected_title": "Name of group check.",
        "content_title": "Check",
    }
    cluster = sdk_client_fs.upload_from_fs(utils.get_data_dir(
        __file__, name)).cluster_create(utils.random_string())
    task = run_cluster_action_and_assert_result(
        cluster, action=params["action"], status=params["expected_state"])
    job = task.job()
    with allure.step("Check all fields after action execution"):
        logs = job.log_list()
        content = job.log(job_id=job.id, log_id=logs[2].id).content[0]
        assert content[
            "message"] == group_msg, f'Expected message {group_msg}. Current message {content["message"]}'
        assert content["result"] is group_result
        assert (
            content["title"] == params["expected_title"]
        ), f'Expected title {params["expected_title"]}. Current title {content["title"]}'
        content_title = content["content"][0]["title"]
        assert (
            content_title == params["content_title"]
        ), f'Expected title {params["content_title"]}. Current title {content_title}'
        content_message = content["content"][0]["message"]
        assert content_message == task_msg, f"Expected message {task_msg}. Current message {content_message}"
        assert content["content"][0]["result"] is task_result
def test_verbose_actions_option(sdk_client_fs, bundle_dir):
    """
    Test verbose_actions option
    Assert attr presence
    Assert attr type
    Assert verbose state in action logs
    """
    bundle_dir_full = get_data_dir(__file__, bundle_dir)
    bundle = sdk_client_fs.upload_from_fs(bundle_dir_full)
    cluster = bundle.cluster_create("test_cluster")
    assert hasattr(options, "verbose_actions")
    assert isinstance(options.verbose_actions, bool)
    options.verbose_actions = True
    run_cluster_action_and_assert_result(cluster=cluster,
                                         action="simple_action")
    assert "verbosity: 4" in sdk_client_fs.job_list()[0].log_list()[0].content
Beispiel #25
0
 def test_run_multijob(self, cluster: Cluster, page: JobListPage):
     """Run action with many jobs"""
     with allure.step('Run action with multiple job'):
         action = cluster.action(display_name=MULTIJOB_ACTION_DISPLAY_NAME)
         task = run_cluster_action_and_assert_result(cluster, action.name)
     page.expand_task_in_row(0)
     with allure.step('Check jobs info'):
         expected_jobs = [{
             'name': job['name'],
             'status': JobStatus.SUCCESS
         } for job in action.subs]
         jobs_info = page.get_all_jobs_info()
         assert (expected_amount := len(expected_jobs)) == (
             actual_amount := len(jobs_info)
         ), ('Amount of jobs is not correct: '
             f'should be {expected_amount}, but {actual_amount} was found')
         for i in range(actual_amount):
             assert (actual_info := asdict(jobs_info[i])) == (
                 expected_info := expected_jobs[i]
             ), f'Job at position #{i} should be {expected_info}, not {actual_info}'
     with allure.step("Open first job's page"):
         page.click_on_job()
         detail_page = JobPageStdout(page.driver, page.base_url,
                                     task.jobs[0]['id'])
         detail_page.wait_page_is_opened()
Beispiel #26
0
def test_double_call_to_multi_state_set(two_clusters: Tuple[Cluster, Cluster],
                                        sdk_client_fs: ADCMClient):
    """Test that double call to plugin from two files doesn't fail"""
    check_multi_state_after_set = build_objects_checker(
        sorted(['much', 'better', 'actually']),
        extractor=_multi_state_extractor,
        field_name=FIELD_NAME)
    check_multi_state_after_unset = build_objects_checker(
        ['actually'], extractor=_multi_state_extractor, field_name=FIELD_NAME)
    cluster = two_clusters[0]
    with allure.step(SET_STEP_TITLE):
        with check_multi_state_after_set(sdk_client_fs, {cluster}):
            run_cluster_action_and_assert_result(cluster,
                                                 'double_call_two_playbooks')
    with allure.step(UNSET_STEP_TITLE):
        with check_multi_state_after_unset(sdk_client_fs, {cluster}):
            run_cluster_action_and_assert_result(cluster, 'double_unset')
Beispiel #27
0
def test_custom_ansible_forks(sdk_client_fs, testing_cluster):
    """
    Check that custom ansible fork count works fine for job and multijob actions
    """
    custom_forks_count = 10
    sdk_client_fs.adcm().config_set_diff(
        {"ansible_settings": {
            "forks": custom_forks_count
        }})
    run_cluster_action_and_assert_result(
        testing_cluster,
        "assert_fork",
        config=dict(fork_count=custom_forks_count))
    run_cluster_action_and_assert_result(
        testing_cluster,
        "assert_fork_multijob",
        config=dict(fork_count=custom_forks_count))
Beispiel #28
0
 def test_cluster_multi_state_after_action(
         self, sdk_client_fs: ADCMClient, cluster_and_multi_states_checker):
     """
     Test cluster and multi states after action
     Before action add multi state that should be unset via action
     """
     object_to_be_changed, check_objects_multi_state_changed = cluster_and_multi_states_checker
     run_cluster_action_and_assert_result(object_to_be_changed,
                                          ACTION_SET_MULTISTATE_NAME)
     with check_objects_multi_state_changed(
             sdk_client_fs,
         {object_to_be_changed
          }), allure.step(f'Run cluster action: {ACTION_NAME}'):
         run_cluster_action_and_assert_result(
             object_to_be_changed,
             action=ACTION_NAME,
             status="success"
             if "fail" not in object_to_be_changed.name else "failed",
         )
Beispiel #29
0
def test_component_action_availability_at_state(
        cluster_with_components: Cluster):
    """
    Test that component action is available on specific component state
    """
    service = cluster_with_components.service_add(name=FIRST_SERVICE)
    component_1 = service.component(name=FIRST_COMPONENT)
    component_2 = service.component(name=SECOND_COMPONENT)

    _assert_actions_state_created(component_1)
    run_cluster_action_and_assert_result(cluster_with_components,
                                         SWITCH_CLUSTER_STATE)
    _assert_actions_state_created(component_1)
    run_service_action_and_assert_result(service, SWITCH_SERVICE_STATE)
    _assert_actions_state_created(component_1)
    run_component_action_and_assert_result(component_1, SWITCH_COMPONENT_STATE)
    _assert_actions_state_installed(component_1)
    _assert_actions_state_created(component_2)
    run_component_action_and_assert_result(component_1, ACTION_STATE_INSTALLED)
Beispiel #30
0
    def test_six_tasks_in_header_popup(self, cluster: Cluster, app_fs):
        """Check list of tasks in header popup"""
        cluster_page = ClusterListPage(app_fs.driver, app_fs.adcm.url).open()
        with allure.step('Run actions in cluster'):
            for _ in range(6):
                run_cluster_action_and_assert_result(
                    cluster,
                    cluster.action(
                        display_name=SUCCESS_ACTION_DISPLAY_NAME).name,
                    status='success')
        cluster_page.header.click_job_block_in_header()
        with allure.step("Check that in popup 5 tasks"):
            assert len(cluster_page.header.get_job_rows_from_popup()
                       ) == 5, "Popup should contain 5 tasks"
        cluster_page.header.click_all_link_in_job_popup()

        job_page = JobListPage(app_fs.driver, app_fs.adcm.url)
        job_page.wait_page_is_opened()
        with allure.step("Check that in job list page 6 tasks"):
            assert job_page.table.row_count == 6, "Job list page should contain 6 tasks"