summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Shakhat <ishakhat@mirantis.com>2016-02-29 18:00:02 +0300
committerIlya Shakhat <ishakhat@mirantis.com>2016-02-29 18:00:02 +0300
commitabab0404cdb8c1852b9d0b1c4e1a5df5a65d83af (patch)
tree9770fca2aa3d71a693067a43b127c4c9de078cbe
parent4ab6709723f4dce6cfe528a050d60285d022f62f (diff)
Implement aggregation stage
-rw-r--r--performa/engine/aggregator.py70
-rw-r--r--performa/engine/main.py3
-rw-r--r--performa/scenarios/db/sysbench.rst25
-rw-r--r--performa/scenarios/db/sysbench.yaml12
4 files changed, 108 insertions, 2 deletions
diff --git a/performa/engine/aggregator.py b/performa/engine/aggregator.py
new file mode 100644
index 0000000..3992d36
--- /dev/null
+++ b/performa/engine/aggregator.py
@@ -0,0 +1,70 @@
1# Copyright (c) 2016 OpenStack Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12# implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16from oslo_log import log as logging
17import pymongo
18
19from performa.engine import utils
20
21LOG = logging.getLogger(__name__)
22
23
24def aggregate(scenario, mongo_url, db_name, tag):
25 if 'aggregation' not in scenario:
26 return # nothing to do
27
28 LOG.info('Running aggregation')
29
30 connection_params = utils.parse_url(mongo_url)
31 mongo_client = pymongo.MongoClient(**connection_params)
32 db = mongo_client.get_database(db_name)
33
34 aggregation = scenario['aggregation']
35
36 records_collection = db.get_collection('records')
37 series_collection = db.get_collection('series')
38
39 for op_group in aggregation:
40 for op, op_params in op_group.items():
41 if op == 'update':
42
43 select_query = op_params['query']
44 values_query = op_params['values']
45 values_pipeline = values_query['pipeline']
46
47 select_query['tag'] = tag
48 select_query['status'] = 'OK'
49
50 for rec in records_collection.find(select_query):
51 start = rec['start']
52 stop = rec['end'] # todo rename field into 'stop'
53
54 series_pipeline = [
55 {'$match': {'$and': [
56 {'tag': tag},
57 {'timestamp': {'$gte': start}},
58 {'timestamp': {'$lte': stop}}
59 ]}}
60 ]
61 series_pipeline.extend(values_pipeline)
62
63 point = next(series_collection.aggregate(series_pipeline))
64 del point['_id'] # to avoid overwriting
65 rec.update(point)
66
67 records_collection.update_one({'_id': rec['_id']},
68 {'$set': point})
69
70 LOG.debug('Updated record: %s', rec)
diff --git a/performa/engine/main.py b/performa/engine/main.py
index 5392620..4cc3e9b 100644
--- a/performa/engine/main.py
+++ b/performa/engine/main.py
@@ -19,6 +19,7 @@ from oslo_config import cfg
19from oslo_log import log as logging 19from oslo_log import log as logging
20import yaml 20import yaml
21 21
22from performa.engine import aggregator
22from performa.engine import ansible_runner 23from performa.engine import ansible_runner
23from performa.engine import config 24from performa.engine import config
24from performa.engine import player 25from performa.engine import player
@@ -60,6 +61,8 @@ def main():
60 61
61 storage.store_data(cfg.CONF.mongo_url, cfg.CONF.mongo_db, records, series) 62 storage.store_data(cfg.CONF.mongo_url, cfg.CONF.mongo_db, records, series)
62 63
64 aggregator.aggregate(scenario, cfg.CONF.mongo_url, cfg.CONF.mongo_db, tag)
65
63 report.generate_report(scenario, base_dir, cfg.CONF.mongo_url, 66 report.generate_report(scenario, base_dir, cfg.CONF.mongo_url,
64 cfg.CONF.mongo_db, cfg.CONF.book, tag) 67 cfg.CONF.mongo_db, cfg.CONF.book, tag)
65 68
diff --git a/performa/scenarios/db/sysbench.rst b/performa/scenarios/db/sysbench.rst
index f47be34..baedc11 100644
--- a/performa/scenarios/db/sysbench.rst
+++ b/performa/scenarios/db/sysbench.rst
@@ -7,7 +7,7 @@ This is the report of execution test plan
7Results 7Results
8^^^^^^^ 8^^^^^^^
9 9
10Chart and table: 10Queries per second depending on threads count:
11 11
12{{''' 12{{'''
13 title: Queries per second 13 title: Queries per second
@@ -30,6 +30,29 @@ Chart and table:
30''' | chart 30''' | chart
31}} 31}}
32 32
33Queries per second and mysqld CPU consumption depending on threads count:
34
35{{'''
36 title: Queries and and CPU util per second
37 axes:
38 x: threads
39 y: queries per sec
40 y2: mysqld CPU consumption, %
41 chart: line
42 pipeline:
43 - { $match: { task: sysbench_oltp, status: OK }}
44 - { $group: { _id: { threads: "$threads" },
45 queries_total_per_sec: { $avg: { $divide: ["$queries_total", "$duration"] }},
46 mysqld_total: { $avg: "$mysqld_total" }
47 }}
48 - { $project: { x: "$_id.threads",
49 y: "$queries_total_per_sec",
50 y2: { $multiply: [ "$mysqld_total", 100 ] }
51 }}
52 - { $sort: { x: 1 }}
53''' | chart
54}}
55
33.. references: 56.. references:
34 57
35.. _Sysbench: https://github.com/akopytov/sysbench 58.. _Sysbench: https://github.com/akopytov/sysbench
diff --git a/performa/scenarios/db/sysbench.yaml b/performa/scenarios/db/sysbench.yaml
index a0c3e33..b41bb78 100644
--- a/performa/scenarios/db/sysbench.yaml
+++ b/performa/scenarios/db/sysbench.yaml
@@ -23,7 +23,7 @@ execution:
23 - 23 -
24 hosts: $target 24 hosts: $target
25 matrix: 25 matrix:
26 threads: [ 10, 20, 30 ] 26 threads: [ 10, 20, 30, 40, 50, 60 ]
27 tasks: 27 tasks:
28 - sysbench_oltp: 28 - sysbench_oltp:
29 duration: 10 29 duration: 10
@@ -34,5 +34,15 @@ execution:
34 command: stop 34 command: stop
35 labels: [ CPU, PRC, PRM ] 35 labels: [ CPU, PRC, PRM ]
36 36
37aggregation:
38 -
39 update:
40 query:
41 { task: sysbench_oltp }
42 values:
43 pipeline:
44 - { $match: { task: atop, status: OK, label: PRC, name: mysqld }}
45 - { $group: { _id: null, mysqld_sys: { $avg: "$sys" }, mysqld_user: { $avg: "$user" }, mysqld_total: { $avg: { $add: [ "$sys", "$user" ] }} }}
46
37report: 47report:
38 template: sysbench.rst 48 template: sysbench.rst