Merge "Adds Zaqar Basic scenarios"
This commit is contained in:
commit
a7c7cc3bb5
14
doc/samples/tasks/scenarios/zaqar/create-queue.json
Normal file
14
doc/samples/tasks/scenarios/zaqar/create-queue.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"ZaqarBasic.create_queue": [
|
||||||
|
{
|
||||||
|
"args": {
|
||||||
|
"name_length": 10
|
||||||
|
},
|
||||||
|
"runner": {
|
||||||
|
"type": "constant",
|
||||||
|
"times": 100,
|
||||||
|
"concurrency": 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
9
doc/samples/tasks/scenarios/zaqar/create-queue.yaml
Normal file
9
doc/samples/tasks/scenarios/zaqar/create-queue.yaml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
ZaqarBasic.create_queue:
|
||||||
|
-
|
||||||
|
args:
|
||||||
|
name_length: 10
|
||||||
|
runner:
|
||||||
|
type: "constant"
|
||||||
|
times: 100
|
||||||
|
concurrency: 10
|
11
rally-scenarios/rally-zaqar.yaml
Normal file
11
rally-scenarios/rally-zaqar.yaml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
ZaqarBasic.create_queue:
|
||||||
|
-
|
||||||
|
args:
|
||||||
|
name_length: 10
|
||||||
|
runner:
|
||||||
|
type: "constant"
|
||||||
|
times: 100
|
||||||
|
concurrency: 10
|
||||||
|
sla:
|
||||||
|
max_failure_percent: 0
|
0
rally/benchmark/scenarios/zaqar/__init__.py
Normal file
0
rally/benchmark/scenarios/zaqar/__init__.py
Normal file
30
rally/benchmark/scenarios/zaqar/basic.py
Normal file
30
rally/benchmark/scenarios/zaqar/basic.py
Normal file
@ -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)
|
29
rally/benchmark/scenarios/zaqar/utils.py
Normal file
29
rally/benchmark/scenarios/zaqar/utils.py
Normal file
@ -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)
|
0
tests/unit/benchmark/scenarios/zaqar/__init__.py
Normal file
0
tests/unit/benchmark/scenarios/zaqar/__init__.py
Normal file
30
tests/unit/benchmark/scenarios/zaqar/test_basic.py
Normal file
30
tests/unit/benchmark/scenarios/zaqar/test_basic.py
Normal file
@ -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)
|
48
tests/unit/benchmark/scenarios/zaqar/test_utils.py
Normal file
48
tests/unit/benchmark/scenarios/zaqar/test_utils.py
Normal file
@ -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')
|
Loading…
Reference in New Issue
Block a user