Speed up builds by increasing threads for builds

Generally, OpenStack CI infrastructure workers will typically have
8 cores therefore by hardcoding the threads to 4, we miss out on
valuable CPU power that can speed up builds.

This patch sets the number of threads when running tests between
the higher number of 4 (original value) or the number of CPU cores.

Change-Id: I857507d08d91ddb5e0bccb118d15f2e2bcf4da99
This commit is contained in:
Mohammed Naser
2017-03-16 15:10:35 -04:00
parent ac1d2df3b8
commit 4f84f3d15c

View File

@@ -11,6 +11,7 @@
# under the License.
import abc
import multiprocessing
import os
import sys
@@ -34,7 +35,12 @@ class BuildTest(object):
super(BuildTest, self).setUp()
self.useFixture(log_fixture.SetLogLevel([__name__],
logging.logging.INFO))
self.build_args = [__name__, "--debug", '--threads', '4']
self.threads = multiprocessing.cpu_count()
if self.threads < 4:
self.threads = 4
self.build_args = [__name__, "--debug", '--threads', str(self.threads)]
@testtools.skipUnless(os.environ.get('DOCKER_BUILD_TEST'),
'Skip the docker build test')