Example #1
0
def v4_new_regressions():
    form = TriagePageSelectedForm(request.form)
    session = request.session
    ts = request.get_testsuite()
    if request.method == 'POST' and \
            request.form['btn'] == "Create New Regression":
        regression, _ = new_regression(session, ts, form.field_changes.data)
        flash("Created " + regression.title, FLASH_SUCCESS)
        return redirect(
            v4_url_for(".v4_regression_list", highlight=regression.id))
    if request.method == 'POST' and request.form['btn'] == "Ignore Changes":
        msg = "Ignoring changes: "
        ignored = []
        for fc_id in form.field_changes.data:
            ignored.append(str(fc_id))
            fc = get_fieldchange(session, ts, fc_id)
            ignored_change = ts.ChangeIgnore(fc)
            session.add(ignored_change)
        session.commit()
        flash(msg + ", ".join(ignored), FLASH_SUCCESS)


#    d = datetime.datetime.now()
#    two_weeks_ago = d - datetime.timedelta(days=14)
    recent_fieldchange = session.query(ts.FieldChange) \
        .join(ts.Test) \
        .outerjoin(ts.ChangeIgnore) \
        .filter(ts.ChangeIgnore.id.is_(None)) \
        .outerjoin(ts.RegressionIndicator) \
        .filter(ts.RegressionIndicator.id.is_(None)) \
        .order_by(desc(ts.FieldChange.id)) \
        .limit(500) \
        .all()
    crs = []

    form.field_changes.choices = list()
    for fc in recent_fieldchange:
        if fc.old_value is None:
            cr, key_run, _ = get_cr_for_field_change(session, ts, fc)
        else:
            cr = PrecomputedCR(fc.old_value, fc.new_value,
                               fc.field.bigger_is_better)
            key_run = get_first_runs_of_fieldchange(session, ts, fc)
        current_cr, _, _ = get_cr_for_field_change(session,
                                                   ts,
                                                   fc,
                                                   current=True)
        crs.append(ChangeData(fc, cr, key_run, current_cr))
        form.field_changes.choices.append((
            fc.id,
            1,
        ))
    return render_template("v4_new_regressions.html",
                           testsuite_name=g.testsuite_name,
                           changes=crs,
                           analysis=lnt.server.reporting.analysis,
                           form=form,
                           **ts_data(ts))
Example #2
0
def v4_new_regressions():
    form = TriagePageSelectedForm(request.form)
    session = request.session
    ts = request.get_testsuite()
    if request.method == 'POST' and \
            request.form['btn'] == "Create New Regression":
        regression, _ = new_regression(session, ts, form.field_changes.data)
        flash("Created " + regression.title, FLASH_SUCCESS)
        return redirect(v4_url_for(".v4_regression_list",
                        highlight=regression.id))
    if request.method == 'POST' and request.form['btn'] == "Ignore Changes":
        msg = "Ignoring changes: "
        ignored = []
        for fc_id in form.field_changes.data:
            ignored.append(str(fc_id))
            fc = get_fieldchange(session, ts, fc_id)
            ignored_change = ts.ChangeIgnore(fc)
            session.add(ignored_change)
        session.commit()
        flash(msg + ", ".join(ignored), FLASH_SUCCESS)

#    d = datetime.datetime.now()
#    two_weeks_ago = d - datetime.timedelta(days=14)
    recent_fieldchange = session.query(ts.FieldChange) \
        .join(ts.Test) \
        .outerjoin(ts.ChangeIgnore) \
        .filter(ts.ChangeIgnore.id.is_(None)) \
        .outerjoin(ts.RegressionIndicator) \
        .filter(ts.RegressionIndicator.id.is_(None)) \
        .order_by(desc(ts.FieldChange.id)) \
        .limit(500) \
        .all()
    crs = []

    form.field_changes.choices = list()
    for fc in recent_fieldchange:
        if fc.old_value is None:
            cr, key_run, _ = get_cr_for_field_change(session, ts, fc)
        else:
            cr = PrecomputedCR(fc.old_value, fc.new_value,
                               fc.field.bigger_is_better)
            key_run = get_first_runs_of_fieldchange(session, ts, fc)
        current_cr, _, _ = get_cr_for_field_change(session, ts, fc,
                                                   current=True)
        crs.append(ChangeData(fc, cr, key_run, current_cr))
        form.field_changes.choices.append((fc.id, 1,))
    return render_template("v4_new_regressions.html",
                           testsuite_name=g.testsuite_name,
                           changes=crs, analysis=lnt.server.reporting.analysis,
                           form=form, **ts_data(ts))
