Merge "Add Gnocchi capabilities scenario"

This commit is contained in:
Zuul 2018-02-02 13:48:17 +00:00 committed by Gerrit Code Review
commit 2cf0a40eb6
8 changed files with 190 additions and 0 deletions

View File

@ -0,0 +1,31 @@
# Copyright 2017 Red Hat, Inc. <http://www.redhat.com>
#
# 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()

View File

@ -0,0 +1,31 @@
# Copyright 2017 Red Hat, Inc. <http://www.redhat.com>
#
# 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())

View File

@ -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
}
}
}
]
}

View File

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

View File

@ -0,0 +1,44 @@
# Copyright 2017 Red Hat, Inc. <http://www.redhat.com>
#
# 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()

View File

@ -0,0 +1,48 @@
# Copyright 2017 Red Hat, Inc. <http://www.redhat.com>
#
# 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)