From e25baace5a1e2f7cc7774303710f1d3d871233a2 Mon Sep 17 00:00:00 2001 From: ubansal Date: Mon, 24 Aug 2020 16:59:44 +0530 Subject: [Test] Checks data rename and delete in arbiter volume Steps: 1.Create a volume and mount it 2.Create deep directory and file in each directory 3.Rename the file 4.Check if brickpath contains old files 5.Delete all data 6.Check .glusterfs/indices/xattrop is empty 7.Check if brickpath is empty Change-Id: I04e50ef94379daa344be1ae1d19cf2d66f8f460b Signed-off-by: ubansal --- tests/functional/arbiter/test_data_delete.py | 110 +++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 tests/functional/arbiter/test_data_delete.py diff --git a/tests/functional/arbiter/test_data_delete.py b/tests/functional/arbiter/test_data_delete.py new file mode 100644 index 000000000..4753efcbc --- /dev/null +++ b/tests/functional/arbiter/test_data_delete.py @@ -0,0 +1,110 @@ +# Copyright (C) 2020 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +from glusto.core import Glusto as g +from glustolibs.gluster.gluster_base_class import (GlusterBaseClass, runs_on) +from glustolibs.gluster.exceptions import ExecutionError +from glustolibs.gluster.brick_libs import get_all_bricks + + +@runs_on([['arbiter', 'distributed-arbiter'], ['glusterfs']]) +class TestDataDelete(GlusterBaseClass): + """ + Description: + Test data delete/rename on arbiter volume + """ + def setUp(self): + # Calling GlusterBaseClass + self.get_super_method(self, 'setUp')() + + # Setup Volume and Mount Volume + ret = self.setup_volume_and_mount_volume(mounts=self.mounts) + if not ret: + raise ExecutionError("Failed to Setup_Volume and Mount_Volume") + g.log.info("Successful in Setup Volume and Mount Volume") + + def tearDown(self): + """ + Cleanup and umount volume + """ + + # Cleanup and umount volume + ret = self.unmount_volume_and_cleanup_volume(mounts=self.mounts) + if not ret: + raise ExecutionError("Failed to umount the vol & cleanup Volume") + g.log.info("Successful in umounting the volume and Cleanup") + + # Calling GlusterBaseClass teardown + self.get_super_method(self, 'tearDown')() + + def test_data_delete(self): + """ + Test steps: + - Get brick list + - Create files and rename + - Check if brick path contains old files + - Delete files from mountpoint + - Check .glusterfs/indices/xattrop is empty + - Check if brickpath is empty + """ + + # pylint: disable=too-many-branches,too-many-statements,too-many-locals + # Get the bricks from the volume + bricks_list = get_all_bricks(self.mnode, self.volname) + g.log.info("Brick List : %s", bricks_list) + + # Create files and rename + cmd = ('cd %s ;for i in `seq 1 100` ;do mkdir -pv directory$i;' + 'cd directory$i;dd if=/dev/urandom of=file$i bs=1M count=5;' + 'mv file$i renamed$i;done;' % (self.mounts[0].mountpoint)) + ret, _, _ = g.run(self.clients[0], cmd) + self.assertEqual(ret, 0, "Fail: Not able to create files on " + "{}".format(self.mounts[0].mountpoint)) + g.log.info("Files created successfully and renamed") + + # Check if brickpath contains old files + for brick in bricks_list: + brick_node, brick_path = brick.split(":") + cmd = ("ls -1 %s |grep file |wc -l " % brick_path) + ret, out, _ = g.run(brick_node, cmd) + self.assertEqual(0, int(out.strip()), "Brick path {} contains old " + "file in node {}".format(brick_path, brick_node)) + g.log.info("Brick path contains renamed files") + + # Delete files from mountpoint + cmd = ('rm -rf -v %s/*' % self.mounts[0].mountpoint) + ret, _, _ = g.run(self.mounts[0].client_system, cmd) + self.assertEqual(ret, 0, "Failed to delete files") + g.log.info("Files deleted successfully for %s", self.mounts[0]) + + # Check .glusterfs/indices/xattrop is empty + for brick in bricks_list: + brick_node, brick_path = brick.split(":") + cmd = ("ls -1 %s/.glusterfs/indices/xattrop/ | " + "grep -ve \"xattrop-\" | wc -l" % brick_path) + ret, out, _ = g.run(brick_node, cmd) + self.assertEqual(0, int(out.strip()), ".glusterfs/indices/" + "xattrop is not empty") + g.log.info("No pending heals on bricks") + + # Check if brickpath is empty + for brick in bricks_list: + brick_node, brick_path = brick.split(":") + cmd = ("ls -1 %s |wc -l " % brick_path) + ret, out, _ = g.run(brick_node, cmd) + self.assertEqual(0, int(out.strip()), "Brick path {} is not empty " + "in node {}".format(brick_path, brick_node)) + g.log.info("Brick path is empty on all nodes") -- cgit