Example #3
0
def v4_profile(testid, run1_id, run2_id=None):
    session = request.session
    ts = request.get_testsuite()
    profileDir = current_app.old_config.profileDir

    try:
        test = session.query(ts.Test).filter(ts.Test.id == testid).one()
        run1 = session.query(ts.Run).filter(ts.Run.id == run1_id).one()
        sample1 = _get_sample(session, ts, run1_id, testid)
        if run2_id is not None:
            run2 = session.query(ts.Run).filter(ts.Run.id == run2_id).one()
            sample2 = _get_sample(session, ts, run2_id, testid)
        else:
            run2 = None
            sample2 = None
    except NoResultFound:
        # FIXME: Make this a nicer error page.
        abort(404)

    if sample1.profile:
        profile1 = sample1.profile
    else:
        profile1 = None

    if sample2 and sample2.profile:
        profile2 = sample2.profile
    else:
        profile2 = None

    json_run1 = {
        'id': run1.id,
        'order': run1.order.llvm_project_revision,
        'machine': run1.machine.name,
        'sample': sample1.id if sample1 else None
    }
    if run2:
        json_run2 = {
            'id': run2.id,
            'order': run2.order.llvm_project_revision,
            'machine': run2.machine.name,
            'sample': sample2.id if sample2 else None
        }
    else:
        json_run2 = {}
    urls = {
        'search': v4_url_for('.v4_search'),
        'singlerun_template':
            v4_url_for('.v4_profile_fwd', testid=1111, run1_id=2222)
            .replace('1111', '<testid>').replace('2222', '<run1id>'),
        'comparison_template':
            v4_url_for('.v4_profile_fwd2', testid=1111, run1_id=2222,
                       run2_id=3333)
            .replace('1111', '<testid>').replace('2222', '<run1id>')
            .replace('3333', '<run2id>'),
        'getTopLevelCounters':
            v4_url_for('.v4_profile_ajax_getTopLevelCounters'),
        'getFunctions': v4_url_for('.v4_profile_ajax_getFunctions'),
        'getCodeForFunction':
            v4_url_for('.v4_profile_ajax_getCodeForFunction'),
    }
    return render_template("v4_profile.html",
                           test=test, run1=json_run1, run2=json_run2,
                           urls=urls, **ts_data(ts))
