[Buildbot-commits] buildbot/buildbot/test test_scheduler.py,NONE,1.1 test_buildreq.py,1.1,1.2
Brian Warner
warner at users.sourceforge.net
Wed Aug 10 04:52:43 UTC 2005
Update of /cvsroot/buildbot/buildbot/buildbot/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5477/buildbot/test
Modified Files:
test_buildreq.py
Added Files:
test_scheduler.py
Log Message:
Revision: arch at buildbot.sf.net--2004/buildbot--dev--0--patch-270
Creator: Brian Warner <warner at monolith.lothar.com>
add docs for 'try', some placeholder tests
* docs/buildbot.texinfo (try): add docs on the
as-yet-unimplemented Try scheduler
* buildbot/test/test_buildreq.py: move Scheduling tests out to ..
* buildbot/test/test_scheduler.py: .. here
(Scheduling.testTryJobdir): add placeholder test for 'try'
Index: test_buildreq.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_buildreq.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- test_buildreq.py 19 Jul 2005 23:11:58 -0000 1.1
+++ test_buildreq.py 10 Aug 2005 04:52:41 -0000 1.2
@@ -1,10 +1,8 @@
# -*- test-case-name: buildbot.test.test_buildreq -*-
from twisted.trial import unittest
-from twisted.internet import defer, reactor
-from twisted.application import service
-from buildbot import buildset, scheduler, interfaces, sourcestamp
+from buildbot import buildset, interfaces, sourcestamp
from buildbot.twcompat import maybeWait
from buildbot.process import base
from buildbot.status import builder
@@ -133,126 +131,3 @@
self.failUnlessEqual(res[1][0], "finished")
self.failUnlessEqual(res[1][1], bss)
-
-class FakeMaster(service.MultiService):
- def submitBuildSet(self, bs):
- self.sets.append(bs)
-
-class Scheduling(unittest.TestCase):
- def setUp(self):
- self.master = master = FakeMaster()
- master.sets = []
- master.startService()
-
- def tearDown(self):
- d = self.master.stopService()
- return maybeWait(d)
-
- def addScheduler(self, s):
- s.setServiceParent(self.master)
-
- def testPeriodic1(self):
- self.addScheduler(scheduler.Periodic("quickly", ["a","b"], 2))
- d = defer.Deferred()
- reactor.callLater(5, d.callback, None)
- d.addCallback(self._testPeriodic1_1)
- return maybeWait(d)
- def _testPeriodic1_1(self, res):
- self.failUnless(len(self.master.sets) > 1)
- s1 = self.master.sets[0]
- self.failUnlessEqual(s1.builderNames, ["a","b"])
-
- def testPeriodic2(self):
- # Twisted-2.0 starts the TimerService right away
- # Twisted-1.3 waits one interval before starting it.
- # so don't bother asserting anything about it
- raise unittest.SkipTest("twisted-1.3 and -2.0 are inconsistent")
- self.addScheduler(scheduler.Periodic("hourly", ["a","b"], 3600))
- d = defer.Deferred()
- reactor.callLater(1, d.callback, None)
- d.addCallback(self._testPeriodic2_1)
- return maybeWait(d)
- def _testPeriodic2_1(self, res):
- # the Periodic scheduler *should* fire right away
- self.failUnless(self.master.sets)
-
- def isImportant(self, change):
- if "important" in change.files:
- return True
- return False
-
- def testBranch(self):
- s = scheduler.Scheduler("b1", "branch1", 2, ["a","b"],
- fileIsImportant=self.isImportant)
- self.addScheduler(s)
-
- c0 = Change("carol", ["important"], "other branch", branch="other")
- s.addChange(c0)
- self.failIf(s.timer)
- self.failIf(s.importantChanges)
-
- c1 = Change("alice", ["important", "not important"], "some changes",
- branch="branch1")
- s.addChange(c1)
- c2 = Change("bob", ["not important", "boring"], "some more changes",
- branch="branch1")
- s.addChange(c2)
- c3 = Change("carol", ["important", "dull"], "even more changes",
- branch="branch1")
- s.addChange(c3)
-
- self.failUnlessEqual(s.importantChanges, [c1,c3])
- self.failUnlessEqual(s.unimportantChanges, [c2])
- self.failUnless(s.timer)
-
- d = defer.Deferred()
- reactor.callLater(4, d.callback, None)
- d.addCallback(self._testBranch_1)
- return maybeWait(d)
- def _testBranch_1(self, res):
- self.failUnlessEqual(len(self.master.sets), 1)
- s = self.master.sets[0].source
- self.failUnlessEqual(s.branch, "branch1")
- self.failUnlessEqual(s.revision, None)
- self.failUnlessEqual(len(s.changes), 3)
- self.failUnlessEqual(s.patch, None)
-
-
- def testAnyBranch(self):
- s = scheduler.AnyBranchScheduler("b1", None, 2, ["a","b"],
- fileIsImportant=self.isImportant)
- self.addScheduler(s)
-
- c1 = Change("alice", ["important", "not important"], "some changes",
- branch="branch1")
- s.addChange(c1)
- c2 = Change("bob", ["not important", "boring"], "some more changes",
- branch="branch1")
- s.addChange(c2)
- c3 = Change("carol", ["important", "dull"], "even more changes",
- branch="branch1")
- s.addChange(c3)
-
- c4 = Change("carol", ["important"], "other branch", branch="branch2")
- s.addChange(c4)
-
- d = defer.Deferred()
- reactor.callLater(4, d.callback, None)
- d.addCallback(self._testAnyBranch_1)
- return maybeWait(d)
- def _testAnyBranch_1(self, res):
- self.failUnlessEqual(len(self.master.sets), 2)
- self.master.sets.sort(lambda a,b: cmp(a.source.branch,
- b.source.branch))
- s1 = self.master.sets[0].source
- self.failUnlessEqual(s1.branch, "branch1")
- self.failUnlessEqual(s1.revision, None)
- self.failUnlessEqual(len(s1.changes), 3)
- self.failUnlessEqual(s1.patch, None)
-
- s2 = self.master.sets[1].source
- self.failUnlessEqual(s2.branch, "branch2")
- self.failUnlessEqual(s2.revision, None)
- self.failUnlessEqual(len(s2.changes), 1)
- self.failUnlessEqual(s2.patch, None)
-
--- NEW FILE: test_scheduler.py ---
# -*- test-case-name: buildbot.test.test_scheduler -*-
from twisted.trial import unittest
from twisted.internet import defer, reactor
from twisted.application import service
from buildbot import scheduler
from buildbot.twcompat import maybeWait
from buildbot.changes.changes import Change
class FakeMaster(service.MultiService):
def submitBuildSet(self, bs):
self.sets.append(bs)
class Scheduling(unittest.TestCase):
def setUp(self):
self.master = master = FakeMaster()
master.sets = []
master.startService()
def tearDown(self):
d = self.master.stopService()
return maybeWait(d)
def addScheduler(self, s):
s.setServiceParent(self.master)
def testPeriodic1(self):
self.addScheduler(scheduler.Periodic("quickly", ["a","b"], 2))
d = defer.Deferred()
reactor.callLater(5, d.callback, None)
d.addCallback(self._testPeriodic1_1)
return maybeWait(d)
def _testPeriodic1_1(self, res):
self.failUnless(len(self.master.sets) > 1)
s1 = self.master.sets[0]
self.failUnlessEqual(s1.builderNames, ["a","b"])
def testPeriodic2(self):
# Twisted-2.0 starts the TimerService right away
# Twisted-1.3 waits one interval before starting it.
# so don't bother asserting anything about it
raise unittest.SkipTest("twisted-1.3 and -2.0 are inconsistent")
self.addScheduler(scheduler.Periodic("hourly", ["a","b"], 3600))
d = defer.Deferred()
reactor.callLater(1, d.callback, None)
d.addCallback(self._testPeriodic2_1)
return maybeWait(d)
def _testPeriodic2_1(self, res):
# the Periodic scheduler *should* fire right away
self.failUnless(self.master.sets)
def isImportant(self, change):
if "important" in change.files:
return True
return False
def testBranch(self):
s = scheduler.Scheduler("b1", "branch1", 2, ["a","b"],
fileIsImportant=self.isImportant)
self.addScheduler(s)
c0 = Change("carol", ["important"], "other branch", branch="other")
s.addChange(c0)
self.failIf(s.timer)
self.failIf(s.importantChanges)
c1 = Change("alice", ["important", "not important"], "some changes",
branch="branch1")
s.addChange(c1)
c2 = Change("bob", ["not important", "boring"], "some more changes",
branch="branch1")
s.addChange(c2)
c3 = Change("carol", ["important", "dull"], "even more changes",
branch="branch1")
s.addChange(c3)
self.failUnlessEqual(s.importantChanges, [c1,c3])
self.failUnlessEqual(s.unimportantChanges, [c2])
self.failUnless(s.timer)
d = defer.Deferred()
reactor.callLater(4, d.callback, None)
d.addCallback(self._testBranch_1)
return maybeWait(d)
def _testBranch_1(self, res):
self.failUnlessEqual(len(self.master.sets), 1)
s = self.master.sets[0].source
self.failUnlessEqual(s.branch, "branch1")
self.failUnlessEqual(s.revision, None)
self.failUnlessEqual(len(s.changes), 3)
self.failUnlessEqual(s.patch, None)
def testAnyBranch(self):
s = scheduler.AnyBranchScheduler("b1", None, 2, ["a","b"],
fileIsImportant=self.isImportant)
self.addScheduler(s)
c1 = Change("alice", ["important", "not important"], "some changes",
branch="branch1")
s.addChange(c1)
c2 = Change("bob", ["not important", "boring"], "some more changes",
branch="branch1")
s.addChange(c2)
c3 = Change("carol", ["important", "dull"], "even more changes",
branch="branch1")
s.addChange(c3)
c4 = Change("carol", ["important"], "other branch", branch="branch2")
s.addChange(c4)
d = defer.Deferred()
reactor.callLater(4, d.callback, None)
d.addCallback(self._testAnyBranch_1)
return maybeWait(d)
def _testAnyBranch_1(self, res):
self.failUnlessEqual(len(self.master.sets), 2)
self.master.sets.sort(lambda a,b: cmp(a.source.branch,
b.source.branch))
s1 = self.master.sets[0].source
self.failUnlessEqual(s1.branch, "branch1")
self.failUnlessEqual(s1.revision, None)
self.failUnlessEqual(len(s1.changes), 3)
self.failUnlessEqual(s1.patch, None)
s2 = self.master.sets[1].source
self.failUnlessEqual(s2.branch, "branch2")
self.failUnlessEqual(s2.revision, None)
self.failUnlessEqual(len(s2.changes), 1)
self.failUnlessEqual(s2.patch, None)
def testTryJobdir(self):
raise unittest.SkipTest("not yet implemented")
s = scheduler.Try_Jobdir("try1", ["a", "b"], "jobdir1")
self.addScheduler(s)
def testTryUserpass(self):
raise unittest.SkipTest("not yet implemented")
up = [("alice","pw1"), ("bob","pw2")]
s = scheduler.Try_Userpass("try2", None, userpass=up)
self.addScheduler(s)
More information about the Commits
mailing list