Merge lp:~billy-olsen/charm-helpers/lp1602444 into lp:charm-helpers

Proposed by Billy Olsen
Status: Merged
Merged at revision: 604
Proposed branch: lp:~billy-olsen/charm-helpers/lp1602444
Merge into: lp:charm-helpers
Diff against target: 53 lines (+31/-1)
2 files modified
charmhelpers/contrib/openstack/context.py (+4/-1)
tests/contrib/openstack/test_os_contexts.py (+27/-0)
To merge this branch: bzr merge lp:~billy-olsen/charm-helpers/lp1602444
Reviewer Review Type Date Requested Status
David Ames (community) Approve
Review via email: mp+299880@code.launchpad.net
To post a comment you must log in.
Revision history for this message
David Ames (thedac) wrote :

Looks good to me. Merging.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'charmhelpers/contrib/openstack/context.py'
--- charmhelpers/contrib/openstack/context.py 2016-07-12 18:23:03 +0000
+++ charmhelpers/contrib/openstack/context.py 2016-07-12 23:06:41 +0000
@@ -1196,7 +1196,10 @@
11961196
1197 def __call__(self):1197 def __call__(self):
1198 multiplier = config('worker-multiplier') or 01198 multiplier = config('worker-multiplier') or 0
1199 ctxt = {"workers": self.num_cpus * multiplier}1199 count = int(self.num_cpus * multiplier)
1200 if multiplier > 0 and count == 0:
1201 count = 1
1202 ctxt = {"workers": count}
1200 return ctxt1203 return ctxt
12011204
12021205
12031206
=== modified file 'tests/contrib/openstack/test_os_contexts.py'
--- tests/contrib/openstack/test_os_contexts.py 2016-07-05 22:41:39 +0000
+++ tests/contrib/openstack/test_os_contexts.py 2016-07-12 23:06:41 +0000
@@ -2451,6 +2451,33 @@
2451 worker = context.WorkerConfigContext()2451 worker = context.WorkerConfigContext()
2452 self.assertTrue(worker.num_cpus, 2)2452 self.assertTrue(worker.num_cpus, 2)
24532453
2454 def test_workerconfig_context_float(self):
2455 self.config.side_effect = fake_config({
2456 'worker-multiplier': 0.3
2457 })
2458 with patch.object(context.WorkerConfigContext, 'num_cpus', 4):
2459 worker = context.WorkerConfigContext()
2460 self.assertTrue(worker.num_cpus, 1)
2461
2462 def test_workerconfig_context_not_quite_0(self):
2463 # Make sure that the multiplier evaluating to somewhere between
2464 # 0 and 1 in the floating point range still has at least one
2465 # worker.
2466 self.config.side_effect = fake_config({
2467 'worker-multiplier': 0.001
2468 })
2469 with patch.object(context.WorkerConfigContext, 'num_cpus', 100):
2470 worker = context.WorkerConfigContext()
2471 self.assertTrue(worker.num_cpus, 1)
2472
2473 def test_workerconfig_context_0(self):
2474 self.config.side_effect = fake_config({
2475 'worker-multiplier': 0
2476 })
2477 with patch.object(context.WorkerConfigContext, 'num_cpus', 2):
2478 worker = context.WorkerConfigContext()
2479 self.assertTrue(worker.num_cpus, 0)
2480
2454 def test_workerconfig_context_noconfig(self):2481 def test_workerconfig_context_noconfig(self):
2455 self.config.return_value = None2482 self.config.return_value = None
2456 with patch.object(context.WorkerConfigContext, 'num_cpus', 2):2483 with patch.object(context.WorkerConfigContext, 'num_cpus', 2):

Subscribers

People subscribed via source and target branches