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 = {
|
||||
'location': '',
|
||||
'cmd': 'ioping --batch',
|
||||
@ -28,7 +36,7 @@ def capture_ioping_results():
|
||||
if ioping_arguments['location'] == '':
|
||||
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['count'],
|
||||
ioping_arguments['interval'],
|
||||
@ -41,7 +49,7 @@ def capture_ioping_results():
|
||||
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():
|
||||
returncode, stdout, stderr = capture_ioping_results()
|
||||
print("%s\n" % (ioping_arguments['cmd']))
|
||||
@ -60,7 +68,7 @@ def ioping_output_telegraf():
|
||||
|
||||
if not returncode == 0:
|
||||
print(stderr)
|
||||
return returncode
|
||||
return returncode
|
||||
|
||||
ioping_statistic_keys = [
|
||||
'statistics_count',
|
||||
@ -88,21 +96,25 @@ def ioping_output_telegraf():
|
||||
|
||||
def get_parser():
|
||||
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
||||
parser.add_argument('-c', '--count',
|
||||
parser.add_argument('-c', '--count',
|
||||
help = 'stop after <count> requests',
|
||||
default = '10')
|
||||
parser.add_argument('-i', '--interval',
|
||||
parser.add_argument('-i', '--interval',
|
||||
help = 'interval between requests',
|
||||
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',
|
||||
default = '/tmp')
|
||||
parser.add_argument('-m', '--mode',
|
||||
help = 'Which output mode to use: shell|telegraf',
|
||||
parser.add_argument('-m', '--mode',
|
||||
help = 'Which output to use: shell|telegraf',
|
||||
default = 'telegraf')
|
||||
parser.add_argument('-o', '--options',
|
||||
help = 'Arbitary options from the ioping options, like -read-write',
|
||||
default = '')
|
||||
parser.add_argument('-w', '--read-write',
|
||||
help = 'Use read-write test instead of read.',
|
||||
action = 'store_true',
|
||||
default = 'False')
|
||||
return parser
|
||||
|
||||
|
||||
@ -114,7 +126,12 @@ def main():
|
||||
ioping_arguments['location'] = args.location
|
||||
ioping_arguments['count'] = args.count
|
||||
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':
|
||||
returncode = ioping_output_shell()
|
||||
@ -122,13 +139,12 @@ def main():
|
||||
returncode = ioping_output_telegraf()
|
||||
else:
|
||||
returncode = 1
|
||||
|
||||
|
||||
return returncode
|
||||
|
||||
|
||||
################################################################################
|
||||
# Main main main
|
||||
# Main main main
|
||||
################################################################################
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
|
||||
sys.exit(main())
|
||||
Loading…
Reference in New Issue
Block a user