Exemplo n.º 1
0
 def _run_actions_on_components(self, cluster: Cluster, service: Service, components: dict, hosts: tuple):
     """Utility function to run actions on components (host actions too)"""
     cluster.action(name='make_sauce').run(
         hc=tuple(
             (
                 {'host_id': host_id, 'service_id': service.id, 'component_id': component_id}
                 for host_id, component_id in (
                     (hosts[1].id, components[self.SPICE_COMPONENT].id),
                     (hosts[1].id, components[self.LEMON_COMPONENT].id),
                     (hosts[2].id, components[self.TOMATO_COMPONENT].id),
                 )
             )
         )
     ).wait()
     cluster.hostcomponent_set(
         (hosts[0], components[self.MILK_COMPONENT]),
         *[
             (cluster.host(id=hc['host_id']), service.component(id=hc['component_id']))
             for hc in cluster.hostcomponent()
         ],
     )
     _wait_for_tasks(
         (
             components[self.TOMATO_COMPONENT].action(name='add_more').run(),
             components[self.SPICE_COMPONENT].action(name='add_more').run(),
         )
     )
Exemplo n.º 2
0
 def test_run_cluster_action(self, cluster: Cluster):
     """Test run cluster action"""
     cluster.config_set({"required": 10})
     cluster.service_add(name="ZOOKEEPER")
     result = cluster.action().run()
     with allure.step("Check if status is running"):
         assert result.status == "running"
Exemplo n.º 3
0
 def test_cluster_action_runs_task(self, cluster: Cluster):
     """Test run cluster action"""
     cluster.config_set({"required": 10})
     cluster.service_add(name="ZOOKEEPER")
     task = cluster.action(name="check-file-type").run()
     with allure.step("Check if status is running"):
         assert task.status == "running"
Exemplo n.º 4
0
def test_cluster_should_be_unlocked_when_ansible_task_killed(cluster: Cluster):
    """Test that cluster is unlocked if ansible task is killed"""
    with allure.step("Run cluster action: lock-terminate for cluster"):
        task = cluster.action(name="lock-terminate").run()
    is_locked(cluster)
    task.wait()
    assert_state(cluster, "terminate_failed")
Exemplo n.º 5
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()
Exemplo n.º 6
0
def test_service_should_be_unlocked_when_ansible_task_killed(complete_cluster: Cluster):
    """Test that service is unlocked if ansible task is killed"""
    service = complete_cluster.service(name="first_service")
    with allure.step("Run action: lock-terminate for cluster"):
        task = complete_cluster.action(name="lock-terminate").run()
    is_locked(service)
    task.wait()
    is_free(service)
Exemplo n.º 7
0
def test_host_should_be_unlocked_when_ansible_task_killed(complete_cluster: Cluster, host: Host):
    """Test that host is unlocked if ansible task is killed"""
    with allure.step("Run action: lock-terminate for cluster"):
        task = complete_cluster.action(name="lock-terminate").run()

    is_locked(host)
    task.wait()
    is_free(host)
Exemplo n.º 8
0
 def test_open_task_by_click_on_name(self, cluster: Cluster,
                                     page: JobListPage):
     """Click on task name and task page should be opened"""
     with allure.step('Run "Long" action'), page.table.wait_rows_change():
         task = cluster.action(display_name=LONG_ACTION_DISPLAY_NAME).run()
     with allure.step('Click on task name'):
         page.click_on_action_name_in_row(page.table.get_row())
     with allure.step('Check Task detailed page is opened'):
         job_page = JobPageStdout(page.driver, page.base_url, task.id)
         job_page.wait_page_is_opened()
         job_page.check_jobs_toolbar(LONG_ACTION_DISPLAY_NAME.upper())
Exemplo n.º 9
0
    def test_job_has_correct_info_in_header_popup(self, job_info: dict,
                                                  cluster: Cluster, app_fs):
        """Run action that finishes (success/failed) and check it in header popup"""

        cluster_page = ClusterListPage(app_fs.driver, app_fs.adcm.url).open()
        cluster_page.wait_config_loaded()

        for action_name, expected_status in job_info['action_name'].items():
            if action_name == LONG_ACTION_DISPLAY_NAME:
                cluster.action(display_name=action_name).run()
            else:
                run_cluster_action_and_assert_result(
                    cluster,
                    cluster.action(display_name=action_name).name,
                    status=expected_status)
        cluster_page.header.click_job_block_in_header()
        assert (cluster_page.header.get_success_job_amount_from_header() ==
                job_info['success_jobs']
                ), f"Success job amount should be {job_info['success_jobs']}"
        assert (
            cluster_page.header.get_in_progress_job_amount_from_header() ==
            job_info['in_progress_job_jobs']
        ), f"In progress job amount should be {job_info['in_progress_job_jobs']}"
        assert (cluster_page.header.get_failed_job_amount_from_header() ==
                job_info['failed_jobs']
                ), f"Failed job amount should be {job_info['failed_jobs']}"

        def _wait_for_background():
            assert job_info['background'] in (
                circle_color := cluster_page.header.get_jobs_circle_color()
            ), f"Bell circle should be colored, but actual color was: {circle_color}"

        with allure.step('Check that "bell" color is correct'):
            wait_until_step_succeeds(_wait_for_background,
                                     period=0.3,
                                     timeout=10)
