Giuseppe Lavagetto has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/363214 )
Change subject: Re-add support for defining threads from CI/cli ...................................................................... Re-add support for defining threads from CI/cli Change-Id: I7f00990e9c3e32fa4373e6ee712768d606d167ce --- M puppet_compiler/cli.py M puppet_compiler/controller.py M puppet_compiler/tests/test_controller.py M setup.py 4 files changed, 9 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/operations/software/puppet-compiler refs/changes/14/363214/1 diff --git a/puppet_compiler/cli.py b/puppet_compiler/cli.py index 6ebe084..d4b34d1 100644 --- a/puppet_compiler/cli.py +++ b/puppet_compiler/cli.py @@ -13,6 +13,7 @@ nodes = os.environ.get('NODES', None) job_id = int(os.environ.get('BUILD_NUMBER')) configfile = os.environ.get('PC_CONFIG', '/etc/puppet-compiler.conf') +nthreads = os.environ.get('NUM_THREADS', 2) def main(): @@ -37,7 +38,7 @@ _log.info("Working on change %d", change) c = controller.Controller(configfile, job_id, - change, nodes) + change, host_list=nodes, nthreads=nthreads) success = c.run() # If the run is marked as failed, exit with a non-zero exit code if not success: diff --git a/puppet_compiler/controller.py b/puppet_compiler/controller.py index 7fee062..9eaf592 100644 --- a/puppet_compiler/controller.py +++ b/puppet_compiler/controller.py @@ -22,7 +22,7 @@ class Controller(object): - def __init__(self, configfile, job_id, change_id, host_list=[]): + def __init__(self, configfile, job_id, change_id, host_list=[], nthreads=2): self.config = { # Url under which results will be found 'http_url': 'https://puppet-compiler.wmflabs.org/html', @@ -36,7 +36,8 @@ 'puppet_private': 'https://gerrit.wikimedia.org/r/labs/private', # Directory hosting all of puppet's runtime files usually # under /var/lib/puppet on debian-derivatives - 'puppet_var': '/var/lib/catalog-differ/puppet' + 'puppet_var': '/var/lib/catalog-differ/puppet', + 'pool_size': nthreads, } try: if configfile is not None: @@ -98,7 +99,7 @@ self.m.prepare() threadpool = threads.ThreadOrchestrator( - self.config.get('pool_size', 2)) + self.config['pool_size']) # For each host, the threadpool will execute # Controller._run_host with the host as the only argument. diff --git a/puppet_compiler/tests/test_controller.py b/puppet_compiler/tests/test_controller.py index c8171d3..c562d5b 100644 --- a/puppet_compiler/tests/test_controller.py +++ b/puppet_compiler/tests/test_controller.py @@ -11,7 +11,7 @@ cls.fixtures = os.path.join(os.path.dirname(__file__), 'fixtures') def test_initialize_no_configfile(self): - c = controller.Controller(None, 19, 224570, 'test.eqiad.wmnet') + c = controller.Controller(None, 19, 224570, 'test.eqiad.wmnet', nthreads=2) self.assertEquals(c.hosts, ['test.eqiad.wmnet']) self.assertEquals(c.config['http_url'], 'https://puppet-compiler.wmflabs.org/html') @@ -19,7 +19,7 @@ def test_parse_config(self): filename = os.path.join(self.fixtures, 'test_config.yaml') - c = controller.Controller(filename, 19, 224570, 'test.eqiad.wmnet') + c = controller.Controller(filename, 19, 224570, 'test.eqiad.wmnet', nthreads=2) self.assertEquals(len(c.config['test_non_existent']), 2) self.assertEquals(c.config['http_url'], 'http://www.example.com/garbagehere') diff --git a/setup.py b/setup.py index 53de09f..4849bbc 100755 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ #!/usr/bin/python +from functools import reduce import os from setuptools import setup, find_packages -- To view, visit https://gerrit.wikimedia.org/r/363214 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7f00990e9c3e32fa4373e6ee712768d606d167ce Gerrit-PatchSet: 1 Gerrit-Project: operations/software/puppet-compiler Gerrit-Branch: master Gerrit-Owner: Giuseppe Lavagetto <glavage...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits