summaryrefslogtreecommitdiffstats
path: root/glustolibs-gluster/glustolibs/gluster/glusterfile.py
Commit message (Collapse)AuthorAgeFilesLines
* [Test+Lib] Add test to check rebalance impact on aclkshithijiyer2020-12-181-0/+76
| | | | | | | | | | | | | | | | | | | | Test case: 1. Create a volume, start it and mount it to a client. 2. Create 10 files on the mount point and set acls on the files. 3. Check the acl value and collect arequal-checksum. 4. Add bricks to the volume and start rebalance. 5. Check the value of acl(it should be same as step 3), collect and compare arequal-checksum with the one collected in step 3 Additional functions added: a. set_acl(): Set acl rule on a specific file b. get_acl(): Get all acl rules set to a file c. delete_acl(): Delete a specific or all acl rules set on a file Change-Id: Ia420cbcc8daea272cd4a282ae27d24f13b4991fe Signed-off-by: kshithijiyer <kshithij.ki@gmail.com>
* [Libfix] Fix python3 getfattr() issueskshithijiyer2020-08-171-3/+5
| | | | | | | | | | | | | | | | | Problem: Due to patch [1] which was sent for issue #24 causes a large number of testcases to fail or get stuck in the latest DHT run. Solution: Make changes sot that getfattr command sends back the output in text wherever needed. Links: [1] https://review.gluster.org/#/c/glusto-tests/+/24841/ Change-Id: I6390e38130b0699ceae652dee8c3b2db2ef3f379 Signed-off-by: kshithijiyer <kshithij.ki@gmail.com>
* [LibFix] Add encoding type to get_fattr()sayaleeraut2020-08-121-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | Currently the get_fattr() function returns the xattr value in the hex encoding format. Adding the option to add/specify other encoding types, i.e. text and base64, where hex will be the default encoding format. Reason - When the xattrs are custom set through mountpoint, it becomes easier to test if the value is correct by using the "text" encoding. Example - >>> ret = get_fattr(host, fqpath, fattr) >>> print ret 0x414243 >>> ret = get_fattr(host, fqpath, fattr, encode="text") >>> print ret "ABC" The value "ABC" is easily readable as opposed to 0x414243 when performing a test. Change-Id: Ie2377b924816ebab0a2af116d82600e01f03d61f Signed-off-by: sayaleeraut <saraut@redhat.com>
* [Libfix] Fix UnicodeDecodeError in get_fattr()kshithijiyer2020-08-111-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Some testcases fail with UnicodeDecodeError when the framework is run using python3. This happens becuase the get_fattr() command returns non-unicode output which leads to data.decode() used in subprocess.Popen to fail. This isn't the case in python2 as it doesn't bother about encoding and dumps whatever is the output back to the management node. ``` gfid = get_fattr(brick_tuple[0], brick_path + '/' + direc, 'trusted.gfid') /root/glusto-tests/tests/functional/dht/test_dht_create_dir.py:127: /usr/local/lib/python3.8/site-packages/glustolibs_gluster-0.22-py3.8.egg/glustolibs/gluster/glusterfile.py:113: in get_fattr rcode, rout, rerr = g.run(host, command) /usr/local/lib/python3.8/site-packages/glusto-0.72-py3.8.egg/glusto/connectible.py:132: in run stdout, stderr = proc.communicate() /usr/lib64/python3.8/subprocess.py:1024: in communicate stdout, stderr = self._communicate(input, endtime, timeout) /usr/lib64/python3.8/subprocess.py:1904: in _communicate stdout = self._translate_newlines(stdout, self = <subprocess.Popen object at 0x7f22b4e2f490>, data = b'\xber\t\nO\xebO\xee\xa4\x9c\xc4L\xac\x1cj\xd5', encoding = 'UTF-8', errors = 'strict' def _translate_newlines(self, data, encoding, errors): data = data.decode(encoding, errors) E UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbe in position 0: invalid start byte /usr/lib64/python3.8/subprocess.py:901: UnicodeDecodeError ``` Solution: Change get_fattr() command to return xattr value in hex to avoid UnicodeDecodeError error from Popen. Fixes: https://github.com/gluster/glusto-tests/issues/24 Change-Id: I8c4786c882adf6079404b97eca2c399535db068f Signed-off-by: kshithijiyer <kshithij.ki@gmail.com>
* [Testfix] Add logic to log more infokshithijiyer2020-08-061-3/+10
| | | | | | | | | Adding code to get dir tree and dump all xattr in hex for Bug 1810901 before remove-brick also adding logic to set log-level to debug. Change-Id: I9c9c970c4de7d313832f6f189cdca8428a073b1e Signed-off-by: kshithijiyer <kshithij.ki@gmail.com>
* [Libfix] Fix is_linkto_file() compatible with newer platformsPranav2020-06-301-5/+2
| | | | | | | | | | | | | Problem: The 'file <file_path>' command output differs in newer platforms. An additional ',' is present in latest builds of the packages, causing tests which uses this method to fail on newer platforms. Fix: Modify the method to handle the latest package output as well Change-Id: I3e59a69b09b960e3a38131a3e76d664b34799ab1 Signed-off-by: Pranav <prprakas@redhat.com>
* [Libfix] Assign correct atime, ctime, mtime valuesnchilaka2020-05-151-2/+2
| | | | | | | | | Changed get_file_stat function to assign correct key-value pairs for atime, mtime and ctime respectively. Previously, all timestamp keys were assigned to atime value Change-Id: I471ec341d1a213395a89f6c01315f3d0f2e976af Signed-off-by: nchilaka <nchilaka@redhat.com>
* [Libfix] Added atime, ctime and mtime for filesBala Konda Reddy M2020-05-141-2/+10
| | | | | | | | | | | | | | | | | | | | | get_file_stat function doesn't have access time modified time and change time for a file or directory. Added respective parameters for get- ting the values into the dictionary. Changed the separator from ':' to '$', reason is to overcome the unpacking of the tuple error as below: 2020-04-02 19:27:45.962477021 If ":" as separator is used, will be hitting "ValueError: too many values to unpack" error. Used $ as separator, as it is not used for the filenames in the glusto-tests and not part of the stat output. Change-Id: I40b0c1fd08a5175d3730c1cf8478d5ad8df6e8dd Signed-off-by: Bala Konda Reddy M <bala12352@gmail.com>
* [Lib] Add create_link_file() to glusterfile.pykshithijiyer2020-05-041-0/+39
| | | | | | | | Adding function create_link_file() to create soft and hard links for an existing file. Change-Id: I6be313ded1a640beb450425fbd29374df51fbfa3 Signed-off-by: kshithijiyer <kshithij.ki@gmail.com>
* [Test+Lib] No fresh lookups on directoryBala Konda Reddy M2020-04-281-0/+33
| | | | | | | | | | | | | | | | | | | Test Steps: 1. Create a volume and set the volume option 'diagnostics.client-log-level' to DEBUG mount the volume on one client. 2. Create a directory 3. Validate the number of lookups for the directory creation from the log file. 4. Perform a new lookup of the directory 5. No new lookups should have happened on the directory, validate from the log file. 6. Bring down one subvol of the volume and repeat step 4, 5 7. Bring down one brick from the online bricks and repeat step 4, 5 8. Start the volume with force and wait for all process to be online. Change-Id: I162766837fd7e61625238a669c4050c2ec9c8a8b Signed-off-by: Bala Konda Reddy M <bmekala@redhat.com>
* [Libfix] Remove rpyc_get_connection() dependency from codekshithijiyer2020-04-011-16/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: `g.rpyc_get_connection()` has a limitaion where it can't convert python2 calls to python3 calls. Due to this a large number of testcases fail when executed from a python2 machine on a python3 only setup or visa versa with the below stack trace: ``` E ========= Remote Traceback (1) ========= E Traceback (most recent call last): E File "/root/tmp.tL8Eqx7d8l/rpyc/core/protocol.py", line 323, in _dispatch_request E res = self._HANDLERS[handler](self, *args) E File "/root/tmp.tL8Eqx7d8l/rpyc/core/protocol.py", line 591, in _handle_inspect E if hasattr(self._local_objects[id_pack], '____conn__'): E File "/root/tmp.tL8Eqx7d8l/rpyc/lib/colls.py", line 110, in __getitem__ E return self._dict[key][0] E KeyError: (b'rpyc.core.service.SlaveService', 94282642994712, 140067150858560) ``` Solution: The solution here is to modify the code to not use `g.rpyc_get_connection()`. The following changes are done to accomplish it: 1)Remove code which uses g.rpyc_get_connection() and use generic logic in functions: a. do_bricks_exist_in_shd_volfile() b. get_disk_usage() c. mount_volume() d. list_files() f. append_string_to_file() 2)Create files which can be uploaded and executed on clients/servers to avoid rpc calls in functions: a. calculate_hash() b. validate_files_in_dir() 3)Modify setup.py to push the below files to `/usr/share/glustolibs/scripts/`: a.compute_hash.py b.walk_dir.py Change-Id: I00a81a88382bf3f8b366753eebdb2999260788ca Signed-off-by: kshithijiyer <kshithij.ki@gmail.com>
* Adding find_and_replace_in_file & check_if_pattern_in_file to library.kshithijiyer2019-05-281-0/+46
| | | | | | | | | | | The function do the following in a nutshell: 1. find_and_replace_in_file: Find and replace a given pattern in a specific file. 2. check_if_pattern_in_file: Check if a give pattern is in seen in file or not. Change-Id: Ib035f54490592f2be32a30f0e8a10e7847812990 Signed-off-by: kshithijiyer <kshithij.ki@gmail.com>
* Using a raw strings for fixing flake warningsVitalii Koriakov2018-10-291-1/+1
| | | | | Change-Id: Ie134790ea05919a4b396657c11cbc3fc7a7fc529 Signed-off-by: Vitalii Koriakov <vkoriako@redhat.com>
* glustolibs/gluster/glusterfile: rpyc connection function callKartik_Burmee2018-04-161-1/+1
| | | | | | | | | | | | | | changed get_connection to rpyc_get_connection. executed a test case after this change and got this error - "error while loading shared libraries: libglusterfs.so.0 cannot open shared object file: No such file or directory". solved this path issue by adding shared library to system library path on my machine. Not sure if it'll be a common issue for everyone using this module. Change-Id: Id52df4b17bc3d30b808bb1eb77c87b03c3ed2f7b Signed-off-by: Kartik_Burmee <kburmee@redhat.com>
* initial dht libsJonathan Holloway2018-02-261-0/+710
* glusterfile.py - helper for gluster client and backend files. * glusterdir.py - helper for gluster client and backend dirs. * brickdir.py - helper for collection and hashing of brickdirs (from pathinfo data). * layout.py - base class for simple DHT layout validation. * dht_test_util.py - utility module to walk a directory tree and run tests against files. * constants.py - definitions for constants used in DHT libraries. * exceptions.py - definitions for exceptions raised in DHT libraries. Change-Id: I44770a822e0ec79561b3aa048e555320f622116a Signed-off-by: Jonathan Holloway <jholloway@redhat.com>