Example #4
0
def v4_regression_detail(id):
    session = request.session
    ts = request.get_testsuite()
    form = EditRegressionForm(request.form)

    try:
        regression_info = session.query(ts.Regression) \
            .filter(ts.Regression.id == id) \
            .one()
    except NoResultFound as e:
        abort(404)
    if request.method == 'POST' and request.form['save_btn'] == "Save Changes":
        regression_info.title = form.title.data
        regression_info.bug = form.bug.data
        regression_info.state = form.state.data
        session.commit()
        flash("Updated " + regression_info.title, FLASH_SUCCESS)
        return redirect(v4_url_for(".v4_regression_list",
                        highlight=regression_info.id,
                        state=int(form.edit_state.data)))
    if request.method == 'POST' and \
            request.form['save_btn'] == "Split Regression":
        # For each of the regression indicators, grab their field ids.
        res_inds = session.query(ts.RegressionIndicator) \
            .filter(ts.RegressionIndicator.field_change_id.in_(
                form.field_changes.data)) \
            .all()
        fc_ids = [x.field_change_id for x in res_inds]
        second_regression, _ = new_regression(session, ts, fc_ids)
        second_regression.state = regression_info.state

        # Now remove our links to this regression.
        for res_ind in res_inds:
            session.delete(res_ind)
        lnt.server.db.fieldchange.rebuild_title(session, ts, regression_info)
        session.commit()
        flash("Split " + second_regression.title, FLASH_SUCCESS)
        return redirect(v4_url_for(".v4_regression_list",
                        highlight=second_regression.id,
                        state=int(form.edit_state.data)))
    if request.method == 'POST' and request.form['save_btn'] == "Delete":
        # For each of the regression indicators, grab their field ids.
        title = regression_info.title
        res_inds = session.query(ts.RegressionIndicator) \
            .filter(
                ts.RegressionIndicator.regression_id == regression_info.id) \
            .all()
        # Now remove our links to this regression.
        for res_ind in res_inds:
            session.delete(res_ind)
        session.delete(regression_info)
        session.commit()
        flash("Deleted " + title, FLASH_SUCCESS)
        return redirect(v4_url_for(".v4_regression_list",
                        state=int(form.edit_state.data)))
    form.field_changes.choices = list()
    form.state.default = regression_info.state
    form.process()
    form.edit_state.data = regression_info.state
    form.title.data = regression_info.title
    form.bug.data = regression_info.bug
    regression_indicators = session.query(ts.RegressionIndicator) \
        .filter(ts.RegressionIndicator.regression_id == id) \
        .all()

    crs = []

    test_suite_versions = set()
    form.field_changes.choices = list()
    # If we have more than 10 regressions, don't graph any by default.
    checkbox_state = 1
    if len(regression_indicators) >= 10:
        checkbox_state = 0

    for regression in regression_indicators:
        fc = regression.field_change
        if fc is None:
            continue
        if fc.old_value is None:
            cr, key_run, all_runs = get_cr_for_field_change(session, ts, fc)
        else:
            cr = PrecomputedCR(fc.old_value, fc.new_value,
                               fc.field.bigger_is_better)
            key_run = get_first_runs_of_fieldchange(session, ts, fc)
        current_cr, _, all_runs = get_cr_for_field_change(session, ts, fc,
                                                          current=True)
        crs.append(ChangeData(fc, cr, key_run, current_cr))
        form.field_changes.choices.append((fc.id, checkbox_state,))
        for run in all_runs:
            ts_rev = key_run.parameters.get('test_suite_revision')
            if ts_rev and ts_rev != u'None':
                test_suite_versions.add(ts_rev)

    if len(test_suite_versions) > 1:
        revs = ', '.join(list(test_suite_versions))
        flash("More than one test-suite version: " + revs,
              FLASH_DANGER)

    if request.args.get('json'):
        return json.dumps({u'Regression': regression_info,
                           u'Changes': crs},
                          cls=LNTEncoder)

    return render_template("v4_regression_detail.html",
                           testsuite_name=g.testsuite_name,
                           regression=regression_info, changes=crs,
                           form=form, analysis=lnt.server.reporting.analysis,
                           check_all=checkbox_state,
                           **ts_data(ts))
Example #5
0
def v4_regression_list():
    session = request.session
    ts = request.get_testsuite()
    form = MergeRegressionForm(request.form)
    machine_filter = request.args.get('machine_filter')
    state_filter = int(request.args.get('state', RegressionState.ACTIVE))
    # Merge requested regressions.
    if request.method == 'POST' and \
       request.form['merge_btn'] == "Merge Regressions":
        reg_inds, regressions = _get_regressions_from_selected_form(session,
                                                                    form, ts)
        links = []
        target = 0
        for i, r in enumerate(regressions):
            if r.bug:
                target = i
                links.append(r.bug)

        new_regress, _ = new_regression(session, ts,
                                     [x.field_change_id for x in reg_inds])
        new_regress.state = regressions[target].state
        new_regress.title = regressions[target].title
        new_regress.bug = ' '.join(links)
        for r in regressions:
            r.bug = v4_url_for(".v4_regression_detail", id=new_regress.id)
            r.title = "Merged into Regression " + str(new_regress.id)
            r.state = RegressionState.IGNORED
        [session.delete(x) for x in reg_inds]

        session.commit()
        flash("Created: " + new_regress.title, FLASH_SUCCESS)
        return redirect(v4_url_for(".v4_regression_detail", id=new_regress.id))
    # Delete requested regressions.
    if request.method == 'POST' and \
            request.form['merge_btn'] == "Delete Regressions":
        reg_inds, regressions = _get_regressions_from_selected_form(session,
                                                                    form, ts)
        titles = [r.title for r in regressions]
        for res_ind in reg_inds:
            session.delete(res_ind)
        for reg in regressions:
            session.delete(reg)
        session.commit()
        flash(' Deleted: '.join(titles), FLASH_SUCCESS)
        return redirect(v4_url_for(".v4_regression_list", state=state_filter))

    q = session.query(ts.Regression)
    title = "All Regressions"
    if state_filter != -1:
        q = q.filter(ts.Regression.state == state_filter)
        title = RegressionState.names[state_filter]
    regression_info = q.all()[::-1]

    form.regression_checkboxes.choices = list()
    regression_sizes = []
    impacts = []
    ages = []

    filtered_regressions = []
    for regression in regression_info:
        reg_inds = session.query(ts.RegressionIndicator) \
            .filter(ts.RegressionIndicator.regression_id ==
                    regression.id) \
            .all()
        if machine_filter:
            machine_names = \
                set([x.field_change.machine.name for x in reg_inds])
            if machine_filter in machine_names:
                filtered_regressions.append(regression)
            else:
                continue
        else:
            filtered_regressions.append(regression)
        form.regression_checkboxes.choices.append((regression.id, 1,))

        regression_sizes.append(len(reg_inds))
        impacts.append(calc_impact(session, ts,
                                   [x.field_change for x in reg_inds]))
        # Now guess the regression age:
        if len(reg_inds) and reg_inds[0].field_change and \
                reg_inds[0].field_change.run:
            age = reg_inds[0].field_change.run.end_time
        else:
            age = EmptyDate()
        ages.append(age)

    return render_template("v4_regression_list.html",
                           testsuite_name=g.testsuite_name,
                           regressions=filtered_regressions,
                           highlight=request.args.get('highlight'),
                           title=title,
                           RegressionState=RegressionState,
                           state_filter=state_filter,
                           form=form,
                           sizes=regression_sizes,
                           impacts=impacts,
                           ages=ages,
                           analysis=lnt.server.reporting.analysis,
                           **ts_data(ts))
