Skip to content

Commit

Permalink
Patch for Ticket #2630(Remove links from REST)
Browse files Browse the repository at this point in the history
  • Loading branch information
rahuln55 committed Mar 21, 2014
1 parent 4d9f5d6 commit 08ef566
Show file tree
Hide file tree
Showing 17 changed files with 18 additions and 88 deletions.
7 changes: 2 additions & 5 deletions master/buildbot/data/builders.py
Expand Up @@ -39,8 +39,7 @@ def get(self, resultSpec, kwargs):
return
defer.returnValue(
dict(builderid=builderid,
name=bdict['name'],
link=base.Link(('builders', str(kwargs['builderid'])))))
name=bdict['name']))


class BuildersEndpoint(base.Endpoint):
Expand All @@ -58,8 +57,7 @@ def get(self, resultSpec, kwargs):
masterid=kwargs.get('masterid', None))
defer.returnValue([
dict(builderid=bd['id'],
name=bd['name'],
link=base.Link(('builders', str(bd['id']))))
name=bd['name'])
for bd in bdicts])

def startConsuming(self, callback, options, kwargs):
Expand All @@ -77,7 +75,6 @@ class Builder(base.ResourceType):
class EntityType(types.Entity):
builderid = types.Integer()
name = types.Identifier(20)
link = types.Link()
entityType = EntityType(name)

def __init__(self, master):
Expand Down
4 changes: 0 additions & 4 deletions master/buildbot/data/buildrequests.py
Expand Up @@ -28,7 +28,6 @@ def db2data(self, dbdict):
data = {
'buildrequestid': dbdict['buildrequestid'],
'buildsetid': dbdict['buildsetid'],
'buildset_link': base.Link(('buildsets', str(dbdict['buildsetid']))),
'builderid': dbdict['builderid'],
'buildername': dbdict['buildername'],
'priority': dbdict['priority'],
Expand All @@ -40,7 +39,6 @@ def db2data(self, dbdict):
'submitted_at': dbdict['submitted_at'],
'complete_at': dbdict['complete_at'],
'waited_for': dbdict['waited_for'],
'link': base.Link(('buildrequests', str(dbdict['buildrequestid']))),
}
return defer.succeed(data)

Expand Down Expand Up @@ -145,7 +143,6 @@ class BuildRequest(base.ResourceType):
class EntityType(types.Entity):
buildrequestid = types.Integer()
buildsetid = types.Integer()
buildset_link = types.Link()
builderid = types.Integer()
buildername = types.Identifier(20)
priority = types.Integer()
Expand All @@ -157,7 +154,6 @@ class EntityType(types.Entity):
submitted_at = types.DateTime()
complete_at = types.NoneOk(types.DateTime())
waited_for = types.Boolean()
link = types.Link()
entityType = EntityType(name)

@defer.inlineCallbacks
Expand Down
11 changes: 0 additions & 11 deletions master/buildbot/data/builds.py
Expand Up @@ -25,20 +25,14 @@ def db2data(self, dbdict):
'buildid': dbdict['id'],
'number': dbdict['number'],
'builderid': dbdict['builderid'],
'builder_link': base.Link(('builders', str(dbdict['builderid']))),
'buildrequestid': dbdict['buildrequestid'],
'buildrequest_link': base.Link(('buildrequests',
str(dbdict['buildrequestid']))),
'buildslaveid': dbdict['buildslaveid'],
'slave_link': base.Link(('slaves', str(dbdict['buildslaveid']))),
'masterid': dbdict['masterid'],
'master_link': base.Link(('masters', str(dbdict['masterid']))),
'started_at': dbdict['started_at'],
'complete_at': dbdict['complete_at'],
'complete': dbdict['complete_at'] is not None,
'state_strings': dbdict['state_strings'],
'results': dbdict['results'],
'link': base.Link(('builds', str(dbdict['id']))),
}
return defer.succeed(data)

