diff options
-rw-r--r-- | README.md | 9 | ||||
-rwxr-xr-x | glustolibs-io/glustolibs/io/utils.py | 128 |
2 files changed, 136 insertions, 1 deletions
@@ -71,6 +71,13 @@ Pre-requisites to run glusto-tests: - Gluster client packages should be installed on Clients - Setup passwordless ssh from the glusto-tests management node to all. - Install glusto-tests dependencies on servers and clients. +- Crefi should be installed on all the clients. + + ``` + $ pip install crefi + $ pip install pyxattr + ``` + - Setup bricks on all servers: - To create bricks refer to [doc](https://gluster.readthedocs.io/en/latest/Administrator%20Guide/formatting-and-mounting-bricks/) **OR** Run gdeploy as shown below. 1. Edit the `gdeploy_sample_config.conf` present in `examples` as shown below and also configure passwordless ssh to all servers: @@ -97,7 +104,7 @@ Pre-requisites to run glusto-tests: ``` gdeploy -c gdeploy_sample_config.conf ``` -Note: +**Note:** - To run cifs protocol: 1.CIFS packages need to be installed on the server diff --git a/glustolibs-io/glustolibs/io/utils.py b/glustolibs-io/glustolibs/io/utils.py index 52c2c7df0..ba73b1711 100755 --- a/glustolibs-io/glustolibs/io/utils.py +++ b/glustolibs-io/glustolibs/io/utils.py @@ -800,3 +800,131 @@ def check_arequal_bricks_replicated(mnode, volname): g.log.info('Arequals for subvol and %s are equal', brick) g.log.info('All arequals are equal for volume %s', volname) return True + + +def run_crefi(client, mountpoint, number, breadth, depth, thread=5, + random_size=False, fop='create', filetype='text', + minfs=10, maxfs=500, single=False, multi=False, size=100, + interval=100, nameBytes=10, random_filename=True): + """ + A function to run crefi on a given mount point and generate I/O. + + Args: + client(str): Client on which I/O has to be performed. + mountpoint(str): Mount point where the client is mounted. + number(int): Number of files to be created. + breadth(int): Number of directories in one level. + depth(int): Number of levels of directories. + + Kwargs: + thread(int): Number of threads used to generate fop. + random_size(bool): Random size of the file between min and max. + fop(str): fop can be [create|rename|chmod|chown|chgrp|symlink|hardlink| + truncate|setxattr] this specifies the type of fop to be + executed by default it is create. + filetype(str): filetype can be [text|sparse|binary|tar] this specifies + the type of file by default it is text. + minfs(int): If random is set to true then this value has to be altered + to change minimum file size. (Value is in KB) + maxfs(int): If random is set to true then this value has to be altered + to change maximum file size. (Value is in KB) + single(bool): Create files in a single directory. + multi(bool): Create files in sub-dir and sub-sub dir. + size(int): Size of the files to be created. (Value is in KB) + interval(int): Print number files created of interval. + nameBytes(int): Number of bytes for filename. (Value is in Bytes) + random_filename(bool): It creates files with random names, if set to + False it creates files with file name file1, + file2 and so on. + + Returns: + bool: True if I/O was sucessfully otherwise False. + + NOTE: + To use this function it is a prerequisite to have crefi installed + on all the clients. Please use the below command to install it: + $ pip install crefi + $ pip install pyxattr + """ + + # Checking value of fop. + list_of_fops = ["create", "rename", "chmod", "chown", "chgrp", "symlink", + "hardlink", "truncate", "setxattr"] + if fop not in list_of_fops: + g.log.error("fop value is not valid.") + return False + + # Checking value of filetype. + list_of_filetypes = ["text", "sparse", "binary", "tar"] + if filetype not in list_of_filetypes: + g.log.error("filetype is not a valid file type.") + return False + + # Checking if single and multi both are set to true. + if single and multi: + g.log.error("single and mutli both can't be true.") + return False + + # Checking if file size and random size arguments are given together. + if (size > 100 or size < 100) and random_size: + g.log.error("Size and Random size can't be used together.") + return False + + # Checking if minfs is greater than or equal to maxfs. + if random_size and (minfs >= maxfs): + g.log.error("minfs shouldn't be greater than or equal to maxfs.") + return False + + # Creating basic command. + command = ("crefi %s -n %s -b %s -d %s " + % (mountpoint, number, breadth, depth)) + + # Checking thread value and adding it, If it is greater or smaller than 5. + if thread > 5 or thread < 5: + command = command + ("-T %s " % thread) + + # Checking if random size is true or false. + if random_size: + command = command + "--random " + if minfs > 10 or minfs < 10: + command = command + ("--min %s " % minfs) + if maxfs > 500 or maxfs < 500: + command = command + ("--max %s " % maxfs) + + # Checking fop and adding it if not create. + if fop != "create": + command = command + ("--fop %s " % fop) + + # Checking if size if greater than or less than 100. + if size > 100 or size < 100: + command = command + ("--size %s " % size) + + # Checking if single or mutli is true. + if single: + command = command + "--single " + if multi: + command = command + "--multi " + + # Checking if random_filename is false. + if not random_filename: + command = command + "-R " + + # Checking if print interval is greater than or less than 100. + if interval > 100 or interval < 100: + command = command + ("-I %s " % interval) + + # Checking if name Bytes is greater than or less than 10. + if nameBytes > 10 or nameBytes < 10: + command = command + ("-l %s " % nameBytes) + + # Checking filetype and setting it if not + # text. + if filetype != "text": + command = command + ("-t %s " % filetype) + + # Running the command on the client node. + ret, _, _ = g.run(client, command) + if ret: + g.log.error("Failed to run crefi on %s." % client) + return False + return True |