def insertTestData(self, buildResults, finalResult): self.db = self.master.db self.db.insertTestData([ fakedb.Master(id=92), fakedb.Worker(id=13, name='sl'), fakedb.Builder(id=79, name='Builder0'), fakedb.Builder(id=80, name='Builder1'), fakedb.Buildset(id=98, results=finalResult, reason="testReason1"), fakedb.BuildsetSourceStamp(buildsetid=98, sourcestampid=234), fakedb.SourceStamp(id=234, project=self.TEST_PROJECT, revision=self.TEST_REVISION, repository=self.TEST_REPO), fakedb.Change(changeid=13, branch=u'master', revision=u'9283', author='me@foo', repository=self.TEST_REPO, codebase=u'cbgerrit', project=u'world-domination', sourcestampid=234), ]) for i, results in enumerate(buildResults): self.db.insertTestData([ fakedb.BuildRequest(id=11 + i, buildsetid=98, builderid=79 + i), fakedb.Build(id=20 + i, number=i, builderid=79 + i, buildrequestid=11 + i, workerid=13, masterid=92, results=results, state_string=u"buildText"), fakedb.Step(id=50 + i, buildid=20 + i, number=5, name='make'), fakedb.Log(id=60 + i, stepid=50 + i, name='stdio', slug='stdio', type='s', num_lines=7), fakedb.LogChunk(logid=60 + i, first_line=0, last_line=1, compressed=0, content=u'Unicode log with non-ascii (\u00E5\u00E4\u00F6).'), fakedb.BuildProperty(buildid=20 + i, name="workername", value="sl"), fakedb.BuildProperty(buildid=20 + i, name="reason", value="because"), ]) for k, v in iteritems(self.TEST_PROPS): self.db.insertTestData([ fakedb.BuildProperty(buildid=20 + i, name=k, value=v) ])
def setupDb(self, results1, results2): self.db = self.master.db self.db.insertTestData([ fakedb.Master(id=92), fakedb.Worker(id=13, name='wrkr'), fakedb.Buildset(id=98, results=results1, reason="testReason1"), fakedb.Buildset(id=99, results=results2, reason="testReason2"), fakedb.Builder(id=80, name='Builder1'), fakedb.BuildRequest(id=11, buildsetid=98, builderid=80), fakedb.BuildRequest(id=12, buildsetid=99, builderid=80), fakedb.Build(id=20, number=0, builderid=80, buildrequestid=11, workerid=13, masterid=92, results=results1), fakedb.Build(id=21, number=1, builderid=80, buildrequestid=12, workerid=13, masterid=92, results=results1), ]) for _id in (20, 21): self.db.insertTestData([ fakedb.BuildProperty(buildid=_id, name="workername", value="wrkr"), fakedb.BuildProperty(buildid=_id, name="reason", value="because"), ])
def setUp(self): self.setUpEndpoint() self.db.insertTestData([ fakedb.Buildset(id=28), fakedb.BuildRequest(id=5, buildsetid=28), fakedb.Master(id=3), fakedb.Buildslave(id=42, name="Friday"), fakedb.Build(id=786, buildrequestid=5, masterid=3, buildslaveid=42), fakedb.BuildProperty(buildid=786, name="year", value=1651, source="Wikipedia"), fakedb.BuildProperty(buildid=786, name="island_name", value="despair", source="Book"), ])
def setupBuildResults(self, results, wantPreviousBuild=False): # this testsuite always goes through setupBuildResults so that # the data is sure to be the real data schema known coming from data # api self.db = self.master.db self.db.insertTestData([ fakedb.Master(id=92), fakedb.Worker(id=13, name='wrk'), fakedb.Buildset(id=98, results=results, reason="testReason1"), fakedb.Builder(id=80, name='Builder1'), fakedb.BuildRequest(id=11, buildsetid=98, builderid=80), fakedb.Build(id=20, number=0, builderid=80, buildrequestid=11, workerid=13, masterid=92, results=results), fakedb.Step(id=50, buildid=20, number=5, name='make'), fakedb.BuildsetSourceStamp(buildsetid=98, sourcestampid=234), fakedb.SourceStamp(id=234, patchid=99), fakedb.Change(changeid=13, branch=u'trunk', revision=u'9283', author='me@foo', repository=u'svn://...', codebase=u'cbsvn', project=u'world-domination', sourcestampid=234), fakedb.Log(id=60, stepid=50, name='stdio', slug='stdio', type='s', num_lines=7), fakedb.LogChunk(logid=60, first_line=0, last_line=1, compressed=0, content=u'Unicode log with non-ascii (\u00E5\u00E4\u00F6).'), fakedb.Patch(id=99, patch_base64='aGVsbG8sIHdvcmxk', patch_author='him@foo', patch_comment='foo', subdir='/foo', patchlevel=3), ]) for _id in (20,): self.db.insertTestData([ fakedb.BuildProperty( buildid=_id, name="workername", value="wrk"), fakedb.BuildProperty( buildid=_id, name="reason", value="because"), fakedb.BuildProperty( buildid=_id, name="scheduler", value="checkin"), fakedb.BuildProperty( buildid=_id, name="branch", value="master"), ]) res = yield utils.getDetailsForBuildset(self.master, 98, wantProperties=True, wantPreviousBuild=wantPreviousBuild) builds = res['builds'] buildset = res['buildset'] @defer.inlineCallbacks def getChangesForBuild(buildid): assert buildid == 20 ch = yield self.master.db.changes.getChange(13) defer.returnValue([ch]) self.master.db.changes.getChangesForBuild = getChangesForBuild defer.returnValue((buildset, builds))
def setupDb(self): self.db = self.master.db self.db.insertTestData([ fakedb.Master(id=92), fakedb.Worker(id=13, name='wrk'), fakedb.Buildset(id=98, results=SUCCESS, reason="testReason1"), fakedb.Builder(id=80, name='Builder1'), fakedb.BuildRequest(id=9, buildsetid=97, builderid=80), fakedb.BuildRequest(id=10, buildsetid=97, builderid=80), fakedb.BuildRequest(id=11, buildsetid=98, builderid=80), fakedb.BuildRequest(id=12, buildsetid=98, builderid=80), fakedb.Build(id=18, number=0, builderid=80, buildrequestid=9, workerid=13, masterid=92, results=FAILURE), fakedb.Build(id=19, number=1, builderid=80, buildrequestid=10, workerid=13, masterid=92, results=RETRY), fakedb.Build(id=20, number=2, builderid=80, buildrequestid=11, workerid=13, masterid=92, results=SUCCESS), fakedb.Build(id=21, number=3, builderid=80, buildrequestid=12, workerid=13, masterid=92, results=SUCCESS), fakedb.BuildsetSourceStamp(buildsetid=98, sourcestampid=234), fakedb.SourceStamp(id=234), fakedb.Change(changeid=13, branch=u'trunk', revision=u'9283', author='me@foo', repository=u'svn://...', codebase=u'cbsvn', project=u'world-domination', sourcestampid=234), fakedb.Patch(id=99, patch_base64='aGVsbG8sIHdvcmxk', patch_author='him@foo', patch_comment='foo', subdir='/foo', patchlevel=3), fakedb.SourceStamp(id=235, patchid=99), ]) for _id in (20, 21): self.db.insertTestData([ fakedb.BuildProperty( buildid=_id, name="workername", value="wrk"), fakedb.BuildProperty( buildid=_id, name="reason", value="because"), fakedb.BuildProperty( buildid=_id, name="owner", value="him"), fakedb.Step(id=100 + _id, buildid=_id, name="step1"), fakedb.Step(id=200 + _id, buildid=_id, name="step2"), fakedb.Log(id=60 + _id, stepid=100 + _id, name='stdio', slug='stdio', type='s', num_lines=2), fakedb.LogChunk(logid=60 + _id, first_line=0, last_line=1, compressed=0, content=self.LOGCONTENT), ]) @defer.inlineCallbacks def getChangesForBuild(buildid): assert buildid == 20 ch = yield self.master.db.changes.getChange(13) defer.returnValue([ch]) self.master.db.changes.getChangesForBuild = getChangesForBuild
def setupBuildResults(self, buildResults, finalResult): # this testsuite always goes through setupBuildResults so that # the data is sure to be the real data schema known coming from data api self.db = self.master.db self.db.insertTestData([ fakedb.Master(id=92), fakedb.Worker(id=13, name='sl'), fakedb.Builder(id=79, name='Builder0'), fakedb.Builder(id=80, name='Builder1'), fakedb.Buildset(id=98, results=finalResult, reason="testReason1"), fakedb.BuildsetSourceStamp(buildsetid=98, sourcestampid=234), fakedb.SourceStamp(id=234), fakedb.Change(changeid=13, branch=u'master', revision=u'9283', author='me@foo', repository=u'https://...', codebase=u'cbgerrit', project=u'world-domination', sourcestampid=234), ]) i = 0 for results in buildResults: self.db.insertTestData([ fakedb.BuildRequest(id=11 + i, buildsetid=98, builderid=79 + i), fakedb.Build(id=20 + i, number=i, builderid=79 + i, buildrequestid=11 + i, workerid=13, masterid=92, results=results, state_string=u"buildText"), fakedb.Step(id=50 + i, buildid=20 + i, number=5, name='make'), fakedb.Log(id=60 + i, stepid=50 + i, name='stdio', slug='stdio', type='s', num_lines=7), fakedb.LogChunk(logid=60 + i, first_line=0, last_line=1, compressed=0, content=u'Unicode log with non-ascii (\u00E5\u00E4\u00F6).'), fakedb.BuildProperty(buildid=20 + i, name="workername", value="sl"), fakedb.BuildProperty(buildid=20 + i, name="reason", value="because"), ]) for k, v in iteritems(self.TEST_PROPS): self.db.insertTestData([ fakedb.BuildProperty(buildid=20 + i, name=k, value=v) ]) i += 1 res = yield utils.getDetailsForBuildset(self.master, 98, wantProperties=True) builds = res['builds'] buildset = res['buildset'] @defer.inlineCallbacks def getChangesForBuild(buildid): assert buildid == 20 ch = yield self.master.db.changes.getChange(13) defer.returnValue([ch]) self.master.db.changes.getChangesForBuild = getChangesForBuild defer.returnValue((buildset, builds))
def setupDb(self, current, previous): super().setupDb(current, previous) job = self.load_fixture('crossbow-job.yaml') self.db.insertTestData([ fakedb.Step(id=50, buildid=21, number=0, name='compile'), fakedb.Step(id=51, buildid=21, number=1, name='benchmark', results=current), fakedb.Log(id=60, stepid=51, name='result', slug='result', type='t', num_lines=len(job)), fakedb.LogChunk(logid=60, first_line=0, last_line=len(job), compressed=0, content=job) ]) for _id in (20, 21): self.db.insertTestData([ fakedb.BuildProperty(buildid=_id, name='crossbow_repo', value='ursa-labs/crossbow') ])
def test_getResponsibleUsersForBuildWithOwners(self): self.setupDb() self.db.insertTestData([ fakedb.BuildProperty( buildid=20, name="owners", value=["him", "her"]), ]) res = yield utils.getResponsibleUsersForBuild(self.master, 20) self.assertEqual(sorted(res), sorted(["me@foo", "him", "her"]))
def test_getResponsibleUsersForBuildWithBadOwner(self): self.setUpLogging() self.setupDb() self.db.insertTestData([ fakedb.BuildProperty(buildid=20, name="owner", value=["him"]), ]) res = yield utils.getResponsibleUsersForBuild(self.master, 20) self.assertLogged("Please report a bug") self.assertEqual(sorted(res), sorted(["me@foo", "him"]))
def setupDb(self, results1, results2): # License note: # Copied from the original buildbot implementation with # minor changes and additions. self.db = self.master.db self.db.insertTestData([ fakedb.Master(id=92), fakedb.Worker(id=13, name='wrkr'), fakedb.Buildset(id=98, results=results1, reason='testReason1'), fakedb.Buildset(id=99, results=results2, reason='testReason2'), fakedb.Builder(id=80, name='Builder1'), fakedb.BuildRequest(id=11, buildsetid=98, builderid=80), fakedb.BuildRequest(id=12, buildsetid=99, builderid=80), fakedb.Build(id=20, number=0, builderid=80, buildrequestid=11, workerid=13, masterid=92, results=results1), fakedb.Build(id=21, number=1, builderid=80, buildrequestid=12, workerid=13, masterid=92, results=results1), ]) for _id in (20, 21): self.db.insertTestData([ fakedb.BuildProperty(buildid=_id, name='buildername', value='Builder1'), fakedb.BuildProperty(buildid=_id, name='workername', value='wrkr'), fakedb.BuildProperty(buildid=_id, name='revision', value=self.REVISION), fakedb.BuildProperty(buildid=_id, name='reason', value='because') ])