Example #6
0
def v4_regression_detail(id):
    session = request.session
    ts = request.get_testsuite()
    form = EditRegressionForm(request.form)

    try:
        regression_info = session.query(ts.Regression) \
            .filter(ts.Regression.id == id) \
            .one()
    except NoResultFound as e:
        abort(404)
    if request.method == 'POST' and request.form['save_btn'] == "Save Changes":
        regression_info.title = form.title.data
        regression_info.bug = form.bug.data
        regression_info.state = form.state.data
        session.commit()
        flash("Updated " + regression_info.title, FLASH_SUCCESS)
        return redirect(
            v4_url_for(".v4_regression_list",
                       highlight=regression_info.id,
                       state=int(form.edit_state.data)))
    if request.method == 'POST' and \
            request.form['save_btn'] == "Split Regression":
        # For each of the regression indicators, grab their field ids.
        res_inds = session.query(ts.RegressionIndicator) \
            .filter(ts.RegressionIndicator.field_change_id.in_(
                form.field_changes.data)) \
            .all()
        fc_ids = [x.field_change_id for x in res_inds]
        second_regression, _ = new_regression(session, ts, fc_ids)
        second_regression.state = regression_info.state

        # Now remove our links to this regression.
        for res_ind in res_inds:
            session.delete(res_ind)
        lnt.server.db.fieldchange.rebuild_title(session, ts, regression_info)
        session.commit()
        flash("Split " + second_regression.title, FLASH_SUCCESS)
        return redirect(
            v4_url_for(".v4_regression_list",
                       highlight=second_regression.id,
                       state=int(form.edit_state.data)))
    if request.method == 'POST' and request.form['save_btn'] == "Delete":
        # For each of the regression indicators, grab their field ids.
        title = regression_info.title
        res_inds = session.query(ts.RegressionIndicator) \
            .filter(
                ts.RegressionIndicator.regression_id == regression_info.id) \
            .all()
        # Now remove our links to this regression.
        for res_ind in res_inds:
            session.delete(res_ind)
        session.delete(regression_info)
        session.commit()
        flash("Deleted " + title, FLASH_SUCCESS)
        return redirect(
            v4_url_for(".v4_regression_list", state=int(form.edit_state.data)))
    form.field_changes.choices = list()
    form.state.default = regression_info.state
    form.process()
    form.edit_state.data = regression_info.state
    form.title.data = regression_info.title
    form.bug.data = regression_info.bug
    regression_indicators = session.query(ts.RegressionIndicator) \
        .filter(ts.RegressionIndicator.regression_id == id) \
        .all()

    crs = []

    test_suite_versions = set()
    form.field_changes.choices = list()
    # If we have more than 10 regressions, don't graph any by default.
    checkbox_state = 1
    if len(regression_indicators) >= 10:
        checkbox_state = 0

    for regression in regression_indicators:
        fc = regression.field_change
        if fc is None:
            continue
        if fc.old_value is None:
            cr, key_run, all_runs = get_cr_for_field_change(session, ts, fc)
        else:
            cr = PrecomputedCR(fc.old_value, fc.new_value,
                               fc.field.bigger_is_better)
            key_run = get_first_runs_of_fieldchange(session, ts, fc)
        current_cr, _, all_runs = get_cr_for_field_change(session,
                                                          ts,
                                                          fc,
                                                          current=True)
        crs.append(ChangeData(fc, cr, key_run, current_cr))
        form.field_changes.choices.append((
            fc.id,
            checkbox_state,
        ))
        for run in all_runs:
            ts_rev = key_run.parameters.get('test_suite_revision')
            if ts_rev and ts_rev != u'None':
                test_suite_versions.add(ts_rev)

    if len(test_suite_versions) > 1:
        revs = ', '.join(list(test_suite_versions))
        flash("More than one test-suite version: " + revs, FLASH_DANGER)

    if request.args.get('json'):
        return json.dumps({
            u'Regression': regression_info,
            u'Changes': crs
        },
                          cls=LNTEncoder)

    return render_template("v4_regression_detail.html",
                           testsuite_name=g.testsuite_name,
                           regression=regression_info,
                           changes=crs,
                           form=form,
                           analysis=lnt.server.reporting.analysis,
                           check_all=checkbox_state,
                           **ts_data(ts))
