示例#1
0
    def handle_merge(self):
        # let's check if we are facing a merge, and in that case,
        # continue the bisection from the merged branch.
        result = None

        self._logger.debug("Starting merge handling...")
        # we have to check the commit of the most recent push
        most_recent_push = self.build_range[1]
        jp = JsonPushes(most_recent_push.repo_name)
        push = jp.pushlog_for_change(most_recent_push.changeset, full='1')
        msg = push['changesets'][-1]['desc']
        self._logger.debug("Found commit message:\n%s\n" % msg)
        branch = find_branch_in_merge_commit(msg)
        if not (branch and len(push['changesets']) >= 2):
            return
        try:
            # so, this is a merge. We can find the oldest and youngest
            # changesets, and the branch where the merge comes from.
            oldest = push['changesets'][0]['node']
            # exclude the merge commit
            youngest = push['changesets'][-2]['node']
            self._logger.debug("This is a merge from %s" % branch)

            # we can't use directly the youngest changeset because we
            # don't know yet if it is good.
            #
            # PUSH1    PUSH2
            # [1 2] [3 4 5 6 7]
            #    G    MERGE  B
            #
            # so first, grab it. This needs to be done on the right branch.
            jp2 = JsonPushes(branch)
            raw = [int(i) for i in
                   jp2.pushlog_within_changes(oldest, youngest, raw=True)]
            data = jp2._request(jp2.json_pushes_url(
                startID=str(min(raw) - 2),
                endID=str(max(raw)),
            ))
            datakeys = [int(i) for i in data]
            oldest = data[str(min(datakeys))]["changesets"][0]
            youngest = data[str(max(datakeys))]["changesets"][-1]

            # we are ready to bisect further
            self._logger.info("************* Switching to %s" % branch)
            gr, br = self._reverse_if_find_fix(oldest, youngest)
            result = (branch, gr, br)
        except MozRegressionError:
            self._logger.debug("Got exception", exc_info=True)
            raise MozRegressionError(
                "Unable to exploit the merge commit. Origin branch is {}, and"
                " the commit message for {} was:\n{}".format(
                    most_recent_push.repo_name,
                    most_recent_push.short_changeset,
                    msg
                )
            )
        self._logger.debug('End merge handling')
        return result
示例#2
0
    def handle_merge(self):
        # let's check if we are facing a merge, and in that case,
        # continue the bisection from the merged branch.
        result = None

        LOG.debug("Starting merge handling...")
        # we have to check the commit of the most recent push
        most_recent_push = self.build_range[1]
        jp = JsonPushes(most_recent_push.repo_name)
        push = jp.pushlog_for_change(most_recent_push.changeset, full='1')
        msg = push['changesets'][-1]['desc']
        LOG.debug("Found commit message:\n%s\n" % msg)
        branch = find_branch_in_merge_commit(msg)
        if not (branch and len(push['changesets']) >= 2):
            return
        try:
            # so, this is a merge. We can find the oldest and youngest
            # changesets, and the branch where the merge comes from.
            oldest = push['changesets'][0]['node']
            # exclude the merge commit
            youngest = push['changesets'][-2]['node']
            LOG.debug("This is a merge from %s" % branch)

            # we can't use directly the youngest changeset because we
            # don't know yet if it is good.
            #
            # PUSH1    PUSH2
            # [1 2] [3 4 5 6 7]
            #    G    MERGE  B
            #
            # so first, grab it. This needs to be done on the right branch.
            jp2 = JsonPushes(branch)
            raw = [
                int(i)
                for i in jp2.pushlog_within_changes(oldest, youngest, raw=True)
            ]
            data = jp2._request(
                jp2.json_pushes_url(
                    startID=str(min(raw) - 2),
                    endID=str(max(raw)),
                ))
            datakeys = [int(i) for i in data]
            oldest = data[str(min(datakeys))]["changesets"][0]
            youngest = data[str(max(datakeys))]["changesets"][-1]

            # we are ready to bisect further
            LOG.info("************* Switching to %s" % branch)
            gr, br = self._reverse_if_find_fix(oldest, youngest)
            result = (branch, gr, br)
        except MozRegressionError:
            LOG.debug("Got exception", exc_info=True)
            raise MozRegressionError(
                "Unable to exploit the merge commit. Origin branch is {}, and"
                " the commit message for {} was:\n{}".format(
                    most_recent_push.repo_name,
                    most_recent_push.short_changeset, msg))
        LOG.debug('End merge handling')
        return result
def test_revision_for_date_raise_appropriate_error():
    jpushes = JsonPushes(branch='inbound')
    jpushes.pushlog_within_changes = Mock(side_effect=EmptyPushlogError)

    with pytest.raises(EmptyPushlogError) as ctx:
        jpushes.revision_for_date(date(2015, 1, 1))

    assert str(ctx.value) == \
        'No pushes available for the date 2015-01-01 on inbound.'
