def testMultipleStepInstances(self): steps = [ (source.CVS, { 'cvsroot': "root", 'cvsmodule': "module" }), (shell.Configure, { 'command': "./configure" }), (shell.Compile, { 'command': "make" }), (shell.Compile, { 'command': "make more" }), (shell.Compile, { 'command': "make evenmore" }), (shell.Test, { 'command': "make test" }), (shell.Test, { 'command': "make testharder" }), ] f = factory.ConfigurableBuildFactory(steps) req = BuildRequest("reason", SourceStamp(), 'test_builder', Properties()) f.newBuild([req])
def getBuildRequestWithNumber(self, brid, t=None): assert isinstance(brid, (int, long)) breq_obj = rpc.RpcProxy('software_dev.commit') res = breq_obj.read(brid) if not res: return None ssid = brid # short-wire ss = self.getSourceStampNumberedNow(ssid, t, res) properties = self.get_properties_from_db(breq_obj, brid, t) bsid = brid br = BuildRequest(res['reason'], ss, res['buildername'], properties) br.submittedAt = str2time(res['submitted_at']) br.priority = res['priority'] br.id = brid br.bsid = bsid return br
def _txn_getBuildRequestWithNumber(self, t, brid): assert isinstance(brid, (int, long)) t.execute(self.quoteq("SELECT br.buildsetid, bs.reason," " bs.sourcestampid, br.buildername," " bs.submitted_at, br.priority" " FROM buildrequests AS br, buildsets AS bs" " WHERE br.id=? AND br.buildsetid=bs.id"), (brid,)) r = t.fetchall() if not r: return None (bsid, reason, ssid, builder_name, submitted_at, priority) = r[0] ss = self.getSourceStampNumberedNow(ssid, t) properties = self.get_properties_from_db("buildset_properties", "buildsetid", bsid, t) br = BuildRequest(reason, ss, builder_name, properties) br.submittedAt = submitted_at br.priority = priority br.id = brid br.bsid = bsid return br
def testGoodStep(self): f = BuildFactory() f.addStep(SetProperty(command=["echo", "value"], property="propname")) ss = SourceStamp() req = BuildRequest("Testing", ss, None) b = f.newBuild([req]) b.build_status = FakeBuildStatus() b.slavebuilder = FakeSlaveBuilder() # This shouldn't raise an exception b.setupBuild(None)
def setUp(self): rmtree("test_steps") self.builder = FakeBuilder() self.builder_status = builder.BuilderStatus("fakebuilder") self.builder_status.basedir = "test_steps" self.builder_status.nextBuildNumber = 0 os.mkdir(self.builder_status.basedir) self.build_status = self.builder_status.newBuild() req = BuildRequest("reason", SourceStamp(), 'test_builder', Properties()) self.build = base.Build([req]) self.build.build_status = self.build_status # fake it self.build.builder = self.builder self.build.slavebuilder = FakeSlaveBuilder() self.remote = FakeRemote() self.finished = 0
def _started(ign): # hack to find out what randomly-assigned port it is listening on port = self.find_webstatus(m).getPortnum() self.port = port # insert an event req = BuildRequest("reason", sourcestamp.SourceStamp(), 'test_builder') build1 = base.Build([req]) bs = m.status.getBuilder("builder1").newBuild() bs.setReason("reason") bs.buildStarted(build1) step1 = BuildStep(name="setup") step1.setBuild(build1) bss = bs.addStepWithName("setup") step1.setStepStatus(bss) bss.stepStarted() log1 = step1.addLog("output") log1.addStdout(u"s\N{LATIN CAPITAL LETTER O WITH GRAVE}me stdout\n".encode("utf-8")) log1.finish() log2 = step1.addHTMLLog("error", "<html>ouch</html>") del log2 log3 = step1.addLog("big") log3.addStdout("big log\n") for i in range(1000): log3.addStdout("a" * 500) log3.addStderr("b" * 500) log3.finish() log4 = step1.addCompleteLog("bigcomplete", "big2 log\n" + "a" * 1*1000*1000) del log4 log5 = step1.addLog("mixed") log5.addHeader("header content") log5.addStdout("this is stdout content") log5.addStderr("errors go here") log5.addEntry(5, "non-standard content on channel 5") log5.addStderr(" and some trailing stderr") d1 = defer.maybeDeferred(step1.step_status.stepFinished, builder.SUCCESS) bs.buildFinished() return d1
def setUp(self): self.builder = FakeBuilder() self.builder_status = builder.BuilderStatus("fakebuilder") self.basedir = self.mktemp() os.mkdir(self.basedir) self.builder_status.basedir = self.basedir self.builder_status.nextBuildNumber = 5 self.build_status = self.builder_status.newBuild() req = BuildRequest("reason", SourceStamp(branch="branch2", revision="1234"), 'test_builder', properties=Properties(scheduler="fakescheduler")) self.build = base.Build([req]) self.build.build_status = self.build_status self.build.setBuilder(self.builder) self.build.setupProperties() self.build.setupSlaveBuilder(FakeSlaveBuilder())
def makeBuildStep(basedir, step_class=BuildStep, **kwargs): bss = setupBuildStepStatus(basedir) ss = SourceStamp() setup = { 'name': "builder1", "slavename": "bot1", 'builddir': "builddir", 'slavebuilddir': "slavebuilddir", 'factory': None } b0 = Builder(setup, bss.getBuild().getBuilder()) b0.botmaster = FakeBotMaster() br = BuildRequest("reason", ss, 'test_builder') b = Build([br]) b.setBuilder(b0) s = step_class(**kwargs) s.setBuild(b) s.setStepStatus(bss) b.build_status = bss.getBuild() b.setupProperties() s.slaveVersion = fake_slaveVersion s.step_status.setText(s.describe(False)) return s
def _txn_getBuildRequestWithNumber(self, t, brid): assert isinstance(brid, (int, long)) t.execute( self.quoteq("SELECT br.buildsetid, bs.reason," " bs.sourcestampid, br.buildername," " bs.submitted_at, br.priority" " FROM buildrequests AS br, buildsets AS bs" " WHERE br.id=? AND br.buildsetid=bs.id"), (brid, )) r = t.fetchall() if not r: return None (bsid, reason, ssid, builder_name, submitted_at, priority) = r[0] ss = self.getSourceStampNumberedNow(ssid, t) properties = self.get_properties_from_db("buildset_properties", "buildsetid", bsid, t) br = BuildRequest(reason, ss, builder_name, properties) br.submittedAt = submitted_at br.priority = priority br.id = brid br.bsid = bsid return br
def create_status(self): for i in range(5): if i % 2 == 0: branch = "release" else: branch = None c = Change("user", ["foo.c"] * i, "see ticket #%i" % i, revision=str(42 + i), when=0.1 * i, branch=branch) self.master.change_svc.addChange(c) ss = sourcestamp.SourceStamp(revision=42) req = BuildRequest("reason", ss, 'test_builder') build1 = base.Build([req]) bs = self.master.status.getBuilder("builder1").newBuild() bs.setReason("reason") bs.buildStarted(build1) bs.setSourceStamp(ss) bs.setProperty("revision", "42", "testcase") bs.setProperty("got_revision", "47", "testcase") bs.setProperty("branch", "release", "testcase") step1 = BuildStep(name="setup") step1.setBuild(build1) bss = bs.addStepWithName("setup") step1.setStepStatus(bss) bss.stepStarted() step2 = BuildStep(name="build") step2.setBuild(build1) bss = bs.addStepWithName("build") step2.setStepStatus(bss) bss.stepStarted() step1.addURL("url1", "http://logurl.net/1") step1.addURL("url2", "http://logurl.net/2") step1.addURL("url3", "http://logurl.net/3") log1 = step1.addLog("output") log1.addStdout( u"some stdout\n") # FIXME: Unicode here fails validation log1.finish() # this has to validate too for the test to pass log2 = step1.addHTMLLog( "error", ''' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head><title>Teh Log</title></head> <body>Aaaiight</body> </html>''') del log2 log3 = step1.addLog("big") log3.addStdout("somewhat big log\n") for i in range(50): log3.addStdout("a" * 50 + "\n") log3.addStderr("b" * 50 + "\n") log3.finish() log5 = step1.addLog("mixed") log5.addHeader("header content") log5.addStdout("this is stdout content") log5.addStderr("errors go here") log5.addEntry(5, "non-standard content on channel 5") log5.addStderr(" and some trailing stderr") d = defer.succeed(None) for i in range(1, 3): ss = sourcestamp.SourceStamp(revision=42 + i, branch='release') req = BuildRequest("reason", ss, 'test_builder') build = base.Build([req] * i) bs = self.master.status.getBuilder("builder%i" % i).newBuild() bs.setReason("reason") bs.buildStarted(build) bs.setSourceStamp(ss) s = BuildStep(name="setup") s.setBuild(build1) bss = bs.addStepWithName("setup") s.setStepStatus(bss) bss.stepStarted() log = s.addLog("stdio") log.finish() d.chainDeferred( defer.maybeDeferred(step1.step_status.stepFinished, builder.SUCCESS)) bs.buildFinished() return d