[Libreoffice-commits] buildbot.git: tb3/dist-packages tb3/tb3 tb3/tb3-local-client tb3/tests

Bjoern Michaelsen bjoern.michaelsen at canonical.com
Mon Jul 29 03:37:37 PDT 2013


 tb3/dist-packages/tb3/scheduler.py |    8 +++---
 tb3/tb3                            |    8 ++++--
 tb3/tb3-local-client               |   48 ++++++++++++++++++++++++-------------
 tb3/tests/tb3-local-client.py      |    4 ---
 4 files changed, 43 insertions(+), 25 deletions(-)

New commits:
commit e7d91008a894d3e912674f19527ea18e6dc9f53b
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Mon Jul 29 12:36:56 2013 +0200

    multiple source support

diff --git a/tb3/dist-packages/tb3/scheduler.py b/tb3/dist-packages/tb3/scheduler.py
index c2164ba..6fb7505 100644
--- a/tb3/dist-packages/tb3/scheduler.py
+++ b/tb3/dist-packages/tb3/scheduler.py
@@ -14,10 +14,10 @@ import functools
 import datetime
 
 class Proposal:
-    def __init__(self, score, commit, scheduler, platform, branch):
-        (self.score, self.commit, self.scheduler, self.platform, self.branch) = (score, commit, scheduler, platform, branch)
+    def __init__(self, score, commit, scheduler, platform, repo, branch):
+        (self.score, self.commit, self.scheduler, self.platform, self.repo, self.branch) = (score, commit, scheduler, platform, repo, branch)
     def __repr__(self):
-        return 'Proposal(%f, %s, %s, %s, %s)' % (self.score, self.commit, self.scheduler, self.platform, self.branch)
+        return 'Proposal(%f, %s, %s, %s, %s, %s)' % (self.score, self.commit, self.scheduler, self.platform, self.repo, self.branch)
     def __cmp__(self, other):
         return other.score - self.score
 
@@ -30,7 +30,7 @@ class Scheduler:
         self.repohistory = tb3.repostate.RepoHistory(self.platform, self.repo)
         self.git = sh.git.bake(_cwd=repo)
     def make_proposal(self, score, commit):
-        return Proposal(score, commit, self.__class__.__name__, self.platform, self.branch)
+        return Proposal(score, commit, self.__class__.__name__, self.platform, self.repo, self.branch)
     def count_commits(self, start, to):
         return int(self.git('rev-list', '%s..%s' % (start, to), count=True))
     def get_commits(self, begin, end):
diff --git a/tb3/tb3 b/tb3/tb3
index 10ccf6f..850906b 100755
--- a/tb3/tb3
+++ b/tb3/tb3
@@ -105,8 +105,8 @@ if __name__ == '__main__':
     else:
         fullcommand = True
     parser.add_argument('--repo', help='location of the LibreOffice core git repository', required=True)
-    parser.add_argument('--platform', help='platform for which coordination is requested', required=True)
-    parser.add_argument('--branch', help='branch for which coordination is requested', required=True)
+    parser.add_argument('--platform', help='platform for which coordination is requested')
+    parser.add_argument('--branch', help='branch for which coordination is requested')
     parser.add_argument('--builder', help='name of the build machine interacting with the coordinator (required for --set-commit-finished and --set-commit-running)')
     if fullcommand:
         parser.add_argument('--sync', help='syncs the repository from its origin', action='store_true')
@@ -131,6 +131,10 @@ if __name__ == '__main__':
     if not args.has_key('builder') and (args.has_key('set_commit_running') or args.has_key('set_commit_finished')):
         parser.print_help()
         sys.exit(1)
+    if args.has_key('set_commit_finished') or args.has_key('set_commit_running') or args.has_key('show_state') or args.has_key('show_history') or args.has_key('show_proposals'):
+        if not (args.has_key('branch') and args.has_key('platform')):
+            parser.print_help()
+            sys.exit(1)
     if not fullcommand:
         args['sync'] = commandname == 'tb3-sync'
         args['show_proposals'] = commandname == 'tb3-show-proposals'
diff --git a/tb3/tb3-local-client b/tb3/tb3-local-client
index 16a7b1f..ec98060 100755
--- a/tb3/tb3-local-client
+++ b/tb3/tb3-local-client
@@ -16,22 +16,32 @@ import time
 
 sys.path.append('./dist-packages')
 
+class ProposalSource:
+    def __init__(self, repo, branch, platform, head_weight, bisect_weight):
+        self.repo = repo
+        self.branch = branch
+        self.platform = platform
+        self.head_weight = head_weight
+        self.bisect_weight = bisect_weight
+
 class LocalClient:
