Beispiel #1
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)
Beispiel #2
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)
Beispiel #3
0
def test_pass_no_config(cluster: Cluster, provider: Provider,
                        sdk_client_fs: ADCMClient):
    """
    Action has config
    Run action without 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 run action that require config with on {obj.__class__.__name__}'
        ):
            with allure.step(
                    'Run action that require config without config and expect ADCM to response with non 500 status code'
            ):
                try:
                    ACTION_MAP[obj.__class__](obj, 'with_config', 'failed')
                except ErrorMessage as e:
                    CONFIG_VALUE_ERROR.equal(e)
                else:
                    raise AssertionError("Action run should've failed")
            with allure.step("Check that job wasn't launched"):
                _check_job_count_equal_to(job_count, sdk_client_fs)
Beispiel #4
0
def _check_job_count_equal_to(count: int, adcm_client: ADCMClient):
    """Check that job count is equal to expected"""
    assert (
        job_count := len(adcm_client.job_list())
    ) == count, f'Amount of jobs expected is {count}, but {job_count} was found'