Expand Down Expand Up @@ -123,19 +117,14 @@ class EntityType(types.Entity):
buildid = types.Integer()
number = types.Integer()
builderid = types.Integer()
builder_link = types.Link()
buildrequestid = types.Integer()
buildrequest_link = types.Link()
buildslaveid = types.Integer()
slave_link = types.Link()
masterid = types.Integer()
master_link = types.Link()
started_at = types.DateTime()
complete = types.Boolean()
complete_at = types.NoneOk(types.DateTime())
results = types.NoneOk(types.Integer())
state_strings = types.List(of=types.String())
link = types.Link()
entityType = EntityType(name)

@defer.inlineCallbacks
Expand Down
10 changes: 0 additions & 10 deletions master/buildbot/data/buildsets.py
Expand Up @@ -52,7 +52,6 @@ def getSs(ssid):
# minor modifications
buildset['submitted_at'] = datetime2epoch(buildset['submitted_at'])
buildset['complete_at'] = datetime2epoch(buildset['complete_at'])
buildset['link'] = base.Link(('buildsets', str(buildset['bsid'])))

defer.returnValue(buildset)

Expand Down Expand Up @@ -120,7 +119,6 @@ class EntityType(types.Entity):
results = types.NoneOk(types.Integer())
sourcestamps = types.List(
of=sourcestampsapi.SourceStamp.entityType)
link = types.Link()
parent_buildid = types.NoneOk(types.Integer())
parent_relationship = types.NoneOk(types.String())
entityType = EntityType(name)
Expand All @@ -145,10 +143,6 @@ def addBuildset(self, waited_for, scheduler=None, sourcestamps=[], reason=u'',
(yield self.master.data.get(('sourcestamps', str(ssid)))).copy()
for ssid in bsdict['sourcestamps']]

# strip the links from those sourcestamps
for ss in sourcestamps:
del ss['link']

# notify about the component build requests
# TODO: needs to be refactored when buildrequests are in the DB
for bn, brid in brids.iteritems():
Expand Down Expand Up @@ -233,10 +227,6 @@ def maybeBuildsetComplete(self, bsid, _reactor=reactor):
('sourcestamps', str(ssid)))))
for ssid in bsdict['sourcestamps']]

# strip the links from those sourcestamps
for ss in sourcestamps:
del ss['link']

msg = dict(
bsid=bsid,
external_idstring=bsdict['external_idstring'],
Expand Down
14 changes: 4 additions & 10 deletions master/buildbot/data/buildslaves.py
Expand Up @@ -26,15 +26,12 @@ def db2data(self, dbdict):
'name': dbdict['name'],
'slaveinfo': dbdict['slaveinfo'],
'connected_to': [
{'masterid': id, 'link': base.Link(('masters', str(id)))}
{'masterid': id}
for id in dbdict['connected_to']],
'configured_on': [
{'masterid': c['masterid'],
'builderid': c['builderid'],
'link': base.Link(('masters', str(c['masterid']),
'builders', str(c['builderid'])))}
'builderid': c['builderid']}
for c in dbdict['configured_on']],
'link': base.Link(('buildslaves', str(dbdict['id']))),
}


Expand Down Expand Up @@ -93,14 +90,11 @@ class EntityType(types.Entity):
buildslaveid = types.Integer()
name = types.String()
connected_to = types.List(of=types.Dict(
masterid=types.Integer(),
link=types.Link()))
masterid=types.Integer()))
configured_on = types.List(of=types.Dict(
masterid=types.Integer(),
builderid=types.Integer(),
link=types.Link()))
builderid=types.Integer()))
slaveinfo = types.JsonObject()
link = types.Link()
entityType = EntityType(name)

@base.updateMethod
Expand Down
4 changes: 0 additions & 4 deletions master/buildbot/data/changes.py
Expand Up @@ -35,7 +35,6 @@ def _fixChange(self, change):
if change:
change = change.copy()
change['when_timestamp'] = datetime2epoch(change['when_timestamp'])
change['link'] = base.Link(('changes', str(change['changeid'])))