Example #7
0
def v4_regression_list():
    session = request.session
    ts = request.get_testsuite()
    form = MergeRegressionForm(request.form)
    machine_filter = request.args.get('machine_filter')
    state_filter = int(request.args.get('state', RegressionState.ACTIVE))
    # Merge requested regressions.
    if request.method == 'POST' and \
       request.form['merge_btn'] == "Merge Regressions":
        reg_inds, regressions = _get_regressions_from_selected_form(
            session, form, ts)
        links = []
        target = 0
        for i, r in enumerate(regressions):
            if r.bug:
                target = i
                links.append(r.bug)

        new_regress, _ = new_regression(session, ts,
                                        [x.field_change_id for x in reg_inds])
        new_regress.state = regressions[target].state
        new_regress.title = regressions[target].title
        new_regress.bug = ' '.join(links)
        for r in regressions:
            r.bug = v4_url_for(".v4_regression_detail", id=new_regress.id)
            r.title = "Merged into Regression " + str(new_regress.id)
            r.state = RegressionState.IGNORED
        [session.delete(x) for x in reg_inds]

        session.commit()
        flash("Created: " + new_regress.title, FLASH_SUCCESS)
        return redirect(v4_url_for(".v4_regression_detail", id=new_regress.id))
    # Delete requested regressions.
    if request.method == 'POST' and \
            request.form['merge_btn'] == "Delete Regressions":
        reg_inds, regressions = _get_regressions_from_selected_form(
            session, form, ts)
        titles = [r.title for r in regressions]
        for res_ind in reg_inds:
            session.delete(res_ind)
        for reg in regressions:
            session.delete(reg)
        session.commit()
        flash(' Deleted: '.join(titles), FLASH_SUCCESS)
        return redirect(v4_url_for(".v4_regression_list", state=state_filter))

    q = session.query(ts.Regression)
    title = "All Regressions"
    if state_filter != -1:
        q = q.filter(ts.Regression.state == state_filter)
        title = RegressionState.names[state_filter]
    regression_info = q.all()[::-1]

    form.regression_checkboxes.choices = list()
    regression_sizes = []
    impacts = []
    ages = []

    filtered_regressions = []
    for regression in regression_info:
        reg_inds = session.query(ts.RegressionIndicator) \
            .filter(ts.RegressionIndicator.regression_id ==
                    regression.id) \
            .all()
        if machine_filter:
            machine_names = \
                set([x.field_change.machine.name for x in reg_inds])
            if machine_filter in machine_names:
                filtered_regressions.append(regression)
            else:
                continue
        else:
            filtered_regressions.append(regression)
        form.regression_checkboxes.choices.append((
            regression.id,
            1,
        ))

        regression_sizes.append(len(reg_inds))
        impacts.append(
            calc_impact(session, ts, [x.field_change for x in reg_inds]))
        # Now guess the regression age:
        if len(reg_inds) and reg_inds[0].field_change and \
                reg_inds[0].field_change.run:
            age = reg_inds[0].field_change.run.end_time
        else:
            age = EmptyDate()
        ages.append(age)

    return render_template("v4_regression_list.html",
                           testsuite_name=g.testsuite_name,
                           regressions=filtered_regressions,
                           highlight=request.args.get('highlight'),
                           title=title,
                           RegressionState=RegressionState,
                           state_filter=state_filter,
                           form=form,
                           sizes=regression_sizes,
                           impacts=impacts,
                           ages=ages,
                           analysis=lnt.server.reporting.analysis,
                           **ts_data(ts))