Unit tests for the new worker multiplier and threads per disk config values

This commit is contained in:
Tom Haddon 2014-06-18 12:34:19 +01:00
parent 89cac18e1f
commit 20253d1e75
2 changed files with 9 additions and 3 deletions

View File

@ -62,13 +62,13 @@ class SwiftStorageServerContext(OSContextGenerator):
def __call__(self):
import psutil
multiplier = config('worker-multiplier') or 1
multiplier = int(config('worker-multiplier')) or 1
ctxt = {
'local_ip': unit_private_ip(),
'account_server_port': config('account-server-port'),
'container_server_port': config('container-server-port'),
'object_server_port': config('object-server-port'),
'workers': psutil.NUM_CPUS * multiplier,
'workers': str(psutil.NUM_CPUS * multiplier),
'object_server_threads_per_disk': config(
'object-server-threads-per-disk'),
}

View File

@ -56,16 +56,22 @@ class SwiftStorageContextTests(CharmTestCase):
_file.write.assert_called_with('RSYNC_ENABLE=true\n')
def test_swift_storage_server_context(self):
import psutil
self.unit_private_ip.return_value = '10.0.0.5'
self.test_config.set('account-server-port', '500')
self.test_config.set('object-server-port', '501')
self.test_config.set('container-server-port', '502')
self.test_config.set('object-server-threads-per-disk', '3')
self.test_config.set('worker-multiplier', '3')
num_workers = psutil.NUM_CPUS * 3
ctxt = swift_context.SwiftStorageServerContext()
result = ctxt()
ex = {
'container_server_port': '502',
'object_server_port': '501',
'account_server_port': '500',
'local_ip': '10.0.0.5'
'local_ip': '10.0.0.5',
'object_server_threads_per_disk': '3',
'workers': str(num_workers),
}
self.assertEquals(ex, result)