Skip to content

Commit

Permalink
add a buildrequests.waited_for column
Browse files Browse the repository at this point in the history
fix the fake buildrequest.waited_for
  • Loading branch information
Buck Golemon committed Aug 7, 2013
1 parent 027cada commit 2a7ff92
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 5 deletions.
3 changes: 2 additions & 1 deletion master/buildbot/db/buildrequests.py
Expand Up @@ -265,4 +265,5 @@ def mkdt(epoch):
buildername=row.buildername, priority=row.priority,
claimed=claimed, claimed_at=claimed_at, mine=mine,
complete=bool(row.complete), results=row.results,
submitted_at=submitted_at, complete_at=complete_at)
submitted_at=submitted_at, complete_at=complete_at,
waited_for=bool(row.waited_for))
@@ -0,0 +1,12 @@
import sqlalchemy as sa

def upgrade(migrate_engine):
metadata = sa.MetaData()
metadata.bind = migrate_engine

buildrequests_table = sa.Table('buildrequests', metadata, autoload=True)

# boolean indicating whether there is a step blocking, waiting for this request to complete
waited_for = sa.Column('waited_for', sa.SmallInteger,
server_default=sa.DefaultClause("0"))
waited_for.create(buildrequests_table)
6 changes: 5 additions & 1 deletion master/buildbot/db/model.py
Expand Up @@ -45,7 +45,7 @@ class Model(base.DBConnectorComponent):
# * dates are stored as unix timestamps (UTC-ish epoch time)
#
# * sqlalchemy does not handle sa.Boolean very well on MySQL or Postgres;
# use sa.Integer instead
# use sa.SmallInteger instead

# build requests

Expand Down Expand Up @@ -73,6 +73,10 @@ class Model(base.DBConnectorComponent):

# time the buildrequest was completed, or NULL
sa.Column('complete_at', sa.Integer),

# boolean indicating whether there is a step blocking, waiting for this request to complete
sa.Column('waited_for', sa.SmallInteger,
server_default=sa.DefaultClause("0")),
)

# Each row in this table represents a claimed build request, where the
Expand Down
1 change: 1 addition & 0 deletions master/buildbot/process/buildrequest.py
Expand Up @@ -105,6 +105,7 @@ def _make_br(cls, brid, brdict, master):
dt = brdict['submitted_at']
buildrequest.submittedAt = dt and calendar.timegm(dt.utctimetuple())
buildrequest.master = master
buildrequest.waitedFor = brdict['waited_for']

# fetch the buildset to get the reason
buildset = yield master.db.buildsets.getBuildset(brdict['buildsetid'])
Expand Down
5 changes: 3 additions & 2 deletions master/buildbot/test/fake/fakedb.py
Expand Up @@ -23,7 +23,6 @@
import base64
import hashlib
from buildbot.util import json, datetime2epoch
from twisted.python import failure
from twisted.internet import defer, reactor
from buildbot.db import buildrequests, schedulers, changesources
from buildbot.test.util import validation
Expand Down Expand Up @@ -122,6 +121,7 @@ class BuildRequest(Row):
results = -1,
submitted_at = 0,
complete_at = 0,
waited_for = 0,
)

id_column = 'id'
Expand Down Expand Up @@ -1530,7 +1530,8 @@ def _brdictFromRow(self, row):
buildername=row.buildername, priority=row.priority,
claimed=claimed, claimed_at=claimed_at, mine=mine,
complete=bool(row.complete), results=row.results,
submitted_at=submitted_at, complete_at=complete_at)
submitted_at=submitted_at, complete_at=complete_at,
waited_for=bool(row.waited_for))

# fake methods

Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/test/unit/test_db_buildrequests.py
Expand Up @@ -72,7 +72,7 @@ def check(brdict):
priority=7, claimed=True, mine=True, complete=True,
results=75, claimed_at=self.CLAIMED_AT,
submitted_at=self.SUBMITTED_AT,
complete_at=self.COMPLETE_AT))
complete_at=self.COMPLETE_AT, waited_for=False))
d.addCallback(check)
return d

Expand Down

0 comments on commit 2a7ff92

Please sign in to comment.