forked from scylladb/scylla-cluster-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
performance_regression_user_profiles_test.py
64 lines (55 loc) · 2.68 KB
/
performance_regression_user_profiles_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See LICENSE for more details.
#
# Copyright (c) 2017 ScyllaDB
import os
from avocado import main
from sdcm.tester import ClusterTester
class PerformanceRegressionUserProfilesTest(ClusterTester):
"""
Test Scylla performance regression with cassandra-stress using custom user profiles.
:avocado: enable
"""
def __init__(self, *args, **kwargs):
super(PerformanceRegressionUserProfilesTest, self).__init__(*args, **kwargs)
self.create_stats = False
def _clean_keyspace(self, cs_profile):
with open(cs_profile) as fdr:
ks = [line.split(':')[-1].strip() for line in fdr.readlines() if line.startswith('keyspace:')]
if ks:
self.log.debug('Drop keyspace {}'.format(ks[0]))
session = self.cql_connection_patient(self.db_cluster.nodes[0])
session.execute('DROP KEYSPACE IF EXISTS {};'.format(ks[0]))
def test_user_profiles(self):
"""
Run workload using user profiles
"""
duration = self.params.get('cs_duration', default='50m')
user_profiles = self.params.get('cs_user_profiles')
assert user_profiles is not None, 'No user profiles defined!'
for cs_profile in user_profiles.split():
assert os.path.exists(cs_profile), 'File not found: {}'.format(cs_profile)
self.log.debug('Run stress test with user profile {}, duration {}'.format(cs_profile, duration))
profile_dst = os.path.join('/tmp', os.path.basename(cs_profile))
with open(cs_profile) as pconf:
cont = pconf.readlines()
for cmd in [line.lstrip('#').strip() for line in cont if line.find('cassandra-stress') > 0]:
stress_cmd = (cmd.format(profile_dst, duration))
self.log.debug('Stress cmd: {}'.format(stress_cmd))
self.create_test_stats()
stress_queue = self.run_stress_thread(stress_cmd=stress_cmd, stress_num=2, profile=cs_profile)
self.get_stress_results(queue=stress_queue)
self.update_test_details(scylla_conf=True)
self.check_regression()
self._clean_keyspace(cs_profile)
if __name__ == '__main__':
main()