shaker/tests/test_traffic_aggregator.py
Ilya Shakhat 1bed81b604 Change output format and proceed with new report
Execution results are now written as flat list of records, where each
record is attributed with scenario name, test name, level of concurrency,
node hostname and agent id.

The report is restyled completely. The new ideology is to show a single
slice of data per time, tree-like navigation is replaced by selectors
which allow to drill-down and browse data from different points of view.

Change-Id: Ic760bb48b1dabd8e05ccb05b72da1a1d9f6a2441
2015-04-16 17:48:00 +03:00

131 lines
4.2 KiB
Python

# Copyright (c) 2015 Mirantis 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 copy
import testtools
from shaker.engine.aggregators import traffic
class TestTrafficAggregator(testtools.TestCase):
def test_agent_summary(self):
aggregator = traffic.TrafficAggregator(None)
original = {
"stderr": "", "stdout": '',
"meta": [["time", "s"], ["Ping ICMP", "ms"],
["TCP download", "bps"]],
"samples": [[0, 1.9, None],
[1, 2.4, None],
[2, 2.6, 60 * 1024 * 1024],
[3, 2.2, 65 * 1024 * 1024],
[4, 2.2, 61 * 1024 * 1024],
[5, 1.9, None]],
}
processed = copy.deepcopy(original)
aggregator.record_summary(processed)
self.assertFalse('stdout' in processed)
expected_stats = {
'Ping ICMP': {
'max': 2.6,
'min': 1.9,
'mean': 2.2,
'unit': 'ms',
},
'TCP download': {
'max': 65.0,
'min': 60.0,
'mean': 62.0,
'unit': 'Mbps',
}
}
self.assertEqual(expected_stats, processed['stats'])
expected_chart = [['time', 0, 1, 2, 3, 4, 5],
['Ping ICMP', 1.9, 2.4, 2.6, 2.2, 2.2, 1.9],
['TCP download', None, None, 60.0, 65.0, 61.0, None]]
self.assertEqual(expected_chart, processed['chart'])
def test_concurrency_summary(self):
aggregator = traffic.TrafficAggregator(None)
original = [
{
'agent_id': 'alpha_agent',
'node': 'alpha',
'stats': {
'Ping ICMP': {
'max': 2.6,
'min': 1.9,
'mean': 2.2,
'unit': 'ms',
},
'TCP download': {
'max': 65.0,
'min': 60.0,
'mean': 62.0,
'unit': 'Mbps',
}
},
'chart': [['time', 0, 1, 2, 3, 4, 5],
['Ping ICMP', 1.9, 2.4, 2.6, 2.2, 2.2, 1.9],
['TCP download', None, None, 60.0, 65.0, 61.0,
None]]
},
{
'agent_id': 'beta_agent',
'node': 'beta',
'stats': {
'Ping ICMP': {
'max': 3.6,
'min': 2.9,
'mean': 3.2,
'unit': 'ms',
},
'TCP download': {
'max': 75.0,
'min': 70.0,
'mean': 72.0,
'unit': 'Mbps',
}
},
'chart': [['time', 0, 1, 2, 3, 4, 5],
['Ping ICMP', 2.9, 3.4, 3.6, 3.2, 3.2, 2.9],
['TCP download', None, None, 70.0, 75.0, 71.0,
None]]
},
]
aggregate = aggregator.concurrency_summary(original)
expected_stats = {
'Ping ICMP': {
'max': 3.6,
'min': 1.9,
'mean': 2.7,
'unit': 'ms',
},
'TCP download': {
'max': 75.0,
'min': 60.0,
'mean': 67.0,
'unit': 'Mbps',
}
}
self.assertEqual(expected_stats, aggregate['stats'])