forked from aerospike/act
-
Notifications
You must be signed in to change notification settings - Fork 0
/
act_config_helper.py
181 lines (163 loc) · 6.27 KB
/
act_config_helper.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!/usr/bin/python
####
# Act config creator to help configuration for tests
####
import cmd
import os
class RunCommand(cmd.Cmd):
__VERSION__ = "0.0.1"
prompt = "ACT> "
name = "Aerospike ACT config creator"
def do_EOF(self, line):
return True
def do_exit(self, line):
return True
def do_createconfig(self,line):
device_names = ''
queue_per_device = 'no'
num_queues = 8
threads_per_queue = 8
test_duration_sec = 86400
report_interval_sec = 1
record_bytes = 1536
large_block_op_kbytes = 128
use_valloc= 'no'
scheduler_mode = 'noop'
use_standard = True
device_load = -1
### Ask for details ###
try:
response = ''
# Number of devices:
while (not response.isdigit()):
response = raw_input('Enter the number of devices you want to create config for: ')
if response == '':
continue
no_of_devices = int(response)
# Device names:
print 'Enter either raw device if over-provisioned using hdparm or partition if over-provisioned using fdisk:'
device_list = ''
for device in range(1, no_of_devices + 1):
response = ''
while response == '':
response = raw_input('Enter device name #' + str(device) + ' (e.g. /dev/sdb or /dev/sdb1): ')
if not response == '':
device_list += response
if device != no_of_devices:
device_list += ','
device_names = device_list
# Test duration:
td = raw_input('Change test duration default of ' + str(test_duration_sec / 3600) + ' hours? (y/N): ')
if 'y' == td or 'Y' == td:
response = 'x'
while (not response.isdigit()):
response = raw_input('Enter the test duration in hours: ')
if response == '':
continue
tds = int(response)
test_duration_sec = tds * 3600
# Non-standard items:
response = raw_input('Use non-standard configuration? (y/N): ')
if 'y' == response or 'Y' == response:
# Read & write rates:
rwops = raw_input('Configure read/write ops per second? (y/N): ')
if 'y' == rwops or 'Y' == rwops:
response = 'x'
while (not response.isdigit()):
response = raw_input('Enter read ops per second for each device: ')
if response == '':
continue
read_reqs_per_sec = int(response) * no_of_devices
response = 'x'
while (not response.isdigit()):
response = raw_input('Enter write ops per second for each device: ')
if response == '':
continue
write_reqs_per_sec = int(response) * no_of_devices
use_standard = False
# Record size:
recsz = raw_input('Change record-bytes default of ' + str(record_bytes) + '? (y/N): ')
if 'y' == recsz or 'Y' == recsz:
response = 'x'
while (not response.isdigit()):
response = raw_input('Enter record-bytes value: ')
if response == '':
continue
record_bytes = response
# Queues & threads:
numq = raw_input('Change num-queues default of ' + str(num_queues) + '? (y/N): ')
if 'y' == numq or 'Y' == numq:
response = 'x'
while (not response.isdigit()):
response = raw_input('Enter num-queues value: ')
if response == '':
continue
num_queues = response
tpq = raw_input('Change threads-per-queue default of ' + str(threads_per_queue) + '? (y/N): ')
if 'y' == tpq or 'Y' == tpq:
response = 'x'
while (not response.isdigit()):
response = raw_input('Enter threads-per-queue value: ')
if response == '':
continue
threads_per_queue = response
# Load factor:
if use_standard:
response = 'x'
while (not response.isdigit()):
print '"1x" load is 2000 reads per second and 1000 writes per second.'
response = raw_input('Enter the load factor (e.g. enter 1 for 1x test): ')
if response == '':
continue
device_load = int(response)
read_reqs_per_sec = no_of_devices * device_load * 2000
write_reqs_per_sec = no_of_devices * device_load * 1000
# Save file:
response = ''
while response == '':
response = raw_input('Do you want to save this config to a file? (y/N): ')
if 'y' == response or 'Y' == response:
if device_load > 0:
load_tag = str(device_load) + 'x'
filename_load_tag = load_tag
else:
load_tag = 'non-standard'
filename_load_tag = str(read_reqs_per_sec / no_of_devices) + 'r' + str(write_reqs_per_sec / no_of_devices) + 'w'
devices = device_names.split(',')
device_names = '_'.join([ d.split('/')[-1] for d in devices ])
actfile = "config_%s_%dh_%s.txt"%(filename_load_tag,tds,device_names)
try:
act_file_fd = open(actfile, "wb")
act_file_fd.write('##########\n')
act_file_fd.write('act config file for testing ' + str(no_of_devices) + ' device(s) at ' + load_tag + ' load\n')
act_file_fd.write('##########\n\n')
act_file_fd.write('# comma-separated list:\n')
act_file_fd.write('device-names: %s\n\n' % str(device_names))
act_file_fd.write('# yes|no - default is no:\n')
act_file_fd.write('queue-per-device: %s\n\n' % str(queue_per_device))
act_file_fd.write('# mandatory non-zero, ignored if queue-per-device is yes:\n')
act_file_fd.write('num-queues: %s\n\n' % str(num_queues))
act_file_fd.write('# mandatory non-zero:\n')
act_file_fd.write('threads-per-queue: %s\n' % str(threads_per_queue))
act_file_fd.write('test-duration-sec: %s\n' % str(test_duration_sec))
act_file_fd.write('report-interval-sec: %s\n' % str(report_interval_sec))
act_file_fd.write('large-block-op-kbytes: %s\n\n' % str(large_block_op_kbytes))
act_file_fd.write('record-bytes: %s\n' % str(record_bytes))
act_file_fd.write('read-reqs-per-sec: %s\n\n' % str(read_reqs_per_sec))
act_file_fd.write('# usually non-zero:\n')
act_file_fd.write('write-reqs-per-sec: %s\n' % str(write_reqs_per_sec))
act_file_fd.write('# yes|no - default is no:\n')
act_file_fd.write('use-valloc: %s\n\n' % str(use_valloc))
act_file_fd.write('# noop|cfq - default is noop:\n')
act_file_fd.write('scheduler-mode: %s\n' % str(scheduler_mode))
act_file_fd.close()
print 'Config file '+ str(actfile) + ' successfully created.'
except Exception, i:
print '\nException: ', i
except Exception, i:
print '\nException: ', i
if __name__ == '__main__':
try:
RunCommand().onecmd('createconfig')
except (KeyboardInterrupt, SystemExit):
print "getting error"