Merge "Adds Zaqar Basic scenarios"

This commit is contained in:
Jenkins 2014-10-28 09:29:41 +00:00 committed by Gerrit Code Review
commit a7c7cc3bb5
9 changed files with 171 additions and 0 deletions

View File

@ -0,0 +1,14 @@
{
"ZaqarBasic.create_queue": [
{
"args": {
"name_length": 10
},
"runner": {
"type": "constant",
"times": 100,
"concurrency": 10
}
}
]
}

View File

@ -0,0 +1,9 @@
---
ZaqarBasic.create_queue:
-
args:
name_length: 10
runner:
type: "constant"
times: 100
concurrency: 10

View File

@ -0,0 +1,11 @@
---
ZaqarBasic.create_queue:
-
args:
name_length: 10
runner:
type: "constant"
times: 100
concurrency: 10
sla:
max_failure_percent: 0

View 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)

View 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)

View 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)

View 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')