diff options
| author | Vijaykumar Koppad <vkoppad@redhat.com> | 2014-06-13 17:52:30 +0530 |
|---|---|---|
| committer | Vijay Bellur <vbellur@redhat.com> | 2015-04-13 10:01:49 +0000 |
| commit | b5d7faa96b5ca44be6899c6976691e0fde7d70d1 (patch) | |
| tree | e2fedcbfdcd0f55afe27f39c65e0c78c796dd34c /tests/geo-rep/compare-gfid.py | |
| parent | 5cb5d7029216ce71b19fd798a86ef4c384262ba9 (diff) | |
Geo-rep: Adding regression tests for geo-rep
This patch introduces upstream regression suit for geo-replication
* Modifies cleanup (tests/include.rc) to remove everything but
hook-scripts.
Prerequisites:
* Passwordless SSH from root to root of current host.
* Export /build/install/sbin and /build/install/bin to PATH
variable for root user.
Change-Id: I433dd8bbb17edba9baaf516fe0dce3133ba39184
BUG: 1101111
Signed-off-by: Vijaykumar Koppad <vkoppad@redhat.com>
Signed-off-by: Ajeet Jha <ajha@redhat.com>
Signed-off-by: Kotresh HR <khiremat@redhat.com>
Reviewed-on: http://review.gluster.org/7392
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Aravinda VK <avishwan@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'tests/geo-rep/compare-gfid.py')
| -rw-r--r-- | tests/geo-rep/compare-gfid.py | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/tests/geo-rep/compare-gfid.py b/tests/geo-rep/compare-gfid.py new file mode 100644 index 00000000000..432c1d77f31 --- /dev/null +++ b/tests/geo-rep/compare-gfid.py @@ -0,0 +1,95 @@ +#!/usr/bin/python + +# Most of this script was written by M S Vishwanath Bhat (vbhat@redhat.com) + +import re +import os +import sys +import xattr +import tempfile + + +def parse_url(url): + match = re.search(r'([\w - _ @ \.]+)::([\w - _ @ \.]+)', url) + if match: + node = match.group(1) + vol = match.group(2) + else: + print 'given url is not a valid url.' + sys.exit(1) + return node, vol + + +def cleanup(master_mnt, slave_mnt): + try: + os.system("umount %s" % (master_mnt)) + except: + print("Failed to unmount the master volume") + try: + os.system("umount %s" % (slave_mnt)) + except: + print("Failed to unmount the slave volume") + + os.removedirs(master_mnt) + os.removedirs(slave_mnt) + + +def main(): + + masterurl = sys.argv[1] + slaveurl = sys.argv[2] + slave_node, slavevol = parse_url(slaveurl) + master_node, mastervol = parse_url(masterurl) + + master_mnt = tempfile.mkdtemp() + slave_mnt = tempfile.mkdtemp() + + try: + print "Mounting master volume on a temp mnt_pnt" + os.system("glusterfs -s %s --volfile-id %s %s" % (master_node, + mastervol, + master_mnt)) + except: + print("Failed to mount the master volume") + cleanup(master_mnt, slave_mnt) + sys.exit(1) + + try: + print "Mounting slave voluem on a temp mnt_pnt" + os.system("glusterfs -s %s --volfile-id %s %s" % (slave_node, slavevol, + slave_mnt)) + except: + print("Failed to mount the master volume") + cleanup(master_mnt, slave_mnt) + sys.exit(1) + + slave_file_list = [slave_mnt] + for top, dirs, files in os.walk(slave_mnt, topdown=False): + for subdir in dirs: + slave_file_list.append(os.path.join(top, subdir)) + for file in files: + slave_file_list.append(os.path.join(top, file)) + + # chdir and then get the gfid, so that you don't need to replace + gfid_attr = 'glusterfs.gfid' + ret = 0 + for sfile in slave_file_list: + mfile = sfile.replace(slave_mnt, master_mnt) + if xattr.getxattr(sfile, gfid_attr, True) != xattr.getxattr( + mfile, gfid_attr, True): + print ("gfid of file %s in slave is different from %s" + + " in master" % (sfile, mfile)) + ret = 1 + + cleanup(master_mnt, slave_mnt) + + sys.exit(ret) + + +if __name__ == '__main__': + if len(sys.argv[1:]) < 2: + print ("Please pass master volume name and slave url as arguments") + print ("USAGE : python <script> <master-host>::<master-vol> " + + "<slave-host>::<slave-vol>") + sys.exit(1) + main() |