sskey = ('sourcestamps', str(change['sourcestampid']))
change['sourcestamp'] = yield self.master.data.get(sskey)
Expand Down Expand Up @@ -99,7 +98,6 @@ class EntityType(types.Entity):
project = types.String()
codebase = types.String()
sourcestamp = sourcestamps.SourceStamp.entityType
link = types.Link()
entityType = EntityType(name)

@base.updateMethod
Expand Down Expand Up @@ -165,8 +163,6 @@ def addChange(self, files=None, comments=None, author=None, revision=None,
# get the change and munge the result for the notification
change = yield self.master.data.get(('changes', str(changeid)))
change = copy.deepcopy(change)
del change['link']
del change['sourcestamp']['link']
self.produceEvent(change, 'new')

# log, being careful to handle funny characters
Expand Down
2 changes: 0 additions & 2 deletions master/buildbot/data/changesources.py
Expand Up @@ -32,7 +32,6 @@ def db2data(self, dbdict):
'changesourceid': dbdict['id'],
'name': dbdict['name'],
'master': master,
'link': base.Link(('changesources', str(dbdict['id']))),
}
defer.returnValue(data)

Expand Down Expand Up @@ -89,7 +88,6 @@ class EntityType(types.Entity):
changesourceid = types.Integer()
name = types.String()
master = types.NoneOk(masters.Master.entityType)
link = types.Link()
entityType = EntityType(name)

@base.updateMethod
Expand Down
4 changes: 0 additions & 4 deletions master/buildbot/data/logs.py
Expand Up @@ -27,11 +27,9 @@ def db2data(self, dbdict):
'name': dbdict['name'],
'slug': dbdict['slug'],
'stepid': dbdict['stepid'],
'step_link': base.Link(('steps', str(dbdict['stepid']))),
'complete': dbdict['complete'],
'num_lines': dbdict['num_lines'],
'type': dbdict['type'],
'link': base.Link(('logs', str(dbdict['id']))),
}
return defer.succeed(data)

Expand Down Expand Up @@ -103,11 +101,9 @@ class EntityType(types.Entity):
name = types.String()
slug = types.Identifier(50)
stepid = types.Integer()
step_link = types.Link()
complete = types.Boolean()
num_lines = types.Integer()
type = types.Identifier(1)
link = types.Link()
entityType = EntityType(name)

@defer.inlineCallbacks
Expand Down
4 changes: 1 addition & 3 deletions master/buildbot/data/masters.py
Expand Up @@ -28,8 +28,7 @@ def _db2data(master):
return dict(masterid=master['id'],
name=master['name'],
active=master['active'],
last_active=master['last_active'],
link=base.Link(('masters', str(master['id']))))
last_active=master['last_active'])


class MasterEndpoint(base.Endpoint):
Expand Down Expand Up @@ -95,7 +94,6 @@ class EntityType(types.Entity):
name = types.String()
active = types.Boolean()
last_active = types.DateTime()
link = types.Link()
entityType = EntityType(name)

@base.updateMethod
Expand Down
2 changes: 0 additions & 2 deletions master/buildbot/data/schedulers.py
Expand Up @@ -32,7 +32,6 @@ def db2data(self, dbdict):
'schedulerid': dbdict['id'],
'name': dbdict['name'],
'master': master,
'link': base.Link(('schedulers', str(dbdict['id']))),
}
defer.returnValue(data)

Expand Down Expand Up @@ -90,7 +89,6 @@ class EntityType(types.Entity):
schedulerid = types.Integer()
name = types.String()
master = types.NoneOk(masters.Master.entityType)
link = types.Link()
entityType = EntityType(name)

