Exemplo n.º 1
0
def test_problem_tracking_bug_alias_length(app):
    "Test alias length on problem tracking bug creation"
    # The slave name doesn't actually matter for this test
    slavename = "talos-mtnlion-r5-0010"

    def create_bug_alias_ok(data):
        data['id'] = 12345
        eq_(data['alias'], slavename, msg="alias should be set when ok")
        return data

    def create_bug_alias_long(data):
        data['id'] = 12345
        eq_(data['alias'], None, msg="alias should be None when too long")
        return data

    with app.app_context():
        with mock.patch("bzrest.client.BugzillaClient.create_bug") as mockcreatebug:
            with mock.patch("relengapi.blueprints.slaveloan.bugzilla.MAX_ALIAS", 50):
                mockcreatebug.side_effect = create_bug_alias_ok
                bug = bugzilla.ProblemTrackingBug(slavename, loadInfo=False)
                bug.create()
            with mock.patch("relengapi.blueprints.slaveloan.bugzilla.MAX_ALIAS", 5):
                mockcreatebug.side_effect = create_bug_alias_long
                bug = bugzilla.ProblemTrackingBug(slavename, loadInfo=False)
                bug.create()
Exemplo n.º 2
0
def bmo_set_tracking_bug(self, machine, loanid):
    try:
        l = Loans.query.get(loanid)
        assert l.bug_id

        bug_comment = "Being loaned to %s in Bug %s" % (l.human.ldap, l.bug_id)

        tracking_bug = bugzilla.ProblemTrackingBug(machine, loadInfo=False)
        try:
            tracking_bug.refresh()
        except bzrest.errors.BugNotFound:
            logger.info("Couldn't find bug, creating it...")
            tracking_bug.create(comment=bug_comment, depends_on=l.bug_id)

        if tracking_bug.data:
            data = {
                "depends_on": {
                    "add": [l.bug_id],
                },
            }
            if not tracking_bug.data["is_open"]:
                data["status"] = "REOPENED"
            tracking_bug.add_comment(bug_comment, data=data)
        if not tracking_bug.id:
            raise ValueError("Unexpected result from bmo, retry")
        return tracking_bug.id
    except Exception as exc:
        logger.exception(exc)
        self.retry(exc=exc)
Exemplo n.º 3
0
def test_problem_tracking_bug_slavename():
    "Test that slave_name is populated in problem tracking bug objects"
    # The slave name doesn't actually matter for this test
    slavename = "talos-mtnlion-r5-0010"
    bug = bugzilla.ProblemTrackingBug(slavename, loadInfo=False)
    eq_(bug.slave_name, slavename)
    eq_(bug.id_, slavename)
Exemplo n.º 4
0
def test_problem_tracking_bug_create_deps(app):
    "Test problem tracking bug creation includes depend"
    # The slave name doesn't actually matter for this test
    slavename = "foobar"

    def create_bug_comment(data):
        data['id'] = 12345
        eq_(data['depends_on'], 54321)
        return data

    with app.app_context():
        with mock.patch("bzrest.client.BugzillaClient.create_bug") as mockcreatebug:
            mockcreatebug.side_effect = create_bug_comment
            bug = bugzilla.ProblemTrackingBug(slavename, loadInfo=False)
            bug.create(depends_on=54321)