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
changes/77/682977/1
David Shrewsbury 3 years ago
parent 67bdd85425
commit 5c605b3240
  1. 13
      nodepool/tests/__init__.py
  2. 2
      nodepool/tests/unit/test_launcher.py

@ -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,
num_uploaders=1):
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,
num_uploaders=self.num_uploaders)
self.builder.cleanup_interval = self.cleanup_interval
self.builder.build_interval = .1
self.builder.upload_interval = .1
@ -544,9 +547,11 @@ class DBTestCase(BaseTestCase):
self.addCleanup(app.stop)
return app
def useBuilder(self, configfile, securefile=None, cleanup_interval=.5):
def useBuilder(self, configfile, securefile=None, cleanup_interval=.5,
num_uploaders=1):
builder_fixture = self.useFixture(
BuilderFixture(configfile, cleanup_interval, securefile)
BuilderFixture(configfile, cleanup_interval, securefile,
num_uploaders)
)
return builder_fixture.builder

@ -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)
self.useBuilder(configfile, num_uploaders=2)
pool.start()
self.waitForImage('fake-provider2', 'fake-image')
nodes = self.waitForNodes('fake-label', 2)

Loading…
Cancel
Save