support container_name from cli
Change-Id: Ib3a99b0453d7e04464ffef303accf1b0c05385df
This commit is contained in:
parent
6bce89964b
commit
a5b2a5f91a
|
@ -119,6 +119,8 @@ def main(argv):
|
||||||
parser.add_argument('-C', '--num-containers', type=int,
|
parser.add_argument('-C', '--num-containers', type=int,
|
||||||
help='Number of containers to distribute objects '
|
help='Number of containers to distribute objects '
|
||||||
'among')
|
'among')
|
||||||
|
parser.add_argument('--container-name',
|
||||||
|
help='Set the base container_name')
|
||||||
parser.add_argument('-x', '--no-delete',
|
parser.add_argument('-x', '--no-delete',
|
||||||
dest='delete', action='store_false',
|
dest='delete', action='store_false',
|
||||||
help='If set, will not delete the objects created')
|
help='If set, will not delete the objects created')
|
||||||
|
@ -157,8 +159,11 @@ def main(argv):
|
||||||
options.put_concurrency = options.concurrency
|
options.put_concurrency = options.concurrency
|
||||||
options.get_concurrency = options.concurrency
|
options.get_concurrency = options.concurrency
|
||||||
options.del_concurrency = options.concurrency
|
options.del_concurrency = options.concurrency
|
||||||
options.containers = ['%s_%d' % (options.container_name, i)
|
if options.num_containers == 1:
|
||||||
for i in range(int(options.num_containers))]
|
options.containers = [options.container_name]
|
||||||
|
else:
|
||||||
|
options.containers = ['%s_%d' % (options.container_name, i)
|
||||||
|
for i in range(int(options.num_containers))]
|
||||||
|
|
||||||
# Turn "yes"/"no"/etc. strings to booleans
|
# Turn "yes"/"no"/etc. strings to booleans
|
||||||
options.use_proxy = config_true_value(options.use_proxy)
|
options.use_proxy = config_true_value(options.use_proxy)
|
||||||
|
|
|
@ -123,6 +123,7 @@ class TestCli(unittest.TestCase):
|
||||||
'--num-objects', '5000',
|
'--num-objects', '5000',
|
||||||
'--num-gets', '4000',
|
'--num-gets', '4000',
|
||||||
'--num-containers', '4',
|
'--num-containers', '4',
|
||||||
|
'--container-name', 'foo',
|
||||||
'-x',
|
'-x',
|
||||||
'--auth_version', '2.0',
|
'--auth_version', '2.0',
|
||||||
'--delay', '10',
|
'--delay', '10',
|
||||||
|
@ -143,6 +144,9 @@ class TestCli(unittest.TestCase):
|
||||||
self.assertEqual(controller_opts.num_gets, 4000)
|
self.assertEqual(controller_opts.num_gets, 4000)
|
||||||
self.assertEqual(controller_opts.num_containers, 4)
|
self.assertEqual(controller_opts.num_containers, 4)
|
||||||
self.assertEqual(len(controller_opts.containers), 4)
|
self.assertEqual(len(controller_opts.containers), 4)
|
||||||
|
self.assertEqual([
|
||||||
|
c.startswith('foo_') for c in controller_opts.containers
|
||||||
|
], [True] * 4)
|
||||||
self.assertFalse(controller_opts.delete)
|
self.assertFalse(controller_opts.delete)
|
||||||
self.assertEqual(controller_opts.auth_version, '2.0')
|
self.assertEqual(controller_opts.auth_version, '2.0')
|
||||||
self.assertEqual(controller_opts.delay, 10)
|
self.assertEqual(controller_opts.delay, 10)
|
||||||
|
@ -156,6 +160,12 @@ class TestCli(unittest.TestCase):
|
||||||
self.assertEqual(controller_opts.timeout, 10)
|
self.assertEqual(controller_opts.timeout, 10)
|
||||||
self.assertTrue(controller_opts.containers)
|
self.assertTrue(controller_opts.containers)
|
||||||
|
|
||||||
|
def test_single_container(self):
|
||||||
|
controller_opts, container_opts, del_opts = self.run_main([
|
||||||
|
'--container-name', 'bar', '--num-containers', '1'])
|
||||||
|
self.assertEqual(controller_opts.num_containers, 1)
|
||||||
|
self.assertEqual(controller_opts.containers, ['bar'])
|
||||||
|
|
||||||
def test_concurrency_overrides_get_put_delete(self):
|
def test_concurrency_overrides_get_put_delete(self):
|
||||||
controller_opts, container_opts, del_opts = self.run_main(
|
controller_opts, container_opts, del_opts = self.run_main(
|
||||||
[
|
[
|
||||||
|
|
Loading…
Reference in New Issue