+    def parse_source(self, source_data):
+        return ProposalSource(source_data[0], source_data[1], source_data[2], float(source_data[3]), float(source_data[4]))
+    def parse_sources(self, sources_data):
+        return [self.parse_source(source_data) for source_data in sources_data]
     def __init__(self, args):
         self.args = args
+        self.sources = self.parse_sources(self.args['proposal_source'])
+        self.repos = set( (source.repo for source in self.sources) )
         self.tb3 = sh.Command.bake(
             sh.Command(self.args['tb3_master']),
-            repo=self.args['repo'],
-            platform=self.args['platform'],
-            branch=self.args['branch'],
             builder=self.args['builder'],
             format='json')
         self.logdir = self.args['logdir']
         self.workdir = tempfile.mkdtemp()
-    def get_proposal(self):
+    def get_proposal(self, source):
         data = ''
-        self.tb3(sync=True)
-        for line in self.tb3(show_proposals=True):
+        for line in self.tb3(repo=source.repo, branch=source.branch, platform=source.platform, show_proposals=True):
             data+=line
         proposals = json.loads(data)
         if len(proposals)>0:
@@ -39,7 +49,7 @@ class LocalClient:
         else:
             return None
     def report_start(self, proposal):
-        self.tb3(set_commit_running=proposal['commit'])
+        self.tb3(repo=proposal['repo'], branch=proposal['branch'], platform=proposal['platform'], set_commit_running=proposal['commit'])
     def run_build(self, proposal):
         buildtime = int(time.time()*100)
         if self.logdir:
@@ -49,8 +59,8 @@ class LocalClient:
         command = sh.Command(self.args['script'])
         rc = command(
             proposal['commit'],
-            self.args['repo'],
-            self.args['platform'],
+            proposal['repo'],
+            proposal['platform'],
             self.args['builder'],
             self.workdir,
             _err=outfile,
@@ -60,15 +70,23 @@ class LocalClient:
             return ('good', os.path.basename(outfile))
         return ('bad', os.path.basename(outfile))
     def report_result(self, proposal, result):
-        self.tb3(set_commit_finished=proposal['commit'], result=result[0], result_reference=result[1])
+        self.tb3(repo=proposal['repo'], branch=proposal['branch'], platform=proposal['platform'], set_commit_finished=proposal['commit'], result=result[0], result_reference=result[1])
     def __one_run(self):
         proposal = None
         while not proposal:
-            proposal = self.get_proposal()
-            print proposal
+            for repo in self.repos:
+                self.tb3(repo=repo, sync=True)
+            proposals = [self.get_proposal(source) for source in self.sources]
+            for p in proposals:
+                if p and (not proposal or p.score > proposal.score):
+                    proposal = p
             if not proposal or float(proposal['score']) < self.args['min_score']:
                 time.sleep(self.args['poll_idle_time'])
-        self.report_start(proposal)
+        print proposal
+        try:
+            self.report_start(proposal)
+        except Exception as e:
+            print "except %s" % e
         result = self.run_build(proposal)
         self.report_result(proposal, result)
     def execute(self):
@@ -82,9 +100,7 @@ class LocalClient:
 if __name__ == '__main__':
     parser = argparse.ArgumentParser(description='local tinderbox runner')
     parser.add_argument('--tb3-master', help='the path to the tb3 executable', required=True)
-    parser.add_argument('--repo', help='location of the LibreOffice core git repository', required=True)
-    parser.add_argument('--platform', help='platform for which coordination is requested', required=True)
-    parser.add_argument('--branch', help='branch for which coordination is requested', required=True)
+    parser.add_argument('--proposal-source', help='where to get proposals from', required=True, nargs=5, metavar=('REPO', 'BRANCH', 'PLATFORM', 'HEAD_MULTIPLIER', 'BIBISECT_MULTIPLIER'), action='append')
     parser.add_argument('--builder', help='name of the build machine interacting with the coordinator', required=True)
     parser.add_argument('--script', help='path to the build script', required=True)
     parser.add_argument('--logdir', help='path to the to store the logs', default=None)
diff --git a/tb3/tests/tb3-local-client.py b/tb3/tests/tb3-local-client.py
index 2ad3a59..64e1c0f 100755
--- a/tb3/tests/tb3-local-client.py
+++ b/tb3/tests/tb3-local-client.py
@@ -28,9 +28,7 @@ class TestTb3LocalClient(unittest.TestCase):
         (self.testdir, self.git) = helpers.createTestRepo()
         self.logdir = tempfile.mkdtemp()
         self.tb3localclient = sh.Command.bake(sh.Command("tb3-local-client"),
-            repo=self.testdir,
-            branch=self.branch,
-            platform=self.platform,
+            '--proposal-source', self.testdir, self.branch, self.platform, 1, 1,
             builder=self.builder,
             tb3_master='./tb3',
             script='./tests/build-script.sh',


More information about the Libreoffice-commits mailing list