Reduce upload threads in tests from 4 to 1

Only a single test actually depends on having more than a single
upload thread active, so this is just wasteful. Reduce the default
to 1 and add an option to useBuilder() that tests may use to alter
the value.

Change-Id: I07ec96000a81153b51b79bfb0daee1586491bcc5
This commit is contained in:
David Shrewsbury 2019-09-18 15:39:12 -04:00
parent 67bdd85425
commit 5c605b3240
2 changed files with 10 additions and 5 deletions

View File

@ -311,17 +311,20 @@ class BaseTestCase(testtools.TestCase):
class BuilderFixture(fixtures.Fixture):
def __init__(self, configfile, cleanup_interval, securefile=None):
def __init__(self, configfile, cleanup_interval, securefile=None,
super(BuilderFixture, self).__init__()
self.configfile = configfile
self.securefile = securefile
self.cleanup_interval = cleanup_interval
self.builder = None
self.num_uploaders = num_uploaders
def setUp(self):
super(BuilderFixture, self).setUp()
self.builder = builder.NodePoolBuilder(
self.configfile, secure_path=self.securefile)
self.configfile, secure_path=self.securefile,
self.builder.cleanup_interval = self.cleanup_interval
self.builder.build_interval = .1
self.builder.upload_interval = .1
@ -544,9 +547,11 @@ class DBTestCase(BaseTestCase):
return app
def useBuilder(self, configfile, securefile=None, cleanup_interval=.5):
def useBuilder(self, configfile, securefile=None, cleanup_interval=.5,
builder_fixture = self.useFixture(
BuilderFixture(configfile, cleanup_interval, securefile)
BuilderFixture(configfile, cleanup_interval, securefile,
return builder_fixture.builder

View File

@ -733,7 +733,7 @@ class TestLauncher(tests.DBTestCase):
"""Test that an image upload failure is contained."""
configfile = self.setup_config('node_upload_fail.yaml')
pool = self.useNodepool(configfile, watermark_sleep=1)
self.useBuilder(configfile, num_uploaders=2)
self.waitForImage('fake-provider2', 'fake-image')
nodes = self.waitForNodes('fake-label', 2)