From 959f5dfdceddd3f7ce0cfb5ba734f5e167be4846 Mon Sep 17 00:00:00 2001 From: Maciej Szymanski <maszyman@cern.ch> Date: Fri, 16 Dec 2016 11:06:12 +0100 Subject: [PATCH 1/8] added script to receive the message about done builds and producing the file for the jenkins job launching the tests --- python/LbMsg/BuildMsg.py | 9 +- python/LbPeriodicTools/LbPeriodicStarter.py | 7 +- scripts/lbp-check-periodic-tests-msg | 119 ++++++++++++++++++++ 3 files changed, 128 insertions(+), 7 deletions(-) create mode 100755 scripts/lbp-check-periodic-tests-msg diff --git a/python/LbMsg/BuildMsg.py b/python/LbMsg/BuildMsg.py index bc27b781..ce251bf3 100644 --- a/python/LbMsg/BuildMsg.py +++ b/python/LbMsg/BuildMsg.py @@ -38,7 +38,7 @@ class NightliesMessenger(Messenger): Sends the message that a particular project has been built ''' self._basicPublish(".".join([slot, project, config]), - json.dumps([slot, project, config, buildId])) + json.dumps([{'slot':slot, 'project':project, 'platform':config, 'build_id':buildId}])) def getBuildsDone(self, queueName=None, bindingKeys=None): @@ -47,7 +47,7 @@ class NightliesMessenger(Messenger): ''' def callback(ch, method, properties, body): print("%r\t%r" % (method.routing_key, body)) - + buildsDone = [] with self._getConnection() as connection: (channel, queueName) = self._setupClientChannel(connection.channel(), queueName, bindingKeys) @@ -55,9 +55,10 @@ class NightliesMessenger(Messenger): method_frame, header_frame, body = channel.basic_get(queue=queueName) if method_frame == None: break - print method_frame.routing_key, body + print method_frame.routing_key, json.loads(body) + buildsDone.append(json.loads(body)[0]) channel.basic_ack(method_frame.delivery_tag) - + return buildsDone def consumeBuildsDone(self, callback, queueName=None, bindingKeys=None): ''' diff --git a/python/LbPeriodicTools/LbPeriodicStarter.py b/python/LbPeriodicTools/LbPeriodicStarter.py index 409ce1c6..66ef1da6 100644 --- a/python/LbPeriodicTools/LbPeriodicStarter.py +++ b/python/LbPeriodicTools/LbPeriodicStarter.py @@ -68,9 +68,10 @@ class PeriodicTestStarter (object): alltests = PeriodicTestSchedule(schedule_filename) # Select the tests to be run at the date - to_run = alltests.getTests(lambda x: - x.isForDate(self._testdatetime, - self._testdatetime_end)) + if testperiod < 0: + to_run = alltests.getTests(None) + else: + to_run = alltests.getTests(lambda x: x.isForDate(self._testdatetime, self._testdatetime_end)) __log__.info("Found %d tests schedule to be run." % len(to_run)) for test in to_run: __log__.info(str(test)) diff --git a/scripts/lbp-check-periodic-tests-msg b/scripts/lbp-check-periodic-tests-msg new file mode 100755 index 00000000..f62764e2 --- /dev/null +++ b/scripts/lbp-check-periodic-tests-msg @@ -0,0 +1,119 @@ +#!/usr/bin/env python +############################################################################### +# (c) Copyright 2013 CERN # +# # +# This software is distributed under the terms of the GNU General Public # +# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # +# # +# In applying this licence, CERN does not waive the privileges and immunities # +# granted to it by virtue of its status as an Intergovernmental Organization # +# or submit itself to any jurisdiction. # +############################################################################### +from LbNightlyTools.Utils import JenkinsTest +''' +Simple script to check which tests should be run for a given date + +''' +__author__ = 'Ben Couturier <ben.couturier@cern.ch>' + +import datetime +import json +import logging +import sys +import fnmatch +from LbNightlyTools.Scripts.Common import PlainScript +from LbPeriodicTools.LbPeriodicStarter import PeriodicTestStarter +import LbMsg.BuildMsg + +class Script(PlainScript): + ''' + Script to print the list of tests to run on a given day, + based on the config specified + ''' + __usage__ = '%prog [options] <config.json>' + __version__ = '' + + def defineOpts(self): + '''Define options.''' + from LbNightlyTools.Scripts.Common import addBasicOptions + self.parser.add_option('-o', '--output', action='store', + help='output file format ' + '[default: test-params-{0}.txt]', + default='test-params-{0}.txt') + self.parser.add_option('-d', '--date', action='store', + help='Date for the tests ' + 'Format: YYYY-MM-dd HH:MM [default: today]') + self.parser.add_option('-i', '--interval', action='store', + help='Interval for test checks in seconds ' + '[default: 60s]', default="60") + self.parser.add_option('-q', '--queue', + default=None, + help='Name of the (persistent) queue to store the messages') + self.parser.add_option('-b', '--bindings', + default=None, + help='Message bindings for this channel') + self.parser.add_option('-c', '--consume', + action="store_true", + default=False, + help='Wait and loop on all messages coming from the server') + + addBasicOptions(self.parser) + + + def main(self): + ''' + Main function of the script. + ''' + + # Checking we did pass an argument + if len(self.args) < 1: + self.parser.error('Please specify config file') + + config_file = self.args[0] + + # # Checking the date at which to run + opts = self.options + testdate = datetime.datetime.today() + + queueName = None + if self.options.queue: + queueName = self.options.queue + + binds = None + if self.options.bindings: + binds = [ self.options.bindings ] + + msg = LbMsg.BuildMsg.NightliesMessenger() + if self.options.consume: + def callback(ch, method, properties, body): + print(" [x] %r:%r" % (method.routing_key, body)) + msg.consumeBuildsDone(callback, queueName, binds) + else: + if queueName == None: + raise Exception("No point in just getting messages on a newly created queue. Name the queue with -q or use -c instead") + buildsDone = msg.getBuildsDone(queueName, binds) + + # Checking which jobs to run + starter = PeriodicTestStarter(config_file, + testdate.strftime('%Y-%m-%d %H:%M:%S'), + -1) + all_tests = starter.getAllTests() + tests_to_run = [] + idx = 0 + for (test_template, test_list) in all_tests: + for test_instance in test_list: + for build in buildsDone: + if test_instance.slot == build['slot']\ + and test_instance.project == build['project']\ + and fnmatch.fnmatch(build['platform'], test_instance.platform): + test_instance.build_id = build['build_id'] + tests_to_run.append(test_instance) + print test_instance + jenkins_test = JenkinsTest.fromScheduledTest(test_instance) + with open(opts.output.format(idx), 'w') as paramfile: + paramfile.writelines(jenkins_test.getParameterLines()) + self.log.warning(opts.output.format(idx)) + idx += 1 + +# __main__ +sys.exit(Script().run()) -- GitLab From 0724d9202e37b538945e7e0bdc4722176a5327bf Mon Sep 17 00:00:00 2001 From: Maciej Szymanski <maszyman@cern.ch> Date: Tue, 10 Jan 2017 15:01:11 +0100 Subject: [PATCH 2/8] added script for jenkins to read messages --- jenkins/periodic-tests/tests-pollqueue.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/jenkins/periodic-tests/tests-pollqueue.sh b/jenkins/periodic-tests/tests-pollqueue.sh index 4948dd7e..dfe6891b 100755 --- a/jenkins/periodic-tests/tests-pollqueue.sh +++ b/jenkins/periodic-tests/tests-pollqueue.sh @@ -12,7 +12,15 @@ . $(dirname $0)/../utils.sh -set_common --build +set_common -lbq-getteststorun -q JenkinsPeriodic -j +# ensure that we do not use stale configuration files +# (unless we are testing with jenkins/mock.sh) +if [ "${JENKINS_MOCK}" != true ] ; then + rm -rf configs +fi +# checkout configs only if missing +[ -e configs ] || lbn-get-configs + +lbp-check-periodic-tests-msg configs/test_schedule2.xml -q PeriodicJenkins -- GitLab From 2a53376076fe9d36c34d37e512eeca953a8748f8 Mon Sep 17 00:00:00 2001 From: Maciej Szymanski <maszyman@cern.ch> Date: Fri, 16 Dec 2016 11:06:12 +0100 Subject: [PATCH 3/8] added script to receive the message about done builds and producing the file for the jenkins job launching the tests --- python/LbMsg/BuildMsg.py | 9 +- python/LbPeriodicTools/LbPeriodicStarter.py | 7 +- scripts/lbp-check-periodic-tests-msg | 119 ++++++++++++++++++++ 3 files changed, 128 insertions(+), 7 deletions(-) create mode 100755 scripts/lbp-check-periodic-tests-msg diff --git a/python/LbMsg/BuildMsg.py b/python/LbMsg/BuildMsg.py index bc27b781..ce251bf3 100644 --- a/python/LbMsg/BuildMsg.py +++ b/python/LbMsg/BuildMsg.py @@ -38,7 +38,7 @@ class NightliesMessenger(Messenger): Sends the message that a particular project has been built ''' self._basicPublish(".".join([slot, project, config]), - json.dumps([slot, project, config, buildId])) + json.dumps([{'slot':slot, 'project':project, 'platform':config, 'build_id':buildId}])) def getBuildsDone(self, queueName=None, bindingKeys=None): @@ -47,7 +47,7 @@ class NightliesMessenger(Messenger): ''' def callback(ch, method, properties, body): print("%r\t%r" % (method.routing_key, body)) - + buildsDone = [] with self._getConnection() as connection: (channel, queueName) = self._setupClientChannel(connection.channel(), queueName, bindingKeys) @@ -55,9 +55,10 @@ class NightliesMessenger(Messenger): method_frame, header_frame, body = channel.basic_get(queue=queueName) if method_frame == None: break - print method_frame.routing_key, body + print method_frame.routing_key, json.loads(body) + buildsDone.append(json.loads(body)[0]) channel.basic_ack(method_frame.delivery_tag) - + return buildsDone def consumeBuildsDone(self, callback, queueName=None, bindingKeys=None): ''' diff --git a/python/LbPeriodicTools/LbPeriodicStarter.py b/python/LbPeriodicTools/LbPeriodicStarter.py index 409ce1c6..66ef1da6 100644 --- a/python/LbPeriodicTools/LbPeriodicStarter.py +++ b/python/LbPeriodicTools/LbPeriodicStarter.py @@ -68,9 +68,10 @@ class PeriodicTestStarter (object): alltests = PeriodicTestSchedule(schedule_filename) # Select the tests to be run at the date - to_run = alltests.getTests(lambda x: - x.isForDate(self._testdatetime, - self._testdatetime_end)) + if testperiod < 0: + to_run = alltests.getTests(None) + else: + to_run = alltests.getTests(lambda x: x.isForDate(self._testdatetime, self._testdatetime_end)) __log__.info("Found %d tests schedule to be run." % len(to_run)) for test in to_run: __log__.info(str(test)) diff --git a/scripts/lbp-check-periodic-tests-msg b/scripts/lbp-check-periodic-tests-msg new file mode 100755 index 00000000..f62764e2 --- /dev/null +++ b/scripts/lbp-check-periodic-tests-msg @@ -0,0 +1,119 @@ +#!/usr/bin/env python +############################################################################### +# (c) Copyright 2013 CERN # +# # +# This software is distributed under the terms of the GNU General Public # +# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # +# # +# In applying this licence, CERN does not waive the privileges and immunities # +# granted to it by virtue of its status as an Intergovernmental Organization # +# or submit itself to any jurisdiction. # +############################################################################### +from LbNightlyTools.Utils import JenkinsTest +''' +Simple script to check which tests should be run for a given date + +''' +__author__ = 'Ben Couturier <ben.couturier@cern.ch>' + +import datetime +import json +import logging +import sys +import fnmatch +from LbNightlyTools.Scripts.Common import PlainScript +from LbPeriodicTools.LbPeriodicStarter import PeriodicTestStarter +import LbMsg.BuildMsg + +class Script(PlainScript): + ''' + Script to print the list of tests to run on a given day, + based on the config specified + ''' + __usage__ = '%prog [options] <config.json>' + __version__ = '' + + def defineOpts(self): + '''Define options.''' + from LbNightlyTools.Scripts.Common import addBasicOptions + self.parser.add_option('-o', '--output', action='store', + help='output file format ' + '[default: test-params-{0}.txt]', + default='test-params-{0}.txt') + self.parser.add_option('-d', '--date', action='store', + help='Date for the tests ' + 'Format: YYYY-MM-dd HH:MM [default: today]') + self.parser.add_option('-i', '--interval', action='store', + help='Interval for test checks in seconds ' + '[default: 60s]', default="60") + self.parser.add_option('-q', '--queue', + default=None, + help='Name of the (persistent) queue to store the messages') + self.parser.add_option('-b', '--bindings', + default=None, + help='Message bindings for this channel') + self.parser.add_option('-c', '--consume', + action="store_true", + default=False, + help='Wait and loop on all messages coming from the server') + + addBasicOptions(self.parser) + + + def main(self): + ''' + Main function of the script. + ''' + + # Checking we did pass an argument + if len(self.args) < 1: + self.parser.error('Please specify config file') + + config_file = self.args[0] + + # # Checking the date at which to run + opts = self.options + testdate = datetime.datetime.today() + + queueName = None + if self.options.queue: + queueName = self.options.queue + + binds = None + if self.options.bindings: + binds = [ self.options.bindings ] + + msg = LbMsg.BuildMsg.NightliesMessenger() + if self.options.consume: + def callback(ch, method, properties, body): + print(" [x] %r:%r" % (method.routing_key, body)) + msg.consumeBuildsDone(callback, queueName, binds) + else: + if queueName == None: + raise Exception("No point in just getting messages on a newly created queue. Name the queue with -q or use -c instead") + buildsDone = msg.getBuildsDone(queueName, binds) + + # Checking which jobs to run + starter = PeriodicTestStarter(config_file, + testdate.strftime('%Y-%m-%d %H:%M:%S'), + -1) + all_tests = starter.getAllTests() + tests_to_run = [] + idx = 0 + for (test_template, test_list) in all_tests: + for test_instance in test_list: + for build in buildsDone: + if test_instance.slot == build['slot']\ + and test_instance.project == build['project']\ + and fnmatch.fnmatch(build['platform'], test_instance.platform): + test_instance.build_id = build['build_id'] + tests_to_run.append(test_instance) + print test_instance + jenkins_test = JenkinsTest.fromScheduledTest(test_instance) + with open(opts.output.format(idx), 'w') as paramfile: + paramfile.writelines(jenkins_test.getParameterLines()) + self.log.warning(opts.output.format(idx)) + idx += 1 + +# __main__ +sys.exit(Script().run()) -- GitLab From 32d14059825d8a332a0f4c1b320febd1767e632f Mon Sep 17 00:00:00 2001 From: Maciej Szymanski <maszyman@cern.ch> Date: Tue, 10 Jan 2017 15:01:11 +0100 Subject: [PATCH 4/8] added script for jenkins to read messages --- jenkins/periodic-tests/tests-pollqueue.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/jenkins/periodic-tests/tests-pollqueue.sh b/jenkins/periodic-tests/tests-pollqueue.sh index 4948dd7e..dfe6891b 100755 --- a/jenkins/periodic-tests/tests-pollqueue.sh +++ b/jenkins/periodic-tests/tests-pollqueue.sh @@ -12,7 +12,15 @@ . $(dirname $0)/../utils.sh -set_common --build +set_common -lbq-getteststorun -q JenkinsPeriodic -j +# ensure that we do not use stale configuration files +# (unless we are testing with jenkins/mock.sh) +if [ "${JENKINS_MOCK}" != true ] ; then + rm -rf configs +fi +# checkout configs only if missing +[ -e configs ] || lbn-get-configs + +lbp-check-periodic-tests-msg configs/test_schedule2.xml -q PeriodicJenkins -- GitLab From d87b9ad0b8272edbdf5f2a92f7c5f2448ef2e1a9 Mon Sep 17 00:00:00 2001 From: Maciej Szymanski <maszyman@cern.ch> Date: Wed, 11 Jan 2017 18:13:44 +0100 Subject: [PATCH 5/8] sending the message that builds are ready added to the nightlies script --- python/LbNightlyTools/Scripts/Common.py | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/python/LbNightlyTools/Scripts/Common.py b/python/LbNightlyTools/Scripts/Common.py index 1dcb97cf..e965e960 100644 --- a/python/LbNightlyTools/Scripts/Common.py +++ b/python/LbNightlyTools/Scripts/Common.py @@ -523,6 +523,33 @@ class DashboardUpdate2(object): else: self.project_test_started(msg) +class PeriodicTestMsg(object): + ''' + Handles sending the message to the queue of ready builds for the periodic tests. + ''' + def __init__(self, script): + self.slot = script.slot + self.platform = script.platform + self.log = logging.getLogger('PeriodicTestMsg') + + def builds_ready(self, msg): + ''' + sends the message that builds are ready + ''' + import LbMsg.BuildMsg + self.log.debug('sending the message to the queue that builds are ready for slot: %s, project: %s, platform: %s, build_id: %s', self.slot.name, msg['project'].name, self.platform, self.slot.build_id) + build_msg = LbMsg.BuildMsg.NightliesMessenger() + build_msg.sendBuildDone(self.slot.name, msg['project'].name, self.platform, self.slot.build_id) + + def accept(self, msg): + ''' + Implements the receiver side of the message protocol. + ''' + msg_type = msg.get('type', '') + + if msg_type == 'ready.artifacts.build': + self.builds_done(msg) + class BaseScript(PlainScript): ''' @@ -550,6 +577,7 @@ class BaseScript(PlainScript): if hasattr(self.options, 'submit'): self.receivers.append(DashboardUpdate(self)) self.receivers.append(DashboardUpdate2(self)) + self.receivers.append(PeriodicTestMsg(self)) def _setup(self, build_dir=None, json_type=None, make_dirs=True): ''' -- GitLab From 419c3128c4a88c07079f2a5014f25ec39c27c790 Mon Sep 17 00:00:00 2001 From: Maciej Szymanski <maszyman@cern.ch> Date: Thu, 12 Jan 2017 09:34:53 +0100 Subject: [PATCH 6/8] fix the name of the function to call --- python/LbNightlyTools/Scripts/Common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/LbNightlyTools/Scripts/Common.py b/python/LbNightlyTools/Scripts/Common.py index e965e960..857fb9d3 100644 --- a/python/LbNightlyTools/Scripts/Common.py +++ b/python/LbNightlyTools/Scripts/Common.py @@ -548,7 +548,7 @@ class PeriodicTestMsg(object): msg_type = msg.get('type', '') if msg_type == 'ready.artifacts.build': - self.builds_done(msg) + self.builds_ready(msg) class BaseScript(PlainScript): -- GitLab From b56e4e068e6b20b81cdfc9bec898ccdbe1becb02 Mon Sep 17 00:00:00 2001 From: Maciej Szymanski <maszyman@cern.ch> Date: Thu, 12 Jan 2017 15:00:14 +0100 Subject: [PATCH 7/8] keeping lines below 80 chars --- python/LbMsg/BuildMsg.py | 16 ++++---- python/LbNightlyTools/Scripts/Common.py | 13 +++++-- python/LbPeriodicTools/LbPeriodicStarter.py | 4 +- scripts/lbp-check-periodic-tests-msg | 43 ++++++++++++--------- 4 files changed, 45 insertions(+), 31 deletions(-) diff --git a/python/LbMsg/BuildMsg.py b/python/LbMsg/BuildMsg.py index ce251bf3..2d1f035f 100644 --- a/python/LbMsg/BuildMsg.py +++ b/python/LbMsg/BuildMsg.py @@ -33,12 +33,14 @@ class NightliesMessenger(Messenger): self._topic_name = "topic.build_ready" - def sendBuildDone(self, slot, project, config, buildId, date=datetime.datetime.now()): + def sendBuildDone(self, slot, project, config, + buildId, date=datetime.datetime.now()): ''' Sends the message that a particular project has been built ''' self._basicPublish(".".join([slot, project, config]), - json.dumps([{'slot':slot, 'project':project, 'platform':config, 'build_id':buildId}])) + json.dumps([{'slot':slot,'project':project, + 'platform':config,'build_id':buildId}])) def getBuildsDone(self, queueName=None, bindingKeys=None): @@ -49,10 +51,10 @@ class NightliesMessenger(Messenger): print("%r\t%r" % (method.routing_key, body)) buildsDone = [] with self._getConnection() as connection: - (channel, queueName) = self._setupClientChannel(connection.channel(), - queueName, bindingKeys) + (channel,queueName)=self._setupClientChannel(connection.channel(), + queueName,bindingKeys) while True: - method_frame, header_frame, body = channel.basic_get(queue=queueName) + method_frame,head_frame,body=channel.basic_get(queue=queueName) if method_frame == None: break print method_frame.routing_key, json.loads(body) @@ -69,8 +71,8 @@ class NightliesMessenger(Messenger): ''' with self._getConnection() as connection: - (channel, queueName) = self._setupClientChannel(connection.channel(), - queueName, bindingKeys) + (channel,queueName)=self._setupClientChannel(connection.channel(), + queueName,bindingKeys) channel.basic_consume(callback, queue=queueName, no_ack=True) diff --git a/python/LbNightlyTools/Scripts/Common.py b/python/LbNightlyTools/Scripts/Common.py index 857fb9d3..d1f71ebf 100644 --- a/python/LbNightlyTools/Scripts/Common.py +++ b/python/LbNightlyTools/Scripts/Common.py @@ -525,7 +525,8 @@ class DashboardUpdate2(object): class PeriodicTestMsg(object): ''' - Handles sending the message to the queue of ready builds for the periodic tests. + Handles sending the message to the queue + of ready builds for the periodic tests. ''' def __init__(self, script): self.slot = script.slot @@ -537,16 +538,20 @@ class PeriodicTestMsg(object): sends the message that builds are ready ''' import LbMsg.BuildMsg - self.log.debug('sending the message to the queue that builds are ready for slot: %s, project: %s, platform: %s, build_id: %s', self.slot.name, msg['project'].name, self.platform, self.slot.build_id) + self.log.debug('sending the message to the queue that builds ' + 'are ready for slot: %s, project: %s, platform: %s, ' + 'build_id: %s', self.slot.name, msg['project'].name, + self.platform, self.slot.build_id) build_msg = LbMsg.BuildMsg.NightliesMessenger() - build_msg.sendBuildDone(self.slot.name, msg['project'].name, self.platform, self.slot.build_id) + build_msg.sendBuildDone(self.slot.name, msg['project'].name, + self.platform, self.slot.build_id) def accept(self, msg): ''' Implements the receiver side of the message protocol. ''' msg_type = msg.get('type', '') - + if msg_type == 'ready.artifacts.build': self.builds_ready(msg) diff --git a/python/LbPeriodicTools/LbPeriodicStarter.py b/python/LbPeriodicTools/LbPeriodicStarter.py index 66ef1da6..32e19cd9 100644 --- a/python/LbPeriodicTools/LbPeriodicStarter.py +++ b/python/LbPeriodicTools/LbPeriodicStarter.py @@ -71,7 +71,9 @@ class PeriodicTestStarter (object): if testperiod < 0: to_run = alltests.getTests(None) else: - to_run = alltests.getTests(lambda x: x.isForDate(self._testdatetime, self._testdatetime_end)) + to_run = alltests.getTests(lambda x: + x.isForDate(self._testdatetime, + self._testdatetime_end)) __log__.info("Found %d tests schedule to be run." % len(to_run)) for test in to_run: __log__.info(str(test)) diff --git a/scripts/lbp-check-periodic-tests-msg b/scripts/lbp-check-periodic-tests-msg index f62764e2..c411f4c7 100755 --- a/scripts/lbp-check-periodic-tests-msg +++ b/scripts/lbp-check-periodic-tests-msg @@ -38,24 +38,26 @@ class Script(PlainScript): from LbNightlyTools.Scripts.Common import addBasicOptions self.parser.add_option('-o', '--output', action='store', help='output file format ' - '[default: test-params-{0}.txt]', + '[default: test-params-{0}.txt]', default='test-params-{0}.txt') self.parser.add_option('-d', '--date', action='store', help='Date for the tests ' - 'Format: YYYY-MM-dd HH:MM [default: today]') + 'Format: YYYY-MM-dd HH:MM [default: today]') self.parser.add_option('-i', '--interval', action='store', help='Interval for test checks in seconds ' - '[default: 60s]', default="60") + '[default: 60s]', default="60") self.parser.add_option('-q', '--queue', default=None, - help='Name of the (persistent) queue to store the messages') + help='Name of the (persistent) queue to ' + 'store the messages') self.parser.add_option('-b', '--bindings', default=None, help='Message bindings for this channel') self.parser.add_option('-c', '--consume', action="store_true", default=False, - help='Wait and loop on all messages coming from the server') + help='Wait and loop on all messages coming ' + 'from the server') addBasicOptions(self.parser) @@ -74,7 +76,7 @@ class Script(PlainScript): # # Checking the date at which to run opts = self.options testdate = datetime.datetime.today() - + queueName = None if self.options.queue: queueName = self.options.queue @@ -90,7 +92,9 @@ class Script(PlainScript): msg.consumeBuildsDone(callback, queueName, binds) else: if queueName == None: - raise Exception("No point in just getting messages on a newly created queue. Name the queue with -q or use -c instead") + raise Exception('No point in just getting messages ' + 'on a newly created queue. ' + 'Name the queue with -q or use -c instead') buildsDone = msg.getBuildsDone(queueName, binds) # Checking which jobs to run @@ -101,19 +105,20 @@ class Script(PlainScript): tests_to_run = [] idx = 0 for (test_template, test_list) in all_tests: - for test_instance in test_list: - for build in buildsDone: - if test_instance.slot == build['slot']\ - and test_instance.project == build['project']\ - and fnmatch.fnmatch(build['platform'], test_instance.platform): - test_instance.build_id = build['build_id'] - tests_to_run.append(test_instance) - print test_instance - jenkins_test = JenkinsTest.fromScheduledTest(test_instance) - with open(opts.output.format(idx), 'w') as paramfile: - paramfile.writelines(jenkins_test.getParameterLines()) + for test_tmp in test_list: + for build in buildsDone: + if test_tmp.slot == build['slot']\ + and test_tmp.project == build['project']\ + and fnmatch.fnmatch(build['platform'], + test_tmp.platform): + test_tmp.build_id = build['build_id'] + tests_to_run.append(test_tmp) + print test_tmp + jenkins_test = JenkinsTest.fromScheduledTest(test_tmp) + with open(opts.output.format(idx), 'w') as parfile: + parfile.writelines(jenkins_test.getParameterLines()) self.log.warning(opts.output.format(idx)) - idx += 1 + idx += 1 # __main__ sys.exit(Script().run()) -- GitLab From 095df7a019902e4d5029376cda10857abaa8184b Mon Sep 17 00:00:00 2001 From: Maciej Szymanski <maszyman@cern.ch> Date: Thu, 12 Jan 2017 15:07:16 +0100 Subject: [PATCH 8/8] fix indentation --- scripts/lbp-check-periodic-tests-msg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lbp-check-periodic-tests-msg b/scripts/lbp-check-periodic-tests-msg index c411f4c7..31888f77 100755 --- a/scripts/lbp-check-periodic-tests-msg +++ b/scripts/lbp-check-periodic-tests-msg @@ -118,7 +118,7 @@ class Script(PlainScript): with open(opts.output.format(idx), 'w') as parfile: parfile.writelines(jenkins_test.getParameterLines()) self.log.warning(opts.output.format(idx)) - idx += 1 + idx += 1 # __main__ sys.exit(Script().run()) -- GitLab