fake run_test
diff --git a/fake_run_test.py b/fake_run_test.py
new file mode 100644
index 0000000..7797cfc
--- /dev/null
+++ b/fake_run_test.py
@@ -0,0 +1,107 @@
+import json
+import sys
+
+import run_test
+
+
+logger = run_test.logger
+tool = None
+
+
+class FakeVMContext(object):
+ def __init__(self, *args, **kwargs):
+ pass
+
+ def __enter__(self):
+ return ["fake@fake"]
+
+ def __exit__(self, *args, **kwargs):
+ pass
+
+
+def fake_start_vms(*args, **kwargs):
+ return FakeVMContext
+
+
+class FakeFD(object):
+ def __init__(self, content):
+ self.content = content
+ self.channel = FakeChannel()
+
+ def read(self):
+ return self.content
+
+
+class FakeChannel(object):
+ def recv_exit_status(self):
+ return 0
+
+
+def get_fake_out(cmd):
+ empty_fd = FakeFD("")
+ if "pgbench" == tool:
+ if "run" in cmd:
+ out = FakeFD("2 1:43\n2 1:42\n4 2:77")
+ else:
+ out = empty_fd
+ elif "iozone" == tool or "fio" == tool:
+ data = {'__meta__': {
+ 'direct_io': 1,
+ 'action': 'r',
+ 'concurence': 1,
+ 'blocksize': 1,
+ 'sync': 's'},
+ 'bw_mean': 10}
+ out = FakeFD(json.dumps(data))
+ else:
+ raise Exception("tool not found")
+ err = empty_fd
+ return empty_fd, out, err
+
+
+def fake_ssh_connect(*args, **kwargs):
+ return FakeSSH()
+
+
+class FakeSFTP(object):
+ def put(self, what, where):
+ logger.debug("Called sftp put with %s %s" % (what, where))
+
+ def chmod(self, f, mode):
+ logger.debug("called sftp chmod %s %s" % (mode, f))
+
+ def close(self):
+ logger.debug("called sftp close")
+
+
+class FakeSSH(object):
+ def exec_command(self, cmd, **kwargs):
+ return get_fake_out(cmd)
+
+ def close(self):
+ pass
+
+ def open_sftp(self):
+ return FakeSFTP()
+
+
+class FakePopen(object):
+ def __init__(self, cmd,
+ shell=True,
+ stdout=None,
+ stderr=None,
+ stdin=None):
+ print "Running subprocess command: %s" % cmd
+ self.stdin, self.stdout, self.stderr = get_fake_out(cmd)
+
+ def wait(self):
+ return 0
+
+
+if __name__ == '__main__':
+ run_test.subprocess.Popen = FakePopen
+ run_test.start_test_vms = fake_start_vms()
+ run_test.ssh_runner.ssh_connect = fake_ssh_connect
+ opts = run_test.parse_args(sys.argv[1:])
+ tool = opts.tool_type
+ exit(run_test.main(sys.argv[1:]))
diff --git a/formatters.py b/formatters.py
index fc3bd4c..2a47649 100644
--- a/formatters.py
+++ b/formatters.py
@@ -62,7 +62,10 @@
sum_res = sum([r[1] for r in results])
mean = sum_res/len(results)
sum_sq = sum([(r[1] - mean) ** 2 for r in results])
- dev = math.sqrt(sum_sq / (len(results) - 1))
+ if len(results) > 1:
+ dev = math.sqrt(sum_sq / (len(results) - 1))
+ else:
+ dev = 0
data[key] = (mean, dev)
return data
diff --git a/run_test.py b/run_test.py
index 67dd298..c6f1d81 100644
--- a/run_test.py
+++ b/run_test.py
@@ -29,9 +29,9 @@
logger = logging.getLogger("io-perf-tool")
-logger.setLevel(logging.INFO)
+logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
-ch.setLevel(logging.INFO)
+ch.setLevel(logging.DEBUG)
logger.addHandler(ch)
log_format = '%(asctime)s - %(levelname)s - %(name)s - %(message)s'
@@ -138,7 +138,7 @@
description="Run disk io performance test")
parser.add_argument("tool_type", help="test tool type",
- choices=['iozone', 'fio', 'pgbench'])
+ choices=['iozone', 'fio', 'pgbench', 'two_scripts'])
parser.add_argument("-l", dest='extra_logs',
action='store_true', default=False,
@@ -150,13 +150,6 @@
parser.add_argument("-f", "--test-opts-file", dest='opts_file',
type=argparse.FileType('r'), default=None,
help="file with cmd line options for test")
- #
- # parser.add_argument("-t", "--test-directory", help="directory with test",
- # dest="test_directory", required=True)
-
- parser.add_argument("-t", "--test", help="test to run",
- dest="test_directory", required=True,
- choices=['io', 'pgbench', 'two_scripts'])
parser.add_argument("--max-preparation-time", default=300,
type=int, dest="max_preparation_time")