fix modules and 2.6 compatibility
diff --git a/wally/suits/io/__init__.py b/wally/suits/io/__init__.py
index afb6ac1..978fa46 100644
--- a/wally/suits/io/__init__.py
+++ b/wally/suits/io/__init__.py
@@ -4,10 +4,12 @@
import logging
import datetime
-from wally.utils import (ssize2b, open_for_append_or_create,
- sec_to_str, StopTestError)
+import paramiko
-from wally.ssh_utils import save_to_remote, read_from_remote, BGSSHTask
+from wally.utils import (ssize2b, sec_to_str, StopTestError)
+
+from wally.ssh_utils import (save_to_remote, read_from_remote, BGSSHTask,
+ reconnect)
from ..itest import IPerfTest, TestResults
from .formatter import format_results_for_console
@@ -30,7 +32,8 @@
'results': self.results,
'raw_result': self.raw_result,
'run_interval': self.run_interval,
- 'vm_count': self.vm_count
+ 'vm_count': self.vm_count,
+ 'test_name': self.test_name
}
@classmethod
@@ -41,7 +44,7 @@
return cls(sec, data['params'], data['results'],
data['raw_result'], data['run_interval'],
- data['vm_count'])
+ data['vm_count'], data['test_name'])
def get_slice_parts_offset(test_slice, real_inteval):
@@ -77,6 +80,9 @@
self.results_file = self.join_remote("results.json")
self.pid_file = self.join_remote("pid")
self.task_file = self.join_remote("task.cfg")
+ self.sh_file = self.join_remote("cmd.sh")
+ self.err_out_file = self.join_remote("fio_err_out")
+ self.exit_code_file = self.join_remote("exit_code")
self.use_sudo = self.options.get("use_sudo", True)
self.test_logging = self.options.get("test_logging", False)
self.raw_cfg = open(self.config_fname).read()
@@ -252,6 +258,9 @@
self.config_params, res,
full_raw_res, interval,
vm_count=self.total_nodes_count)
+ tres.test_name = os.path.basename(self.config_fname)
+ if tres.test_name.endswith('.cfg'):
+ tres.test_name = tres.test_name[:-4]
self.on_result_cb(tres)
except (OSError, StopTestError):
raise
@@ -263,31 +272,38 @@
barrier.exit()
def do_run(self, barrier, cfg_slice, pos, nolog=False):
- # return open("/tmp/lit-sunshine/io/results.json").read(), (1, 2)
+ bash_file = "#!/bin/bash\n" + \
+ "fio --output-format=json --output={out_file} " + \
+ "--alloc-size=262144 {job_file} " + \
+ " >{err_out_file} 2>&1 \n" + \
+ "echo $? >{res_code_file}\n"
+
conn_id = self.node.get_conn_id()
fconn_id = conn_id.replace(":", "_")
- cmd_templ = "fio --output-format=json --output={1} " + \
- "--alloc-size=262144 {0}"
+ # cmd_templ = "fio --output-format=json --output={1} " + \
+ # "--alloc-size=262144 {0}"
- if self.options.get("use_sudo", True):
- cmd_templ = "sudo " + cmd_templ
+ bash_file = bash_file.format(out_file=self.results_file,
+ job_file=self.task_file,
+ err_out_file=self.err_out_file,
+ res_code_file=self.exit_code_file)
task_fc = "\n\n".join(map(str, cfg_slice))
with self.node.connection.open_sftp() as sftp:
save_to_remote(sftp, self.task_file, task_fc)
+ save_to_remote(sftp, self.sh_file, bash_file)
fname = "{0}_{1}.fio".format(pos, fconn_id)
with open(os.path.join(self.log_directory, fname), "w") as fd:
fd.write(task_fc)
- cmd = cmd_templ.format(self.task_file, self.results_file)
-
exec_time = sum(map(execution_time, cfg_slice))
exec_time_str = sec_to_str(exec_time)
timeout = int(exec_time + max(300, exec_time))
soft_tout = exec_time
+
barrier.wait()
if self.is_primary:
@@ -305,8 +321,28 @@
self.run_over_ssh("cd " + os.path.dirname(self.task_file), nolog=True)
task = BGSSHTask(self.node, self.options.get("use_sudo", True))
begin = time.time()
- task.start(cmd)
- task.wait(soft_tout, timeout)
+
+ if self.options.get("use_sudo", True):
+ sudo = "sudo "
+ else:
+ sudo = ""
+
+ task.start(sudo + "bash " + self.sh_file)
+
+ while True:
+ try:
+ task.wait(soft_tout, timeout)
+ break
+ except paramiko.SSHException:
+ pass
+
+ try:
+ self.node.connection.close()
+ except:
+ pass
+
+ reconnect(self.node.connection, self.node.conn_url)
+
end = time.time()
if not nolog:
@@ -326,7 +362,18 @@
with self.node.connection.open_sftp() as sftp:
result = read_from_remote(sftp, self.results_file)
+ exit_code = read_from_remote(sftp, self.exit_code_file)
+ err_out = read_from_remote(sftp, self.err_out_file)
+ exit_code = exit_code.strip()
+
+ if exit_code != '0':
+ msg = "fio exit with code {0}: {1}".format(exit_code, err_out)
+ logger.critical(msg.strip())
+ raise StopTestError("fio failed")
+
sftp.remove(self.results_file)
+ sftp.remove(self.err_out_file)
+ sftp.remove(self.exit_code_file)
fname = "{0}_{1}.json".format(pos, fconn_id)
with open(os.path.join(self.log_directory, fname), "w") as fd:
diff --git a/wally/suits/io/check_distribution.cfg b/wally/suits/io/check_distribution.cfg
index 4746f37..9475cde 100644
--- a/wally/suits/io/check_distribution.cfg
+++ b/wally/suits/io/check_distribution.cfg
@@ -10,4 +10,4 @@
ramp_time=5
runtime=30
-size=10G
+size=200G
diff --git a/wally/suits/io/hdd.cfg b/wally/suits/io/hdd.cfg
index 4b242a8..0eb85a6 100644
--- a/wally/suits/io/hdd.cfg
+++ b/wally/suits/io/hdd.cfg
@@ -1,17 +1,15 @@
[global]
include defaults.cfg
-NUM_ROUNDS=3
-
# NUMJOBS={% 1, 5, 10, 15, 20, 30, 40, 80 %}
-NUMJOBS={% 1, 5, 10 %}
+NUMJOBS={% 1, 3, 5, 10, 20, 40 %}
write_lat_log=fio_log
write_iops_log=fio_log
log_avg_msec=500
-size=10G
+size={TEST_FILE_SIZE}
ramp_time=5
runtime=30