@base.updateMethod
Expand Down
2 changes: 0 additions & 2 deletions master/buildbot/data/sourcestamps.py
Expand Up @@ -28,7 +28,6 @@ def _db2data(ss):
'repository': ss['repository'],
'codebase': ss['codebase'],
'created_at': ss['created_at'],
'link': base.Link(('sourcestamps', str(ss['ssid']))),
'patch': None,
}
if ss['patch_body']:
Expand Down Expand Up @@ -91,5 +90,4 @@ class EntityType(types.Entity):
codebase = types.String()
patch = types.NoneOk(patches.Patch.entityType)
created_at = types.DateTime()
link = types.Link()
entityType = EntityType(name)
4 changes: 0 additions & 4 deletions master/buildbot/data/steps.py
Expand Up @@ -26,14 +26,12 @@ def db2data(self, dbdict):
'number': dbdict['number'],
'name': dbdict['name'],
'buildid': dbdict['buildid'],
'build_link': base.Link(('builds', str(dbdict['buildid']))),
'started_at': dbdict['started_at'],
'complete': dbdict['complete_at'] is not None,
'complete_at': dbdict['complete_at'],
'state_strings': dbdict['state_strings'],
'results': dbdict['results'],
'urls': dbdict['urls'],
'link': base.Link(('builds', str(dbdict['id']))),
}
return defer.succeed(data)

Expand Down Expand Up @@ -115,7 +113,6 @@ class EntityType(types.Entity):
number = types.Integer()
name = types.Identifier(50)
buildid = types.Integer()
build_link = types.Link()
started_at = types.NoneOk(types.DateTime())
complete = types.Boolean()
complete_at = types.NoneOk(types.DateTime())
Expand All @@ -126,7 +123,6 @@ class EntityType(types.Entity):
name=types.String(),
url=types.String()
))
link = types.Link()
entityType = EntityType(name)

@defer.inlineCallbacks
Expand Down
6 changes: 3 additions & 3 deletions master/buildbot/test/integration/test_www.py
Expand Up @@ -143,9 +143,9 @@ def test_masters(self):
self.assertEqual(res, {
'masters': [
{'active': False, 'masterid': 7, 'name': 'some:master',
'last_active': SOMETIME, 'link': self.link('masters/7')},
'last_active': SOMETIME},
{'active': True, 'masterid': 8, 'name': 'other:master',
'last_active': OTHERTIME, 'link': self.link('masters/8')},
'last_active': OTHERTIME},
],
'meta': {
'total': 2,
Expand All @@ -158,7 +158,7 @@ def test_masters(self):
self.assertEqual(res, {
'masters': [
{'active': False, 'masterid': 7, 'name': 'some:master',
'last_active': SOMETIME, 'link': self.link('masters/7')},
'last_active': SOMETIME},
],
'meta': {
'links': [
Expand Down
5 changes: 0 additions & 5 deletions master/buildbot/test/unit/test_data_buildrequests.py
Expand Up @@ -18,7 +18,6 @@

from buildbot.data import buildrequests
from buildbot.data import resultspec
from buildbot.data.base import Link
from buildbot.test.fake import fakedb
from buildbot.test.fake import fakemaster
from buildbot.test.util import endpoint
Expand Down Expand Up @@ -73,15 +72,11 @@ def testGetExisting(self):
self.assertEqual(buildrequest['results'], 75)
self.assertEqual(buildrequest['claimed_by_masterid'],
fakedb.FakeBuildRequestsComponent.MASTER_ID)
self.assertEqual(buildrequest['link'].__repr__(),
Link(('buildrequests', '44'), []).__repr__())
self.assertEqual(buildrequest['claimed'], True)
self.assertEqual(buildrequest['submitted_at'], self.SUBMITTED_AT)
self.assertEqual(buildrequest['complete_at'], self.COMPLETE_AT)
self.assertEqual(buildrequest['buildsetid'], 8822)
self.assertEqual(buildrequest['priority'], 7)
self.assertEqual(buildrequest['buildset_link'].__repr__(),
Link(('buildsets', '8822'), []).__repr__())

@defer.inlineCallbacks
def testGetMissing(self):
Expand Down

0 comments on commit 08ef566

Please sign in to comment.