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:]))