Add options to select different test szenarios
Added: - test for read-write - make iointerface selectable
This commit is contained in:
parent
c115a9e38e
commit
64256add50
@ -9,8 +9,16 @@ import sys
|
|||||||
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Global variables and defaults
|
# Global variables and defaults
|
||||||
################################################################################
|
################################################################################
|
||||||
|
iointerfaces_allowed = [
|
||||||
|
'async',
|
||||||
|
'cached',
|
||||||
|
'direct',
|
||||||
|
'sync',
|
||||||
|
'dsync'
|
||||||
|
]
|
||||||
|
|
||||||
ioping_arguments = {
|
ioping_arguments = {
|
||||||
'location': '',
|
'location': '',
|
||||||
'cmd': 'ioping --batch',
|
'cmd': 'ioping --batch',
|
||||||
@ -28,7 +36,7 @@ def capture_ioping_results():
|
|||||||
if ioping_arguments['location'] == '':
|
if ioping_arguments['location'] == '':
|
||||||
return 1, '', 'No ioping_locationectory given.'
|
return 1, '', 'No ioping_locationectory given.'
|
||||||
|
|
||||||
cmd = '%s %s --count %s --interval %s %s' % (ioping_arguments['cmd'],
|
cmd = '%s %s --count %s --interval %s %s' % (ioping_arguments['cmd'],
|
||||||
ioping_arguments['options'],
|
ioping_arguments['options'],
|
||||||
ioping_arguments['count'],
|
ioping_arguments['count'],
|
||||||
ioping_arguments['interval'],
|
ioping_arguments['interval'],
|
||||||
@ -41,7 +49,7 @@ def capture_ioping_results():
|
|||||||
return ioping_output.returncode, ioping_output.stdout, ioping_output.stderr
|
return ioping_output.returncode, ioping_output.stdout, ioping_output.stderr
|
||||||
|
|
||||||
|
|
||||||
# Function to output the ioping capture on an interactive shell
|
# Function to output the ioping capture on an interactive shell
|
||||||
def ioping_output_shell():
|
def ioping_output_shell():
|
||||||
returncode, stdout, stderr = capture_ioping_results()
|
returncode, stdout, stderr = capture_ioping_results()
|
||||||
print("%s\n" % (ioping_arguments['cmd']))
|
print("%s\n" % (ioping_arguments['cmd']))
|
||||||
@ -60,7 +68,7 @@ def ioping_output_telegraf():
|
|||||||
|
|
||||||
if not returncode == 0:
|
if not returncode == 0:
|
||||||
print(stderr)
|
print(stderr)
|
||||||
return returncode
|
return returncode
|
||||||
|
|
||||||
ioping_statistic_keys = [
|
ioping_statistic_keys = [
|
||||||
'statistics_count',
|
'statistics_count',
|
||||||
@ -88,21 +96,25 @@ def ioping_output_telegraf():
|
|||||||
|
|
||||||
def get_parser():
|
def get_parser():
|
||||||
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
||||||
parser.add_argument('-c', '--count',
|
parser.add_argument('-c', '--count',
|
||||||
help = 'stop after <count> requests',
|
help = 'stop after <count> requests',
|
||||||
default = '10')
|
default = '10')
|
||||||
parser.add_argument('-i', '--interval',
|
parser.add_argument('-i', '--interval',
|
||||||
help = 'interval between requests',
|
help = 'interval between requests',
|
||||||
default = '1s')
|
default = '1s')
|
||||||
parser.add_argument('-l', '--location',
|
parser.add_argument('--iointerface',
|
||||||
|
help = 'Which ionterface to use: async|cached|direct|sync|dsync',
|
||||||
|
default = '')
|
||||||
|
parser.add_argument('-l', '--location',
|
||||||
help = 'directory|file|device to test. Best would be a directory to not shred anything accidentially',
|
help = 'directory|file|device to test. Best would be a directory to not shred anything accidentially',
|
||||||
default = '/tmp')
|
default = '/tmp')
|
||||||
parser.add_argument('-m', '--mode',
|
parser.add_argument('-m', '--mode',
|
||||||
help = 'Which output mode to use: shell|telegraf',
|
help = 'Which output to use: shell|telegraf',
|
||||||
default = 'telegraf')
|
default = 'telegraf')
|
||||||
parser.add_argument('-o', '--options',
|
parser.add_argument('-w', '--read-write',
|
||||||
help = 'Arbitary options from the ioping options, like -read-write',
|
help = 'Use read-write test instead of read.',
|
||||||
default = '')
|
action = 'store_true',
|
||||||
|
default = 'False')
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
@ -114,7 +126,12 @@ def main():
|
|||||||
ioping_arguments['location'] = args.location
|
ioping_arguments['location'] = args.location
|
||||||
ioping_arguments['count'] = args.count
|
ioping_arguments['count'] = args.count
|
||||||
ioping_arguments['interval'] = args.interval
|
ioping_arguments['interval'] = args.interval
|
||||||
ioping_arguments['options'] = args.options
|
if args.read_write == True:
|
||||||
|
ioping_arguments['options'] += '--read-write '
|
||||||
|
if not args.iointerface == '':
|
||||||
|
if args.iointerface in iointerfaces_allowed:
|
||||||
|
ioping_arguments['options'] += '--%s ' % args.iointerface
|
||||||
|
|
||||||
|
|
||||||
if args.mode == 'shell':
|
if args.mode == 'shell':
|
||||||
returncode = ioping_output_shell()
|
returncode = ioping_output_shell()
|
||||||
@ -122,13 +139,12 @@ def main():
|
|||||||
returncode = ioping_output_telegraf()
|
returncode = ioping_output_telegraf()
|
||||||
else:
|
else:
|
||||||
returncode = 1
|
returncode = 1
|
||||||
|
|
||||||
return returncode
|
return returncode
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Main main main
|
# Main main main
|
||||||
################################################################################
|
################################################################################
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user