def test_error_unchanged(self): pipeline_status.get_failure_stage_signature = MagicMock(side_effect=[{2000: {}}, {1999: {}}]) pipeline_status.get_log_parser = MagicMock(return_value=TexttestConsoleParser) this_stage = self.create_stage_failure_info(None, False, "TEST", stage_id=2000) previous_stage = self.create_stage_failure_info(this_stage, False, "TEST", stage_id=1999) current = pipeline_status.create_stage_info(this_stage) previous = pipeline_status.create_stage_info(previous_stage) result = failure_tip.get_failure_tip(current, previous, 0) self.assertEqual(result, ("Same failure indices as last test. Unlikely flickering.", "Last claim: resp: desc"))
def test_error_introduced(self): pipeline_status.get_failure_stage_signature = MagicMock(return_value={2000: {}}) pipeline_status.get_log_parser = MagicMock(return_value=TexttestConsoleParser) failed_stage = self.create_stage_failure_info(None, False, "TEST") passed_stage = self.create_stage_failure_info(failed_stage, True) current = pipeline_status.create_stage_info(failed_stage) previous = pipeline_status.create_stage_info(passed_stage) result = failure_tip.get_failure_tip(current, previous, 0) self.assertEqual(result, ("Last pipeline was a success. Potential for flickering but may need further investigation.", "Last claim: resp: desc") )
def test_error_introduced(self): pipeline_status.get_failure_stage_signature = MagicMock( return_value={2000: {}}) pipeline_status.get_log_parser = MagicMock( return_value=TexttestConsoleParser) failed_stage = self.create_stage_failure_info(None, False, "TEST") passed_stage = self.create_stage_failure_info(failed_stage, True) current = pipeline_status.create_stage_info(failed_stage) previous = pipeline_status.create_stage_info(passed_stage) result = failure_tip.get_failure_tip(current, previous, 0) self.assertEqual(result, ( "Last pipeline was a success. Potential for flickering but may need further investigation.", "Last claim: resp: desc"))
def test_current_passing(self): pipeline_status.get_log_parser = MagicMock(return_value="characterize") passed_stage = self.create_stage_failure_info(None, True) current = pipeline_status.create_stage_info(passed_stage) result = failure_tip.get_failure_tip(current, None, 0) self.assertEqual(result, ("All good.", ""))
def test_current_passing(self): pipeline_status.get_log_parser = MagicMock(return_value="characterize") passed_stage = self.create_stage_failure_info(None, True) current = pipeline_status.create_stage_info(passed_stage) result = failure_tip.get_failure_tip(current, None, 0) self.assertEqual(result, ("All good.", ''))
def test_error_unchanged(self): pipeline_status.get_failure_stage_signature = MagicMock(side_effect=[{ 2000: {} }, { 1999: {} }]) pipeline_status.get_log_parser = MagicMock( return_value=TexttestConsoleParser) this_stage = self.create_stage_failure_info(None, False, "TEST", stage_id=2000) previous_stage = self.create_stage_failure_info(this_stage, False, "TEST", stage_id=1999) current = pipeline_status.create_stage_info(this_stage) previous = pipeline_status.create_stage_info(previous_stage) result = failure_tip.get_failure_tip(current, previous, 0) self.assertEqual( result, ("Same failure indices as last test. Unlikely flickering.", "Last claim: resp: desc"))
def insights(pipeline_name): current_stage = get_current_stage(pipeline_name) if current_stage is None: abort( 500, "Database error. Have you tried syncing some pipelines " "using gocddash_sync.py? Current_stage is None.") current_status = pipeline_status.create_stage_info(current_stage) last_stage = get_previous_stage(current_stage) previous_status = pipeline_status.create_stage_info(last_stage) latest_passing_stage = get_latest_passing_stage(pipeline_name) stage_name_index = (get_connection().get_stage_order(pipeline_name)).index( current_stage.stage_name) git_history = [] perpetrator_data = [] if not current_stage.is_success(): if latest_passing_stage is None: latest_passing_stage = get_first_synced_stage(pipeline_name) if not current_stage.pipeline_counter - latest_passing_stage.pipeline_counter == 1: perpetrator_data = get_git_comparison( pipeline_name, latest_passing_stage.pipeline_counter + 1, latest_passing_stage.pipeline_counter, app.config['PREFERRED_UPSTREAM']) git_history = get_git_comparison(pipeline_name, current_stage.pipeline_counter, latest_passing_stage.pipeline_counter, app.config['PREFERRED_UPSTREAM']) base_url = app.config['PUBLIC_GO_SERVER_URL'] rerun_link = base_url + "pipelines/{}/{}/{}/{}".format( current_stage.pipeline_name, current_stage.pipeline_counter, current_stage.stage_name, current_stage.stage_counter) job_to_display = get_job_to_display(current_stage.stage_id) if job_to_display: log_link = base_url + "tab/build/detail/{}/{}/{}/{}/{}#tab-tests".format( current_stage.pipeline_name, current_stage.pipeline_counter, current_stage.stage_name, current_stage.stage_counter, job_to_display.job_name) else: log_link = 'FIX_THIS' main_pipeline_link = base_url + "tab/pipeline/history/{}".format( current_stage.pipeline_name) comparison_link = base_url + "compare/{}/{}/with/{}".format( current_stage.pipeline_name, current_stage.pipeline_counter, latest_passing_stage.pipeline_counter) dash_status = get_cctray_status() recommendation, last_claim = failure_tip.get_failure_tip( current_status, previous_status, latest_passing_stage.pipeline_counter) template = render_template( 'insights.html', go_server_url=app.config['PUBLIC_GO_SERVER_URL'], now=datetime.now(), theme=get_bootstrap_theme(), footer=get_footer(), current_status=current_status, git_history=git_history, rerun_link=rerun_link, comparison_link=comparison_link, live_info=dash_status.pipelines[pipeline_name], latest_passing_stage=latest_passing_stage, previous_status=previous_status, recommendation=recommendation, last_claim=last_claim, log_link=log_link, main_pipeline_link=main_pipeline_link, stage_name_index=stage_name_index, application_root=app.config['APPLICATION_ROOT'], username=app.config['GO_SERVER_USER'], passwd=app.config['GO_SERVER_PASSWD'], rerun_token=app.config['RERUN_TOKEN'], perpretrator_data=perpetrator_data) return make_response(template)
def test_current_post(self): post_stage = self.create_stage_failure_info(None, False, "POST") current = pipeline_status.create_stage_info(post_stage) result = failure_tip.get_failure_tip(current, None, 0) self.assertEqual(result, ("All tests passed, but the build failed.", ""))
def test_current_startup(self): startup_stage = self.create_stage_failure_info(None, False, "STARTUP") current = pipeline_status.create_stage_info(startup_stage) result = failure_tip.get_failure_tip(current, None, 0) self.assertEqual(result, ("Tests failed during STARTUP.", ""))
def insights(pipeline_name): current_stage = get_current_stage(pipeline_name) if current_stage is None: abort(500, "Database error. Have you tried syncing some pipelines " "using gocddash_sync.py? Current_stage is None.") current_status = pipeline_status.create_stage_info(current_stage) last_stage = get_previous_stage(current_stage) previous_status = pipeline_status.create_stage_info(last_stage) latest_passing_stage = get_latest_passing_stage(pipeline_name) stage_name_index = (get_connection().get_stage_order(pipeline_name)).index(current_stage.stage_name) git_history = [] perpetrator_data = [] if not current_stage.is_success(): if latest_passing_stage is None: latest_passing_stage = get_first_synced_stage(pipeline_name) if not current_stage.pipeline_counter - latest_passing_stage.pipeline_counter == 1: perpetrator_data = get_git_comparison(pipeline_name, latest_passing_stage.pipeline_counter + 1, latest_passing_stage.pipeline_counter, app.config['PREFERRED_UPSTREAM']) git_history = get_git_comparison(pipeline_name, current_stage.pipeline_counter, latest_passing_stage.pipeline_counter, app.config['PREFERRED_UPSTREAM']) base_url = app.config['PUBLIC_GO_SERVER_URL'] rerun_link = base_url + "pipelines/{}/{}/{}/{}".format(current_stage.pipeline_name, current_stage.pipeline_counter, current_stage.stage_name, current_stage.stage_counter) job_to_display = get_job_to_display(current_stage.stage_id) if job_to_display: log_link = base_url + "tab/build/detail/{}/{}/{}/{}/{}#tab-tests".format( current_stage.pipeline_name, current_stage.pipeline_counter, current_stage.stage_name, current_stage.stage_counter, job_to_display.job_name) else: log_link = 'FIX_THIS' main_pipeline_link = base_url + "tab/pipeline/history/{}".format(current_stage.pipeline_name) comparison_link = base_url + "compare/{}/{}/with/{}".format(current_stage.pipeline_name, current_stage.pipeline_counter, latest_passing_stage.pipeline_counter) dash_status = get_cctray_status() recommendation, last_claim = failure_tip.get_failure_tip(current_status, previous_status, latest_passing_stage.pipeline_counter) template = render_template( 'insights.html', go_server_url=app.config['PUBLIC_GO_SERVER_URL'], now=datetime.now(), theme=get_bootstrap_theme(), footer=get_footer(), current_status=current_status, git_history=git_history, rerun_link=rerun_link, comparison_link=comparison_link, live_info=dash_status.pipelines[pipeline_name], latest_passing_stage=latest_passing_stage, previous_status=previous_status, recommendation=recommendation, last_claim=last_claim, log_link=log_link, main_pipeline_link=main_pipeline_link, stage_name_index=stage_name_index, application_root=app.config['APPLICATION_ROOT'], username=app.config['GO_SERVER_USER'], passwd=app.config['GO_SERVER_PASSWD'], rerun_token=app.config['RERUN_TOKEN'], perpretrator_data=perpetrator_data ) return make_response(template)
def test_current_post(self): post_stage = self.create_stage_failure_info(None, False, "POST") current = pipeline_status.create_stage_info(post_stage) result = failure_tip.get_failure_tip(current, None, 0) self.assertEqual(result, ("All tests passed, but the build failed.", ''))
def test_current_startup(self): startup_stage = self.create_stage_failure_info(None, False, "STARTUP") current = pipeline_status.create_stage_info(startup_stage) result = failure_tip.get_failure_tip(current, None, 0) self.assertEqual(result, ("Tests failed during STARTUP.", ''))