Exemplo n.º 10
0
 def test_download_log(self, cluster: Cluster, app_fs: ADCMTest,
                       downloads_directory):
     """Download log file from detailed page menu"""
     downloaded_file_template = '{job_id}-ansible-{log_type}.txt'
     action = cluster.action(display_name=SUCCESS_ACTION_DISPLAY_NAME)
     task = run_cluster_action_and_assert_result(cluster, action.name)
     job_id = task.jobs[0]['id']
     job_page = _open_detailed_job_page(job_id, app_fs)
     with allure.step('Download logfiles'):
         job_page.click_on_log_download('stdout')
         wait_file_is_presented(downloaded_file_template.format(
             job_id=job_id, log_type='stdout'),
                                app_fs,
                                dirname=downloads_directory)
         job_page.click_on_log_download('stderr')
         wait_file_is_presented(downloaded_file_template.format(
             job_id=job_id, log_type='stderr'),
                                app_fs,
                                dirname=downloads_directory)
Exemplo n.º 11
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"
Exemplo n.º 12
0
 def test_on_tasks_in_header_popup(self, cluster: Cluster,
                                   page: JobListPage, app_fs):
     """Run action and click on it in header popup"""
     actions = {
         SUCCESS_ACTION_DISPLAY_NAME: 'success',
         FAIL_ACTION_DISPLAY_NAME: 'failed'
     }
     with allure.step('Run actions in cluster'):
         for action_name, status in actions.items():
             action = cluster.action(display_name=action_name)
             run_cluster_action_and_assert_result(cluster,
                                                  action.name,
                                                  status=status)
     page.header.click_job_block_in_header()
     for action_name, _ in actions.items():
         page.header.click_on_task_row_by_name(task_name=action_name)
         job_page = JobPageStdout(app_fs.driver, app_fs.adcm.url, job_id=1)
         job_page.check_title(action_name)
         job_page.check_text(
             success_task=action_name == SUCCESS_ACTION_DISPLAY_NAME)
Exemplo n.º 13
0
 def test_acknowledge_jobs_in_header_popup(self, cluster: Cluster,
                                           page: JobListPage):
     """Run action and click acknowledge in header popup"""
     with allure.step('Run action in cluster'):
         action = cluster.action(display_name=SUCCESS_ACTION_DISPLAY_NAME)
         run_cluster_action_and_assert_result(cluster,
                                              action.name,
                                              status='success')
     page.header.click_job_block_in_header()
     page.header.click_acknowledge_btn_in_job_popup()
     page.header.check_no_jobs_presented()
     assert page.header.get_success_job_amount_from_header(
     ) == "0", "Success job amount should be 0"
     assert page.header.get_in_progress_job_amount_from_header(
     ) == "0", "In progress job amount should be 0"
     assert page.header.get_failed_job_amount_from_header(
     ) == "0", "Failed job amount should be 0"
     assert 'background: transparent' in page.header.get_jobs_circle_color(
     ), "Bell circle should be without color"
     page.header.check_acknowledge_btn_not_displayed()
Exemplo n.º 14
0
 def test_open_log_menu(self, log_type: str, cluster: Cluster,
                        app_fs: ADCMTest):
     """Open stdout/stderr log menu and check info"""
     action = cluster.action(display_name=SUCCESS_ACTION_DISPLAY_NAME)
     task = run_cluster_action_and_assert_result(cluster, action.name)
     job_page = _open_detailed_job_page(task.jobs[0]['id'], app_fs)
     with allure.step(
             f'Open menu with {log_type} logs and check all info is presented'
     ):
         getattr(job_page, f'open_{log_type}_menu')()
         wait_and_assert_ui_info(
             {
                 'name': SUCCESS_ACTION_DISPLAY_NAME,
                 'invoker_objects': cluster.name,
                 'start_date': is_not_empty,
                 'finish_date': is_not_empty,
                 'execution_time': is_not_empty,
             },
             job_page.get_job_info,
         )
         job_page.check_jobs_toolbar(SUCCESS_ACTION_DISPLAY_NAME.upper())
Exemplo n.º 15
0
 def test_finished_job_has_correct_info(self, job_info: dict,
                                        cluster: Cluster,
                                        page: JobListPage):
     """Run action that finishes (success/failed) and check it is displayed correctly"""
     expected_info_in_popup = {**job_info}
     expected_status = expected_info_in_popup.get('status').value
     expected_info_in_table = {
         **expected_info_in_popup, 'invoker_objects': cluster.name
     }
     with allure.step(
             f'Run action and wait for "{expected_status}" status'):
         action = cluster.action(
             display_name=expected_info_in_popup['action_name'])
         run_cluster_action_and_assert_result(cluster,
                                              action.name,
                                              status=expected_status)
     _check_finished_job_info_in_table(page, expected_info_in_table)
     open_filter_on_page = getattr(page,
                                   f'select_filter_{expected_status}_tab')
     open_filter_on_page()
     _check_finished_job_info_in_table(page, expected_info_in_table)
     _check_job_info_in_popup(page, expected_info_in_popup)