[Buildbot-commits] buildbot/buildbot/test test_steps.py,1.14,1.15

Brian Warner warner at users.sourceforge.net
Sat Oct 22 22:42:01 UTC 2005


Update of /cvsroot/buildbot/buildbot/buildbot/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32691/buildbot/test

Modified Files:
	test_steps.py 
Log Message:
Revision: arch at buildbot.sf.net--2004/buildbot--dev--0--patch-354
Creator:  Brian Warner <warner at lothar.com>

add some slave-versioning code

	* buildbot/slave/commands.py (cvs_ver): document new features

	* buildbot/process/step.py (BuildStep.slaveVersion): document it
	(BuildStep.slaveVersionNewEnough): more useful utility method
	* buildbot/test/test_steps.py (Version): start testing it


Index: test_steps.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_steps.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- test_steps.py	19 Jul 2005 23:11:58 -0000	1.14
+++ test_steps.py	22 Oct 2005 22:41:58 -0000	1.15
@@ -24,6 +24,9 @@
 from buildbot.process import step, base, factory
 from buildbot.process.step import ShellCommand #, ShellCommands
 from buildbot.status import builder
+from buildbot.test.runutils import RunMixin
+from buildbot.twcompat import maybeWait
+from buildbot.slave import commands
 
 from twisted.python import log
 #log.startLogging(sys.stdout)
@@ -167,3 +170,65 @@
         req = base.BuildRequest("reason", SourceStamp())
         b = f.newBuild([req])
         #for s in b.steps: print s.name
+
+class VersionCheckingStep(step.BuildStep):
+    def start(self):
+        # give our test a chance to run. It is non-trivial for a buildstep to
+        # claw its way back out to the test case which is currently running.
+        master = self.build.builder.botmaster.parent
+        checker = master._checker
+        checker(self)
+        # then complete
+        self.finished(step.SUCCESS)
+
+version_config = """
+from buildbot.process import factory, step
+from buildbot.test.test_steps import VersionCheckingStep
+BuildmasterConfig = c = {}
+f1 = factory.BuildFactory([
+    factory.s(VersionCheckingStep),
+    ])
+c['bots'] = [['bot1', 'sekrit']]
+c['sources'] = []
+c['schedulers'] = []
+c['builders'] = [{'name':'quick', 'slavename':'bot1',
+                  'builddir': 'quickdir', 'factory': f1}]
+c['slavePortnum'] = 0
+"""
+
+class Version(RunMixin, unittest.TestCase):
+    def setUp(self):
+        RunMixin.setUp(self)
+        self.master.loadConfig(version_config)
+        self.master.startService()
+        d = self.connectSlave(["quick"])
+        return maybeWait(d)
+
+    def doBuild(self, buildername):
+        br = base.BuildRequest("forced", SourceStamp())
+        d = br.waitUntilFinished()
+        self.control.getBuilder(buildername).requestBuild(br)
+        return d
+
+
+    def checkCompare(self, s):
+        v = s.slaveVersion("svn", None)
+        # this insures that we are getting the version correctly
+        self.failUnlessEqual(s.slaveVersion("svn", None), commands.cvs_ver)
+        # and that non-existent commands do not provide a version
+        self.failUnlessEqual(s.slaveVersion("NOSUCHCOMMAND"), None)
+        # TODO: verify that a <=0.5.0 buildslave (which does not implement
+        # remote_getCommands) handles oldversion= properly. This requires a
+        # mutant slave which does not offer that method.
+        #self.failUnlessEqual(s.slaveVersion("NOSUCHCOMMAND", "old"), "old")
+
+        # now check the comparison functions
+        self.failUnless(s.slaveVersionNewEnough("svn", commands.cvs_ver))
+        self.failUnless(s.slaveVersionNewEnough("svn", "1.1"))
+        self.failIf(s.slaveVersionNewEnough("svn", commands.cvs_ver + ".1"))
+
+    def testCompare(self):
+        self.master._checker = self.checkCompare
+        d = self.doBuild("quick")
+        return maybeWait(d)
+





More information about the Commits mailing list