monotone-commits-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Monotone-commits-diffs] net.venge.monotone: b20a7c199ce2d223b1c86c2346


From: code
Subject: [Monotone-commits-diffs] net.venge.monotone: b20a7c199ce2d223b1c86c23467ac9e7df43b2cf
Date: Sun, 13 Mar 2011 10:44:41 +0100 (CET)

revision:            b20a7c199ce2d223b1c86c23467ac9e7df43b2cf
date:                2011-03-13T09:44:18
author:              Richard Levitte <address@hidden>
branch:              net.venge.monotone
changelog:
* contrib/monotone-buildbot-notification.lua: Moved and renamed...
* extra/mtn-hooks/monotone-buildbot.lua: ... here.  Changed the name
  slightly, and only run old_note_commit if it's not nil.

* test/extra/buildbot/__driver__.lua: Test driver for the buildbot script.
* test/extra/buildbot/master.cfg: A buildbot master configuration that
  dumps some of the data received from a 'buildbot sendchange' to file.
* test/extra/buildbot/expected.result.dat: The result expected.
* test/extra/buildbot/run-buildbot.sh: A script to start the buildbots
  after a few environment variables get set.

manifest:
format_version "1"

new_manifest [81f4776ef45898f1701bc9917df819a8443bae81]

old_revision [2b305b8844c5c3e66f21f5e0fd6c7dcb70748327]

rename "contrib/monotone-buildbot-notification.lua"
    to "extra/mtn-hooks/monotone-buildbot.lua"

add_dir "test/extra/buildbot"

add_file "test/extra/buildbot/__driver__.lua"
 content [af50ca47a8edc3bb98be59d65c8c29bb789bfaf0]

add_file "test/extra/buildbot/expected.result.dat"
 content [69c0042ae5ab6d349c8b25f4e50726787d306a91]

add_file "test/extra/buildbot/master.cfg"
 content [279250eed8a67dd4e2bce8349c8c4a7b6376e69d]

add_file "test/extra/buildbot/run-buildbot.sh"
 content [d8dabcc56a8ceef2db975b80fa76ce6c2316fda4]

patch "extra/mtn-hooks/monotone-buildbot.lua"
 from [1dbe849872ba609599a09fc0c1bdc3006a5b072d]
   to [41d82aee6613c5d1775fd8ebf97ffd0c29ea807c]

  set "test/extra/buildbot/run-buildbot.sh"
 attr "mtn:execute"
value "true"
============================================================
--- contrib/monotone-buildbot-notification.lua	1dbe849872ba609599a09fc0c1bdc3006a5b072d
+++ extra/mtn-hooks/monotone-buildbot.lua	41d82aee6613c5d1775fd8ebf97ffd0c29ea807c
@@ -8,24 +8,26 @@
 -- 
 -- 0.1 (2007-07-10) Markus Schiltknecht <address@hidden>
 --     - initial version
+-- 0.2 (2011-03-11) Richard Levitte <address@hidden>
+--     - updated to have things more protected
 --
 -- License: GPL
 --
 ----------------------------------------------------------------------
 -- To configure this hooks, use the following variables:
 --
--- MBN_buildbot_bin	The buildbot binary.
+-- MB_buildbot_bin	The buildbot binary.
 --                      Defaults to "buildbot"
--- MBN_buildbot_master	The address:port to the buildbot master
+-- MB_buildbot_master	The address:port to the buildbot master
 --                      Defaults to "localhost:9989"
 --
 
 do
    local buildbot_bin = "buildbot"
-   if MBN_buildbot_bin then buildbot_bin = MBN_buildbot_bin end
+   if MB_buildbot_bin then buildbot_bin = MB_buildbot_bin end
 
    local buildbot_master = "localhost:9989"
-   if MBN_buildbot_master then buildbot_master = MBN_buildbot_master end
+   if MB_buildbot_master then buildbot_master = MB_buildbot_master end
    
    local notify_buildbot =
       function (rev_id, revision, certs)
@@ -75,7 +77,9 @@ do
 
    local old_node_commit = note_commit
    function note_commit (new_id, revision, certs)
-      old_note_commit(new_id, revision, certs)
+      if old_note_commit then
+	 old_note_commit(new_id, revision, certs)
+      end
       notify_buildbot(new_id, revision, certs)
    end
 
