diff --git a/doc/samples/tasks/scenarios/zaqar/create-queue.json b/doc/samples/tasks/scenarios/zaqar/create-queue.json new file mode 100644 index 0000000000..f71f1308c3 --- /dev/null +++ b/doc/samples/tasks/scenarios/zaqar/create-queue.json @@ -0,0 +1,14 @@ +{ + "ZaqarBasic.create_queue": [ + { + "args": { + "name_length": 10 + }, + "runner": { + "type": "constant", + "times": 100, + "concurrency": 10 + } + } + ] +} diff --git a/doc/samples/tasks/scenarios/zaqar/create-queue.yaml b/doc/samples/tasks/scenarios/zaqar/create-queue.yaml new file mode 100644 index 0000000000..be3eaf1648 --- /dev/null +++ b/doc/samples/tasks/scenarios/zaqar/create-queue.yaml @@ -0,0 +1,9 @@ +--- + ZaqarBasic.create_queue: + - + args: + name_length: 10 + runner: + type: "constant" + times: 100 + concurrency: 10 diff --git a/rally-scenarios/rally-zaqar.yaml b/rally-scenarios/rally-zaqar.yaml new file mode 100644 index 0000000000..0bdefefc26 --- /dev/null +++ b/rally-scenarios/rally-zaqar.yaml @@ -0,0 +1,11 @@ +--- + ZaqarBasic.create_queue: + - + args: + name_length: 10 + runner: + type: "constant" + times: 100 + concurrency: 10 + sla: + max_failure_percent: 0 diff --git a/rally/benchmark/scenarios/zaqar/__init__.py b/rally/benchmark/scenarios/zaqar/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/rally/benchmark/scenarios/zaqar/basic.py b/rally/benchmark/scenarios/zaqar/basic.py new file mode 100644 index 0000000000..a4709a0459 --- /dev/null +++ b/rally/benchmark/scenarios/zaqar/basic.py @@ -0,0 +1,30 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from rally.benchmark.scenarios import base +from rally.benchmark.scenarios.zaqar import utils as zutils +from rally.benchmark import validation + + +class ZaqarBasic(zutils.ZaqarScenario): + + @validation.number("name_length", minval=10) + @base.scenario(context={"cleanup": ["zaqar"]}) + def create_queue(self, name_length=10, **kwargs): + """Creates Zaqar queue with random name. + + :param name_length: length of generated (random) part of name + :param **kwargs: Other optional parameters to create queues like + "metadata". + """ + + self._queue_create(name_length=name_length, **kwargs) diff --git a/rally/benchmark/scenarios/zaqar/utils.py b/rally/benchmark/scenarios/zaqar/utils.py new file mode 100644 index 0000000000..232bf30420 --- /dev/null +++ b/rally/benchmark/scenarios/zaqar/utils.py @@ -0,0 +1,29 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from rally.benchmark.scenarios import base + + +class ZaqarScenario(base.Scenario): + + @base.atomic_action_timer('zaqar.create_queue') + def _queue_create(self, name_length=10, **kwargs): + """Creates Zaqar queue with random name. + + :param name_length: length of generated (random) part of name + :param **kwargs: Other optional parameters to create queues like + "metadata". + :returns: zaqar queue instance + """ + + name = self._generate_random_name(length=name_length) + return self.clients("zaqar").queue(name, **kwargs) \ No newline at end of file diff --git a/tests/unit/benchmark/scenarios/zaqar/__init__.py b/tests/unit/benchmark/scenarios/zaqar/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/unit/benchmark/scenarios/zaqar/test_basic.py b/tests/unit/benchmark/scenarios/zaqar/test_basic.py new file mode 100644 index 0000000000..8fec6db213 --- /dev/null +++ b/tests/unit/benchmark/scenarios/zaqar/test_basic.py @@ -0,0 +1,30 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import mock + +from rally.benchmark.scenarios.zaqar import basic +from tests.unit import test + +BASE = "rally.benchmark.scenarios.zaqar." +BASIC = BASE + "basic.ZaqarBasic." + + +class ZaqarBasicTestCase(test.TestCase): + + @mock.patch(BASIC + "_generate_random_name") + def test_create_queue(self, mock_gen_name): + scenario = basic.ZaqarBasic() + mock_gen_name.return_value = "fizbit" + scenario._queue_create = mock.MagicMock() + scenario.create_queue(name_length=10) + scenario._queue_create.assert_called_once_with(name_length=10) diff --git a/tests/unit/benchmark/scenarios/zaqar/test_utils.py b/tests/unit/benchmark/scenarios/zaqar/test_utils.py new file mode 100644 index 0000000000..f881e3b806 --- /dev/null +++ b/tests/unit/benchmark/scenarios/zaqar/test_utils.py @@ -0,0 +1,48 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import mock + +from rally.benchmark.scenarios.zaqar import utils +from tests.unit import fakes +from tests.unit import test + +UTILS = "rally.benchmark.scenarios.zaqar.utils." + + +class ZaqarScenarioTestCase(test.TestCase): + + def _test_atomic_action_timer(self, atomic_actions, name): + action_duration = atomic_actions.get(name) + self.assertIsNotNone(action_duration) + self.assertIsInstance(action_duration, float) + + @mock.patch(UTILS + "ZaqarScenario._generate_random_name") + def test_queue_create(self, mock_gen_name): + name = "kitkat" + mock_gen_name.return_value = name + + queue = {} + fake_zaqar = fakes.FakeZaqarClient() + fake_zaqar.queue = mock.MagicMock(return_value=queue) + + fake_clients = fakes.FakeClients() + fake_clients._zaqar = fake_zaqar + scenario = utils.ZaqarScenario(clients=fake_clients) + + result = scenario._queue_create(name_length=10) + + self.assertEqual(queue, result) + + fake_zaqar.queue.assert_called_once_with("kitkat") + self._test_atomic_action_timer(scenario.atomic_actions(), + 'zaqar.create_queue') \ No newline at end of file