Example #1
0
 def asDict(self):
     return dict(action=self.action,
                 who=self.who,
                 when=self.when,
                 completed_at=self.completed_at,
                 complete_data=(json.loads(self.complete_data) if self.complete_data else self.complete_data),
                 what=json.loads(self.what))
Example #2
0
 def asDict(self):
     return dict(action=self.action,
                 who=self.who,
                 when=self.when,
                 completed_at=self.completed_at,
                 complete_data=(json.loads(self.complete_data) if
                                self.complete_data else self.complete_data),
                 what=json.loads(self.what))
Example #3
0
    def test_cancel_pending_revision(self):
        response = self.app.delete(url('cancel_revision', branch='branch1', revision='987654321', format='json'), extra_environ=dict(REMOTE_USER='******'))

        requests = self.get_jobrequests()
        self.assertEquals(len(requests), 1)
        r = requests[0]
        self.assertEquals(r.action, 'cancel_revision')
        self.assertEquals(r.who, 'me')
        self.assertEquals(json.loads(r.what), {'branch': 'branch1', 'revision': '987654321'})
Example #4
0
    def test_rebuild_request_priority(self):
        response = self.app.post(url('rebuild_request', branch='branch1', format='json'), {'request_id': 1, 'priority': 1}, extra_environ=dict(REMOTE_USER='******'))

        requests = self.get_jobrequests()
        self.assertEquals(len(requests), 1)
        r = requests[0]
        self.assertEquals(r.action, 'rebuild_request')
        self.assertEquals(r.who, 'me')
        self.assertEquals(json.loads(r.what), {'priority': 1, 'brid': 1})
Example #5
0
    def test_cancel_complete_request(self):
        response = self.app.delete(url('cancel_request', branch='branch1', request_id=1, format='json'), extra_environ=dict(REMOTE_USER='******'))

        requests = self.get_jobrequests()
        self.assertEquals(len(requests), 1)
        r = requests[0]
        self.assertEquals(r.who, 'me')
        self.assertEquals(r.action, 'cancel_request')
        self.assertEquals(json.loads(r.what), {'brid': 1})
Example #6
0
def getRequestProperties(request_id):
    # Get the properties for this request
    br = meta.scheduler_db_meta.tables['buildrequests']
    bs = meta.scheduler_db_meta.tables['buildsets']
    bsp = meta.scheduler_db_meta.tables['buildset_properties']

    props = bsp.select(and_(
        bsp.c.buildsetid == bs.c.id,
        bs.c.id == br.c.buildsetid,
        br.c.id == request_id,
        )).execute().fetchall()
    return dict( (p.property_name, json.loads(p.property_value)[0]) for p in props)
Example #7
0
    def test_reprioritize(self):
        self.g.mq._clock = mock.Mock(return_value=543221)
        p = self.engine.execute('select priority from buildrequests where id=3').scalar()
        self.assertEquals(p, 0)
        response = self.app.put(url('reprioritize', branch='branch1', request_id=3), {'priority': 1}, extra_environ=dict(REMOTE_USER='******'))

        # We're looking for a message being sent, not an actual change in the priority
        requests = self.get_jobrequests()
        self.assertEquals(len(requests), 1)
        r = requests[0]
        self.assertEquals(r.action, 'reprioritize')
        self.assertEquals(r.who, 'me')
        self.assertEquals(json.loads(r.what), {'priority': 1, 'brid': 3})
Example #8
0
    def new_build_for_builder(self, branch, builder_name, revision):
        """Creates a new arbitrary build/test for this buildername, for this revision. 
        Optional POST parameters are 'properties' and 'files', which should be a dictionary and a list, respectively."""
        who = self._require_auth()

        if branch not in self._branches_cache:
            return self._failed("Branch %s not found" % branch, 404)

        # Get priority
        try:
            priority = validators.Int(if_empty=0).\
                to_python(request.POST.get('priority'))
        except formencode.Invalid:
            return self._failed('Bad priority', 400)

        # Get properties
        try:
            properties = json.loads(request.POST.get('properties'))
            assert isinstance(properties, dict)
        except Exception:
            properties = {}

        # Get the list of files
        try:
            files = json.loads(request.POST.get('files'))
            assert isinstance(files, list)
        except Exception:
            files = []

        # Set branch to ${branch}-selfserve to keep schedulers from triggering
        branch += "-selfserve"
        access_log.info("%s new_build_for_builder of %s %s %s",
                        who, branch, builder_name, revision)
        retval = g.mq.newBuildForBuilder(
                        who, branch, revision, priority, builder_name, properties, files)
        response.status = 202

        return self._format(retval)
Example #9
0
    def new_build_for_builder(self, branch, builder_name, revision):
        """Creates a new arbitrary build/test for this buildername, for this revision.
        Optional POST parameters are 'properties' and 'files', which should be a dictionary and a list, respectively."""
        who = self._require_auth()

        if branch not in self._branches_cache:
            return self._failed("Branch %s not found" % branch, 404)

        # Get priority
        try:
            priority = validators.Int(if_empty=0).\
                to_python(request.POST.get('priority'))
        except formencode.Invalid:
            return self._failed('Bad priority', 400)

        # Get properties
        try:
            properties = json.loads(request.POST.get('properties'))
            assert isinstance(properties, dict)
        except Exception:
            properties = {}

        # Get the list of files
        try:
            files = json.loads(request.POST.get('files'))
            assert isinstance(files, list)
        except Exception:
            files = []

        # Set branch to ${branch}-selfserve to keep schedulers from triggering
        branch += "-selfserve"
        access_log.info("%s new_build_for_builder of %s %s %s",
                        who, branch, builder_name, revision)
        retval = g.mq.newBuildForBuilder(
                        who, branch, revision, priority, builder_name, properties, files)
        response.status = 202

        return self._format(retval)
Example #10
0
    def test_rebuild_request(self):
        old_req = self.engine.execute("select * from buildrequests where id=5").fetchone()
        self.assertEquals(old_req, None)

        old_req = self.engine.execute("select * from buildrequests, buildsets where buildrequests.id=1 and buildrequests.buildsetid = buildsets.id").fetchone()

        response = self.app.post(url('rebuild_request', branch='branch1', format='json'), {'request_id': 1}, extra_environ=dict(REMOTE_USER='******'))

        requests = self.get_jobrequests()
        self.assertEquals(len(requests), 1)
        r = requests[0]
        self.assertEquals(r.action, 'rebuild_request')
        self.assertEquals(r.who, 'me')
        self.assertEquals(json.loads(r.what), {'priority': 0, 'brid': 1})
Example #11
0
    def test_cancel_running_build(self):
        complete, claimed_at = self.engine.execute('select complete, claimed_at from buildrequests where id=2').fetchone()
        self.assertEquals(complete, 0)
        self.assert_(claimed_at != 0)

        self.app.delete(url('cancel_build', branch='branch2', build_id=2, format='json'), extra_environ=dict(REMOTE_USER='******'))

        # We're looking for a message being sent, not an actual change in the priority
        requests = self.get_jobrequests()
        self.assertEquals(len(requests), 1)
        r = requests[0]
        self.assertEquals(r.action, 'cancel_build')
        self.assertEquals(r.who, 'me')
        self.assertEquals(json.loads(r.what), {'bid': 2})