Merge "Add Ceilometer list samples"

This commit is contained in:
Jenkins 2015-04-29 15:22:38 +00:00 committed by Gerrit Code Review
commit 5c6735c073
8 changed files with 118 additions and 1 deletions

View File

@ -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:

View File

@ -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()

View File

@ -130,6 +130,14 @@ class CeilometerScenario(base.Scenario):
"""
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.

View File

@ -0,0 +1,17 @@
{
"CeilometerSamples.list_samples": [
{
"runner": {
"type": "constant",
"times": 10,
"concurrency": 2
},
"context": {
"users": {
"tenants": 2,
"users_per_tenant": 2
}
}
}
]
}

View File

@ -0,0 +1,11 @@
---
CeilometerSamples.list_samples:
-
runner:
type: "constant"
times: 10
concurrency: 2
context:
users:
tenants: 2
users_per_tenant: 2

View File

@ -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()

View File

@ -117,6 +117,11 @@ class CeilometerScenarioTestCase(test.TestCase):
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")

View File

@ -763,6 +763,9 @@ class FakeSampleManager(FakeManager):
sample = FakeSample(self, **kwargs)
return [self._cache(sample)]
def list(self):
return ["fake-samples"]
class FakeMeterManager(FakeManager):