diff --git a/rally/plugins/openstack/scenarios/gnocchi/__init__.py b/rally/plugins/openstack/scenarios/gnocchi/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/rally/plugins/openstack/scenarios/gnocchi/capabilities.py b/rally/plugins/openstack/scenarios/gnocchi/capabilities.py new file mode 100644 index 00000000..1f88fb4e --- /dev/null +++ b/rally/plugins/openstack/scenarios/gnocchi/capabilities.py @@ -0,0 +1,31 @@ +# Copyright 2017 Red Hat, Inc. +# +# 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 import consts +from rally.plugins.openstack import scenario +from rally.plugins.openstack.scenarios.gnocchi import utils as gnocchiutils +from rally.task import validation + +"""Scenarios for Gnocchi capabilities.""" + + +@validation.add("required_services", + services=[consts.Service.GNOCCHI]) +@validation.add("required_platform", platform="openstack", users=True) +@scenario.configure(name="Gnocchi.list_capabilities") +class ListCapabilities(gnocchiutils.GnocchiBase): + + def run(self): + """List supported aggregation methods.""" + self.gnocchi.list_capabilities() diff --git a/rally/plugins/openstack/scenarios/gnocchi/utils.py b/rally/plugins/openstack/scenarios/gnocchi/utils.py new file mode 100644 index 00000000..60e91a31 --- /dev/null +++ b/rally/plugins/openstack/scenarios/gnocchi/utils.py @@ -0,0 +1,31 @@ +# Copyright 2017 Red Hat, Inc. +# +# 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.plugins.openstack import scenario +from rally.plugins.openstack.services.gnocchi import metric + + +class GnocchiBase(scenario.OpenStackScenario): + """Base class for Gnocchi scenarios with basic atomic actions.""" + + def __init__(self, context=None, admin_clients=None, clients=None): + super(GnocchiBase, self).__init__(context, admin_clients, clients) + if hasattr(self, "_admin_clients"): + self.admin_gnocchi = metric.GnocchiService( + self._admin_clients, name_generator=self.generate_random_name, + atomic_inst=self.atomic_actions()) + if hasattr(self, "_clients"): + self.gnocchi = metric.GnocchiService( + self._clients, name_generator=self.generate_random_name, + atomic_inst=self.atomic_actions()) diff --git a/samples/tasks/scenarios/gnocchi/list-capabilities.json b/samples/tasks/scenarios/gnocchi/list-capabilities.json new file mode 100644 index 00000000..060b660f --- /dev/null +++ b/samples/tasks/scenarios/gnocchi/list-capabilities.json @@ -0,0 +1,22 @@ +{ + "Gnocchi.list_capabilities": [ + { + "runner": { + "type": "constant", + "times": 10, + "concurrency": 2 + }, + "context": { + "users": { + "tenants": 2, + "users_per_tenant": 3 + } + }, + "sla": { + "failure_rate": { + "max": 0 + } + } + } + ] +} diff --git a/samples/tasks/scenarios/gnocchi/list-capabilities.yaml b/samples/tasks/scenarios/gnocchi/list-capabilities.yaml new file mode 100644 index 00000000..0890489b --- /dev/null +++ b/samples/tasks/scenarios/gnocchi/list-capabilities.yaml @@ -0,0 +1,14 @@ +--- + Gnocchi.list_capabilities: + - + runner: + type: constant + times: 10 + concurrency: 2 + context: + users: + tenants: 2 + users_per_tenant: 3 + sla: + failure_rate: + max: 0 diff --git a/tests/unit/plugins/openstack/scenarios/gnocchi/__init__.py b/tests/unit/plugins/openstack/scenarios/gnocchi/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/unit/plugins/openstack/scenarios/gnocchi/test_capabilities.py b/tests/unit/plugins/openstack/scenarios/gnocchi/test_capabilities.py new file mode 100644 index 00000000..bd25162b --- /dev/null +++ b/tests/unit/plugins/openstack/scenarios/gnocchi/test_capabilities.py @@ -0,0 +1,44 @@ +# Copyright 2017 Red Hat, Inc. +# +# 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.plugins.openstack.scenarios.gnocchi import capabilities +from tests.unit import test + + +class GnocchiCapabilitiesTestCase(test.ScenarioTestCase): + + def get_test_context(self): + context = super(GnocchiCapabilitiesTestCase, self).get_test_context() + context.update({ + "user": { + "user_id": "fake", + "credential": mock.MagicMock() + }, + "tenant": {"id": "fake"} + }) + return context + + def setUp(self): + super(GnocchiCapabilitiesTestCase, self).setUp() + patch = mock.patch( + "rally.plugins.openstack.services.gnocchi.metric.GnocchiService") + self.addCleanup(patch.stop) + self.mock_metric = patch.start() + + def test__list_capabilities(self): + metric_service = self.mock_metric.return_value + capabilities.ListCapabilities(self.context).run() + metric_service.list_capabilities.assert_called_once_with() diff --git a/tests/unit/plugins/openstack/scenarios/gnocchi/test_utils.py b/tests/unit/plugins/openstack/scenarios/gnocchi/test_utils.py new file mode 100644 index 00000000..901935c4 --- /dev/null +++ b/tests/unit/plugins/openstack/scenarios/gnocchi/test_utils.py @@ -0,0 +1,48 @@ +# Copyright 2017 Red Hat, Inc. +# +# 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.plugins.openstack.scenarios.gnocchi import utils +from tests.unit import test + + +class GnocchiBaseTestCase(test.ScenarioTestCase): + + def setUp(self): + super(GnocchiBaseTestCase, self).setUp() + self.context = super(GnocchiBaseTestCase, self).get_test_context() + self.context.update({ + "admin": { + "id": "fake_user_id", + "credential": mock.MagicMock() + }, + "user": { + "id": "fake_user_id", + "credential": mock.MagicMock() + }, + "tenant": {"id": "fake_tenant_id", + "name": "fake_tenant_name"} + }) + patch = mock.patch( + "rally.plugins.openstack.services.gnocchi.metric.GnocchiService") + self.addCleanup(patch.stop) + self.mock_service = patch.start() + + def test__gnocchi_base(self): + base = utils.GnocchiBase(self.context) + self.assertEqual(base.admin_gnocchi, + self.mock_service.return_value) + self.assertEqual(base.gnocchi, + self.mock_service.return_value)