diff --git a/.gitignore b/.gitignore index d7fe34e17e..6aa35d06c4 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,4 @@ cover .mr.developer.cfg .project .pydevproject +*.swp diff --git a/rally/benchmark/scenarios/glance/utils.py b/rally/benchmark/scenarios/glance/utils.py index 1803801c1b..c9f90fbc68 100644 --- a/rally/benchmark/scenarios/glance/utils.py +++ b/rally/benchmark/scenarios/glance/utils.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +from oslo.config import cfg import random import string import time @@ -23,6 +24,33 @@ from rally.benchmark import utils as bench_utils from rally import utils +glance_benchmark_opts = [ + cfg.FloatOpt('glance_image_create_prepoll_delay', + default=2, + help='Time to sleep after creating a resource before ' + 'polling for it status'), + cfg.FloatOpt('glance_image_create_timeout', + default=120, + help='Time to wait for glance image to be created.'), + cfg.FloatOpt('glance_image_create_poll_interval', + default=1, + help='Interval between checks when waiting for image ' + 'creation.'), + cfg.FloatOpt('glance_image_delete_timeout', + default=120, + help='Time to wait for glance image to be deleted.'), + cfg.FloatOpt('glance_image_delete_poll_interval', + default=1, + help='Interval between checks when waiting for image ' + 'deletion.') +] + + +CONF = cfg.CONF +benchmark_group = cfg.OptGroup(name='benchmark', title='benchmark options') +CONF.register_opts(glance_benchmark_opts, group=benchmark_group) + + class GlanceScenario(base.Scenario): @scenario_utils.atomic_action_timer('glance.create_image') @@ -46,11 +74,13 @@ class GlanceScenario(base.Scenario): container_format=container_format, disk_format=disk_format, **kwargs) - time.sleep(5) - image = utils.wait_for(image, - is_ready=bench_utils.resource_is("active"), - update_resource=bench_utils.get_from_manager(), - timeout=120, check_interval=3) + time.sleep(CONF.benchmark.glance_image_create_prepoll_delay) + image = utils.wait_for( + image, + is_ready=bench_utils.resource_is("active"), + update_resource=bench_utils.get_from_manager(), + timeout=CONF.benchmark.glance_image_create_timeout, + check_interval=CONF.benchmark.glance_image_create_poll_interval) return image @scenario_utils.atomic_action_timer('glance.delete_image') @@ -62,9 +92,11 @@ class GlanceScenario(base.Scenario): :param image: Image object """ image.delete() - utils.wait_for_delete(image, - update_resource=bench_utils.get_from_manager(), - timeout=120, check_interval=3) + utils.wait_for_delete( + image, + update_resource=bench_utils.get_from_manager(), + timeout=CONF.benchmark.glance_image_delete_timeout, + check_interval=CONF.benchmark.glance_image_delete_poll_interval) def _generate_random_name(self, length): name = ''.join(random.choice(string.lowercase) for i in range(length)) diff --git a/tests/benchmark/scenarios/glance/test_utils.py b/tests/benchmark/scenarios/glance/test_utils.py index 8314b93133..43eda0edc7 100644 --- a/tests/benchmark/scenarios/glance/test_utils.py +++ b/tests/benchmark/scenarios/glance/test_utils.py @@ -64,7 +64,7 @@ class GlanceScenarioTestCase(test.TestCase): self.assertIsInstance(action_duration, float) @mock.patch(GLANCE_UTILS + '.GlanceScenario.clients') - def test__create_image(self, mock_clients): + def test_create_image(self, mock_clients): mock_clients("glance").images.create.return_value = self.image scenario = utils.GlanceScenario() return_image = scenario._create_image('image_name', @@ -74,21 +74,21 @@ class GlanceScenarioTestCase(test.TestCase): self.wait_for.mock.assert_called_once_with(self.image, update_resource=self.gfm(), is_ready=self.res_is.mock(), - check_interval=3, + check_interval=1, timeout=120) self.res_is.mock.assert_has_calls(mock.call('active')) self.assertEqual(self.wait_for.mock(), return_image) self._test_atomic_action_timer(scenario.atomic_actions_time(), 'glance.create_image') - def test__delete_image(self): + def test_delete_image(self): scenario = utils.GlanceScenario() scenario._delete_image(self.image) self.image.delete.assert_called_once_with() self.wait_for_delete.\ mock.assert_called_once_with(self.image, update_resource=self.gfm(), - check_interval=3, + check_interval=1, timeout=120) self._test_atomic_action_timer(scenario.atomic_actions_time(), 'glance.delete_image')