Skip to content

Commit

Permalink
Merge "Add Ceilometer list samples"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Apr 29, 2015
2 parents 1daf204 + cc9bb6f commit 5c6735c
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 1 deletion.
14 changes: 14 additions & 0 deletions rally-jobs/rally.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,20 @@
failure_rate:
max: 0

CeilometerSamples.list_samples:
-
runner:
type: "constant"
times: 10
concurrency: 10
context:
users:
tenants: 1
users_per_tenant: 1
sla:
failure_rate:
max: 0

Dummy.dummy:
-
args:
Expand Down
32 changes: 32 additions & 0 deletions rally/benchmark/scenarios/ceilometer/samples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# All Rights Reserved.
#
# 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.ceilometer import utils as ceilometerutils
from rally.benchmark import validation
from rally import consts


class CeilometerSamples(ceilometerutils.CeilometerScenario):
"""Benchmark scenarios for Ceilometer Samples API."""

@validation.required_services(consts.Service.CEILOMETER)
@validation.required_openstack(users=True)
@base.scenario()
def list_samples(self):
"""Fetch all samples.
This scenario fetches list of all samples.
"""
self._list_samples()
10 changes: 9 additions & 1 deletion rally/benchmark/scenarios/ceilometer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ def _list_resources(self):
"""
return self.clients("ceilometer").resources.list()

@base.atomic_action_timer("ceilometer.list_samples")
def _list_samples(self):
"""List all Samples.
:returns: list of all samples
"""
return self.clients("ceilometer").samples.list()

@base.atomic_action_timer("ceilometer.get_stats")
def _get_stats(self, meter_name):
"""Get stats for a specific meter.
Expand Down Expand Up @@ -214,4 +222,4 @@ def _query_samples(self, filter, orderby, limit):
:returns: queried samples
"""
return self.clients("ceilometer").query_samples.query(
filter, orderby, limit)
filter, orderby, limit)
17 changes: 17 additions & 0 deletions samples/tasks/scenarios/ceilometer/list-samples.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"CeilometerSamples.list_samples": [
{
"runner": {
"type": "constant",
"times": 10,
"concurrency": 2
},
"context": {
"users": {
"tenants": 2,
"users_per_tenant": 2
}
}
}
]
}
11 changes: 11 additions & 0 deletions samples/tasks/scenarios/ceilometer/list-samples.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
CeilometerSamples.list_samples:
-
runner:
type: "constant"
times: 10
concurrency: 2
context:
users:
tenants: 2
users_per_tenant: 2
27 changes: 27 additions & 0 deletions tests/unit/benchmark/scenarios/ceilometer/test_samples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# All Rights Reserved.
#
# 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.ceilometer import samples
from tests.unit import test


class CeilometerSamplesTestCase(test.TestCase):
def test_list_samples(self):
scenario = samples.CeilometerSamples()
scenario._list_samples = mock.MagicMock()
scenario.list_samples()

scenario._list_samples.assert_called_once_with()
5 changes: 5 additions & 0 deletions tests/unit/benchmark/scenarios/ceilometer/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ def test__list_resources(self):
fake_resources = self.scenario._list_resources()
self.assertEqual(fake_resources, ["fake-resource"])

def test__list_samples(self):
"""Test _list_samples."""
fake_samples = self.scenario._list_samples()
self.assertEqual(fake_samples, ["fake-samples"])

def test__get_stats(self):
"""Test _get_stats function."""
fake_statistics = self.scenario._get_stats("fake-meter")
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/fakes.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,9 @@ def create(self, **kwargs):
sample = FakeSample(self, **kwargs)
return [self._cache(sample)]

def list(self):
return ["fake-samples"]


class FakeMeterManager(FakeManager):

Expand Down

0 comments on commit 5c6735c

Please sign in to comment.