summaryrefslogtreecommitdiffstats
path: root/tests/distaf
diff options
context:
space:
mode:
authorShwetha Panduranga <spandura@redhat.com>2016-06-27 02:02:29 +0530
committerRaghavendra Talur <rtalur@redhat.com>2016-06-26 21:57:51 -0700
commit0d280e0b7f2042e78b8d94a48d5e3bcc5c13f422 (patch)
treea47f7f643db26c044e4e8506a068f87c49cc5fda /tests/distaf
parent7897e023e60f8cdfa6d7a5ea654214ad186dd033 (diff)
Adding simple test "running dd from mount".
Change-Id: Icbb799c401e73b51a7e96b86db78e46f6b0d5813 BUG: 1350258 Signed-off-by: Shwetha Panduranga <spandura@redhat.com> Reviewed-on: http://review.gluster.org/14807 Tested-by: ShwethaHPanduranga NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Raghavendra Talur <rtalur@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'tests/distaf')
-rw-r--r--tests/distaf/tests_d/sanity/__init__.py0
-rw-r--r--tests/distaf/tests_d/sanity/io_config.yml14
-rw-r--r--tests/distaf/tests_d/sanity/test_dd_writes.py139
3 files changed, 153 insertions, 0 deletions
diff --git a/tests/distaf/tests_d/sanity/__init__.py b/tests/distaf/tests_d/sanity/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/tests/distaf/tests_d/sanity/__init__.py
diff --git a/tests/distaf/tests_d/sanity/io_config.yml b/tests/distaf/tests_d/sanity/io_config.yml
new file mode 100644
index 00000000000..577c43eda09
--- /dev/null
+++ b/tests/distaf/tests_d/sanity/io_config.yml
@@ -0,0 +1,14 @@
+gluster:
+ tests:
+ io:
+ dd_writes:
+ num_of_files: 1
+ num_of_process_per_file: 1
+ input_file: /dev/urandom
+ block_size: random
+ count: 1
+ # oflag: append,direct,nonblock
+ # conv: fsync
+
+
+
diff --git a/tests/distaf/tests_d/sanity/test_dd_writes.py b/tests/distaf/tests_d/sanity/test_dd_writes.py
new file mode 100644
index 00000000000..3cff3ef8d82
--- /dev/null
+++ b/tests/distaf/tests_d/sanity/test_dd_writes.py
@@ -0,0 +1,139 @@
+from distaf.util import tc, testcase, globl_configs
+from distaflibs.gluster.gluster_base_class import GlusterBaseClass
+from distaflibs.gluster.mount_ops import mount_volume, umount_volume
+import os
+import random
+import yaml
+
+@testcase("test_dd_writes")
+class TestDdWrites(GlusterBaseClass):
+ """
+ runs_on_volumes: [ distribute, replicate, dist_rep ]
+ runs_on_protocol: [ glusterfs, nfs ]
+ reuse_setup: True
+ """
+ def __init__(self, globl_configs):
+ GlusterBaseClass.__init__(self, globl_configs)
+ self.filename = "dd_testfile"
+ io_config_file = os.path.join(os.path.dirname
+ (os.path.realpath(__file__)),
+ "io_config.yml")
+ dd_writes_config = yaml.load(open(io_config_file))
+ # Num of dd's to start per client/per file
+ self.num_of_dd_writes_process = (dd_writes_config['gluster']['tests']
+ ['io']['dd_writes']
+ ['num_of_process_per_file'])
+
+ # Num of files to create
+ self.num_of_files = (dd_writes_config['gluster']['tests']
+ ['io']['dd_writes']['num_of_files'])
+
+ # Input file for dd command
+ self.dd_input_file = (dd_writes_config['gluster']['tests']
+ ['io']['dd_writes']['input_file'])
+
+ # Block size
+ self.block_size = (dd_writes_config['gluster']['tests']
+ ['io']['dd_writes']['block_size'])
+ if "random" in self.block_size:
+ self.block_size = ["1k", "10k", "256k", "512k" ,"1M",
+ "10M", "100M", "256M", "512M", "1G"]
+
+ # dd count
+ self.dd_count = (dd_writes_config['gluster']['tests']
+ ['io']['dd_writes']['count'])
+
+ # dd CONV
+ if (dd_writes_config['gluster']['tests']['io']
+ ['dd_writes']).has_key('conv'):
+ self.dd_conv = (dd_writes_config['gluster']['tests']
+ ['io']['dd_writes']['conv'])
+ else:
+ self.dd_conv = None
+
+ # dd OFLAG
+ if (dd_writes_config['gluster']['tests']['io']
+ ['dd_writes']).has_key('oflag'):
+ self.dd_oflag = (dd_writes_config['gluster']['tests']
+ ['io']['dd_writes']['oflag'])
+ else:
+ self.dd_oflag = None
+
+
+ def setup(self):
+ ret = GlusterBaseClass.setup(self)
+ if not ret:
+ return False
+
+ if self.mounts:
+ for mount_obj in self.mounts:
+ ret = mount_obj.mount()
+ if not ret:
+ tc.logger.error("Mounting Volume %s failed on %s:%s" %
+ (mount_obj.volname,
+ mount_obj.client_system,
+ mount_obj.mountpoint))
+ return False
+ return True
+
+
+ def run(self):
+ rc = True
+ dd_cmd = "dd if=%s count=%s " % (self.dd_input_file, self.dd_count)
+ if self.dd_conv is not None:
+ dd_cmd += "conv=%s " % self.dd_conv
+
+ if self.dd_oflag is not None:
+ dd_cmd += "oflag=%s " % self.dd_oflag
+
+ all_mounts_cmd_runs = []
+ for mount_obj in self.mounts:
+ all_cmd_runs = []
+ for i in range(1, (self.num_of_files + 1)):
+ cmd_runs = []
+ for j in range(1, (self.num_of_dd_writes_process + 1)):
+ cmd = dd_cmd + ("of=%s bs=%s" %
+ (os.path.join(mount_obj.mountpoint,
+ self.filename + "_" + str(i)),
+ random.choice(self.block_size)))
+ tc.logger.info("Executing Command: %s", cmd)
+ ret = tc.run_async(mount_obj.client_system, cmd)
+ cmd_runs.append(ret)
+ all_cmd_runs.append(cmd_runs)
+ all_mounts_cmd_runs.append(all_cmd_runs)
+
+ for all_cmd_runs in all_mounts_cmd_runs:
+ for cmd_runs in all_cmd_runs:
+ for each_cmd_run in cmd_runs:
+ each_cmd_run.wait()
+
+ rc = True
+ for i, all_cmd_runs in enumerate(all_mounts_cmd_runs):
+ for j, cmd_runs in enumerate(all_cmd_runs):
+ for k, each_cmd_run in enumerate(cmd_runs):
+ ret, _, _ = each_cmd_run.value()
+ if ret != 0:
+ tc.logger.error("DD Writes failed on: %s/%s/%s:%d" %
+ (self.mounts[i].client_system,
+ self.mounts[i].mountpoint,
+ (self.filename + "_" + str(j)), k))
+ rc = False
+ if not rc:
+ tc.logger.error("DD Write failed on atleast one file")
+ return False
+ else:
+ tc.logger.info("DD Write successfully passed on all the files")
+ return True
+
+ def teardown(self):
+ for mount_obj in self.mounts:
+ cleanup_mount_cmd = "rm -rf %s/*" % mount_obj.mountpoint
+ ret, out, err = tc.run(mount_obj.client_system,
+ cleanup_mount_cmd)
+ for mount_obj in self.mounts:
+ mount_obj.unmount()
+ ret = GlusterBaseClass.teardown(self)
+ if not ret:
+ return False
+ return True
+