示例#4
0
def test_revision_for_date_raise_appropriate_error():
    jpushes = JsonPushes(branch='inbound')
    jpushes.pushlog_within_changes = Mock(side_effect=EmptyPushlogError)

    with pytest.raises(EmptyPushlogError) as ctx:
        jpushes.revision_for_date(date(2015, 1, 1))

    assert str(ctx.value) == \
        'No pushes available for the date 2015-01-01 on inbound.'
示例#5
0
def test_pushlog_within_changes(mocker):
    push_first = {"1": {"date": 1}}
    other_pushes = {"2": {"date": 2}, "3": {"date": 3}}

    retry_get = mocker.patch("mozregression.json_pushes.retry_get")
    response = Mock(json=Mock(side_effect=[push_first, other_pushes]))
    retry_get.return_value = response

    jpushes = JsonPushes()
    assert jpushes.pushlog_within_changes("fromchset", "tochset") == [{"date": 1}, {"date": 2}, {"date": 3}]
def test_pushlog_within_changes(mocker):
    push_first = {'1': {'date': 1}}
    other_pushes = {
        '2': {'date': 2},
        '3': {'date': 3}
    }

    retry_get = mocker.patch('mozregression.json_pushes.retry_get')
    response = Mock(json=Mock(side_effect=[push_first, other_pushes]))
    retry_get.return_value = response

    jpushes = JsonPushes()
    assert jpushes.pushlog_within_changes('fromchset', "tochset") == [
        {'date': 1}, {'date': 2}, {'date': 3}
    ]

    # raw should include push ids in the result
    response = Mock(json=Mock(side_effect=[push_first, other_pushes]))
    retry_get.return_value = response

    assert jpushes.pushlog_within_changes(
        'fromchset', "tochset", raw=True
    ) == dict(push_first.items() + other_pushes.items())
示例#7
0
def range_for_inbounds(fetch_config, start_rev, end_rev):
    """
    Creates a BuildRange for inbounds builds.
    """
    info_fetcher = InboundInfoFetcher(fetch_config)

    pushlogs_finder = JsonPushes(branch=fetch_config.inbound_branch)
    pushlogs = pushlogs_finder.pushlog_within_changes(start_rev, end_rev)

    futures_builds = []
    for pushlog in pushlogs:
        changeset = pushlog['changesets'][-1]
        futures_builds.append(FutureBuildInfo(info_fetcher, changeset))
    return BuildRange(info_fetcher, futures_builds)
示例#8
0
def test_pushlog_within_changes_using_dates():
    p1 = {'changesets': ['abc'], 'date': 12345}
    p2 = {'changesets': ['def'], 'date': 67891}
    pushes = {'1': p1, '2': p2}

    jpushes = JsonPushes(branch='m-i')

    jpushes._request = Mock(return_value=pushes)

    assert jpushes.pushlog_within_changes(date(2015, 1, 1),
                                          date(2015, 2, 2)) == [p1, p2]

    jpushes._request.assert_called_once_with(
        'https://hg.mozilla.org/integration/mozilla-inbound/json-pushes?'
        'startdate=2015-01-01&enddate=2015-02-03')
示例#9
0
def test_pushlog_within_changes(mocker):
    push_first = {'1': {'date': 1}}
    other_pushes = {'2': {'date': 2}, '3': {'date': 3}}

    retry_get = mocker.patch('mozregression.json_pushes.retry_get')
    response = Mock(json=Mock(side_effect=[push_first, other_pushes]))
    retry_get.return_value = response

    jpushes = JsonPushes()
    assert jpushes.pushlog_within_changes('fromchset', "tochset") == [{
        'date': 1
    }, {
        'date': 2
    }, {
        'date': 3
    }]

    # raw should include push ids in the result
    response = Mock(json=Mock(side_effect=[push_first, other_pushes]))
    retry_get.return_value = response

    assert jpushes.pushlog_within_changes(
        'fromchset', "tochset",
        raw=True) == dict(push_first.items() + other_pushes.items())
示例#10
0
def test_pushlog_within_changes_using_dates():
    p1 = {'changesets': ['abc'], 'date': 12345}
    p2 = {'changesets': ['def'], 'date': 67891}
    pushes = {'1': p1, '2': p2}

    jpushes = JsonPushes(branch='m-i')

    jpushes._request = Mock(return_value=pushes)

    assert jpushes.pushlog_within_changes(
        date(2015, 1, 1), date(2015, 2, 2)
    ) == [p1, p2]

    jpushes._request.assert_called_once_with(
        'https://hg.mozilla.org/integration/mozilla-inbound/json-pushes?'
        'startdate=2015-01-01&enddate=2015-02-03'
    )