- Remove translations Nobody is using translations for Rally and I don't think that anybody is going to use it. Target auditory for Rally are developers/operators which usually know well english. For me this looks like waste of resources, performance degradation (cause we are calling _()), complexity (+1 thing that you need to know) - Pass to log already formatted strings It's very bad because in case of wrong formatting, it doesn't fail instead just writes errors to the logs, as well information about trace is lost, so it's super hard to fix it Log wrapper doesn't allow to use LOG anymore for formatting strings All places are fixed - Improve logging of exceptions LOG.exception() already logs exception, which means it's bad idea to pass str(e) to it. Instead we should provide clear description of what happend. Improved few places to write warnings or exceptions in case of different level of logs. In few places just use LOG.exception - Part of log messages were improved and simplified Depends-On: If23d874e8b73de12ba2b8c4e028a55543af6381b Change-Id: Ibc1e1f4f554649d14b8fe4801557b83922ecefe3
98 lines
2.9 KiB
ReStructuredText
98 lines
2.9 KiB
ReStructuredText
..
|
|
Copyright 2016 Mirantis Inc. 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.
|
|
|
|
.. _plugins_sla_plugin:
|
|
|
|
|
|
SLA as a plugin
|
|
===============
|
|
|
|
Let's create an SLA (success criterion) plugin that checks whether the
|
|
range of the observed performance measurements does not exceed the
|
|
allowed maximum value.
|
|
|
|
Creation
|
|
^^^^^^^^
|
|
|
|
Inherit a class for your plugin from the base *SLA* class and implement its API
|
|
(the *add_iteration(iteration)*, the *details()* method):
|
|
|
|
.. code-block:: python
|
|
|
|
from rally.task import sla
|
|
|
|
@sla.configure(name="max_duration_range")
|
|
class MaxDurationRange(sla.SLA):
|
|
"""Maximum allowed duration range in seconds."""
|
|
|
|
CONFIG_SCHEMA = {
|
|
"type": "number",
|
|
"minimum": 0.0,
|
|
}
|
|
|
|
def __init__(self, criterion_value):
|
|
super(MaxDurationRange, self).__init__(criterion_value)
|
|
self._min = 0
|
|
self._max = 0
|
|
|
|
def add_iteration(self, iteration):
|
|
# Skipping failed iterations (that raised exceptions)
|
|
if iteration.get("error"):
|
|
return self.success # This field is defined in base class
|
|
|
|
# Updating _min and _max values
|
|
self._max = max(self._max, iteration["duration"])
|
|
self._min = min(self._min, iteration["duration"])
|
|
|
|
# Updating successfulness based on new max and min values
|
|
self.success = self._max - self._min <= self.criterion_value
|
|
return self.success
|
|
|
|
def details(self):
|
|
return ("%s - Maximum allowed duration range: %.2f%% <= %.2f%%"
|
|
% (self.status(), self._max - self._min, self.criterion_value))
|
|
|
|
|
|
Usage
|
|
^^^^^
|
|
|
|
The new plugin can be used by specifying it in SLA section. Like below:
|
|
|
|
.. code-block:: json
|
|
|
|
{
|
|
"Dummy.dummy": [
|
|
{
|
|
"args": {
|
|
"sleep": 0.01
|
|
},
|
|
"runner": {
|
|
"type": "constant",
|
|
"times": 5,
|
|
"concurrency": 1
|
|
},
|
|
"context": {
|
|
"users": {
|
|
"tenants": 1,
|
|
"users_per_tenant": 1
|
|
}
|
|
},
|
|
"sla": {
|
|
"max_duration_range": 2.5
|
|
}
|
|
}
|
|
]
|
|
}
|