============================================================
--- /dev/null	
+++ test/extra/buildbot/__driver__.lua	af50ca47a8edc3bb98be59d65c8c29bb789bfaf0
@@ -0,0 +1,86 @@
+skip_if(not existsonpath("buildbot"))
+
+----- Set up a dumping buildbot that reacts directly on the commit.
+buildbot1_slave_port = tostring(math.random(1024,65535))
+buildbot1_result_file = "buildbot1.results.dat"
+mkdir("buildbot1")
+check({"buildbot", "create-master", "buildbot1"}, 0, false, false)
+get("run-buildbot.sh")		-- We use this to start the buildbot because it sets the needed
+				-- environment variables TEST_PORT and TEST_OUTPUT
+get("master.cfg", "buildbot1/master.cfg")
+
+----- Set up a dumping buildbot that reacts on the push.
+buildbot2_slave_port = tostring(math.random(1024,65535))
+buildbot2_result_file = "buildbot2.results.dat"
+mkdir("buildbot2")
+check({"buildbot", "create-master", "buildbot2"}, 0, false, false)
+get("run-buildbot.sh")		-- We use this to start the buildbot because it sets the needed
+				-- environment variables TEST_PORT and TEST_OUTPUT
+get("master.cfg", "buildbot2/master.cfg")
+
+----- Set up the hooks
+mtn_setup()
+append("test_hooks.lua", "\n\
+\n\
+includedirpattern(get_confdir() .. \"/hooks.d\",\"*.conf\")\n\
+includedirpattern(get_confdir() .. \"/hooks.d\",\"*.lua\")\n\
+")
+mkdir("hooks.d")
+check(copy(srcdir.."/../extra/mtn-hooks/monotone-buildbot.lua",
+	   "hooks.d/monotone-buildbot.lua"))
+writefile("hooks.d/monotone-buildbot.conf",
+	  "MB_buildbot_master = \"localhost:"..buildbot1_slave_port.."\"\n")
+
+includecommon("netsync.lua")
+netsync.setup()
+append("netsync.lua", "\n\
+\n\
+includedirpattern(get_confdir() .. \"/hooks-net.d\",\"*.conf\")\n\
+includedirpattern(get_confdir() .. \"/hooks-net.d\",\"*.lua\")\n\
+")
+mkdir("hooks-net.d")
+check(copy(srcdir.."/../extra/mtn-hooks/monotone-buildbot.lua",
+	   "hooks-net.d/monotone-buildbot.lua"))
+writefile("hooks-net.d/monotone-buildbot.conf",
+	  "MB_buildbot_master = \"localhost:"..buildbot2_slave_port.."\"\n")
+
+
+function protectedrun()
+   ----- Start all servers
+   check({"./run-buildbot.sh", "buildbot1", buildbot1_slave_port, buildbot1_result_file}, 0, false, false)
+   check({"./run-buildbot.sh", "buildbot2", buildbot2_slave_port, buildbot2_result_file}, 0, false, false)
+   srv = netsync.start(2)
+
+   ----- Now, just commit something
+   addfile("test1", "testing")
+   commit()
+
+   ----- And push
+   srv:push("testbranch",1)
+end
+
+b1,res1 = pcall(protectedrun)
+
+----- Stop all server processes
+protectedstops = {
+   function ()
+      srv:stop()
+   end,
+   function ()
+      check({"buildbot", "stop", "buildbot1"}, 0, false, false)
+   end,
+   function ()
+      check({"buildbot", "stop", "buildbot2"}, 0, false, false)
+   end
+}
+
+for _,f in pairs(protectedstops) do
+   b2,res2 = pcall(f)
+end
+
+check(b1)
+
+----- Check all results
+get("expected.result.dat")
+check(samefile(buildbot1_result_file, "expected.result.dat"), 0, false, false)
+check(samefile(buildbot2_result_file, "expected.result.dat"), 0, false, false)
============================================================
--- /dev/null	
+++ test/extra/buildbot/expected.result.dat	69c0042ae5ab6d349c8b25f4e50726787d306a91
@@ -0,0 +1 @@
+['address@hidden', 'testbranch', '6cc0b3a6ed2cacaa05fa887dfb545bca03060f5f', 'blah-blah\n\n', (' test1 ',)]
============================================================
--- /dev/null	
+++ test/extra/buildbot/master.cfg	279250eed8a67dd4e2bce8349c8c4a7b6376e69d
@@ -0,0 +1,61 @@
+# -*- python -*-
+
+# this isn't a normal buildbot master.cfg, it's quite the hack.  All we
+# want from it is that it dumps the content recieved by a 'buildbot
+# sendchange' to stdout, so we need a hacked version of PBChangeSource
+# and that's all.
+
+import os
+test_output = os.environ.get("TEST_OUTPUT")
+test_port = int(os.environ.get("TEST_PORT"))
+
+from buildbot.changes import pb
+from twisted.python import log
+
+class DumpPerspective(pb.ChangePerspective):
+    def perspective_addChange(self, changedict):
+        log.msg("perspective_addChange called")
+        interesting_changes=[
+            changedict["who"],
+            changedict["branch"],
+            changedict["revision"],
+            changedict["comments"],
+            changedict["files"]
+            ]
+        with open(test_output, "wb") as f:
+            print >> f, interesting_changes
+        pb.ChangePerspective.perspective_addChange(self, changedict)
+
+class DumpChangeSource(pb.PBChangeSource):
+    def describe(self):
+        return "DumpChangeSource listener on all-purpose slaveport, for testing"
+    def getPerspective(self, mind=None, username=None):
+        return DumpPerspective(self.parent, self.prefix)
+
+c = BuildmasterConfig = {}
+c["change_source"] = DumpChangeSource()
+
+# Standard minimal stuff
+c['slaves'] = []
+c['slavePortnum'] = test_port
+c['schedulers'] = []
+c['builders'] = []
+
+from buildbot.buildslave import BuildSlave
+c['slaves'] = [BuildSlave("example-slave", "pass")]
+
+from buildbot.scheduler import Scheduler
+c['schedulers'].append(Scheduler(name="all", branch=None,
+                                 treeStableTimer=None,
+                                 builderNames=["runtests"]))
+
+from buildbot.process.factory import BuildFactory
+from buildbot.steps.shell import ShellCommand
+factory = BuildFactory()
+factory.addStep(ShellCommand(command=["echo"]))
+
+from buildbot.config import BuilderConfig
+c['builders'].append(BuilderConfig(name="runtests",
+                                   slavenames=["example-slave"],
+                                   factory=factory))
+
============================================================
--- /dev/null	
+++ test/extra/buildbot/run-buildbot.sh	d8dabcc56a8ceef2db975b80fa76ce6c2316fda4
@@ -0,0 +1,8 @@
+#! /bin/sh -x
+
+dir="$1"
+TEST_PORT=$2
+TEST_OUTPUT="`pwd`/$3"
+export TEST_PORT TEST_OUTPUT
+
+buildbot start "$dir"

reply via email to

[Prev in Thread] Current Thread [Next in Thread]