From 2270f397413e4f7dae6ed1e831847096350f3acb Mon Sep 17 00:00:00 2001 From: Gaurav Yadav Date: Thu, 1 Feb 2018 22:44:59 +0530 Subject: Create cluster with shortnames and create volume using IP and FQDN - Peer probe using short name - Create volume using IP - Start/stop/getvolumeinfo - Create volume using FQDN - Start/stop/getvolumeinfo Change-Id: I2d55944035c44e8ee360beb4ce41550338586d15 Signed-off-by: Gaurav Yadav Signed-off-by: Rajesh Madaka --- tests/functional/glusterd/test_probe_hostname.py | 184 +++++++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 tests/functional/glusterd/test_probe_hostname.py (limited to 'tests/functional') diff --git a/tests/functional/glusterd/test_probe_hostname.py b/tests/functional/glusterd/test_probe_hostname.py new file mode 100644 index 000000000..4b950c70f --- /dev/null +++ b/tests/functional/glusterd/test_probe_hostname.py @@ -0,0 +1,184 @@ +# Copyright (C) 2017-2018 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. + +import socket +from glusto.core import Glusto as g +from glustolibs.gluster.gluster_base_class import GlusterBaseClass +from glustolibs.gluster.peer_ops import (peer_probe, peer_detach, + peer_probe_servers) +from glustolibs.gluster.lib_utils import form_bricks_list +from glustolibs.gluster.volume_ops import (volume_create, volume_start, + get_volume_list, volume_stop, + get_volume_info, get_volume_status) +from glustolibs.gluster.volume_libs import cleanup_volume +from glustolibs.gluster.exceptions import ExecutionError + + +class TestPeerProbe(GlusterBaseClass): + @classmethod + def setUpClass(cls): + GlusterBaseClass.setUpClass.im_func(cls) + g.log.info("Starting %s ", cls.__name__) + + def setUp(self): + # Performing peer detach + for server in self.servers[1:]: + # Peer detach + ret, _, _ = peer_detach(self.mnode, server) + if ret: + raise ExecutionError("Peer detach failed") + g.log.info("Peer detach SUCCESSFUL.") + self.peer_probe = False + + GlusterBaseClass.setUp.im_func(self) + + def tearDown(self): + + # Peer probe detached servers + if not self.peer_probe: + ret = peer_probe_servers(self.mnode, self.servers) + if not ret: + raise ExecutionError("Failed to probe detached " + "servers %s" % self.servers) + g.log.info("Peer probe success for detached " + "servers %s", self.servers) + + # clean up all volumes and detaches peers from cluster + + vol_list = get_volume_list(self.mnode) + for volume in vol_list: + ret = cleanup_volume(self.mnode, volume) + if not ret: + raise ExecutionError("Failed to Cleanup the " + "Volume %s" % volume) + g.log.info("Volume deleted successfully : %s", volume) + + # Calling GlusterBaseClass tearDown + GlusterBaseClass.tearDown.im_func(self) + + def test_peer_probe_validation(self): + ''' + -> Create trusted storage pool, by probing with networkshort names + -> Create volume using IP of host + -> perform basic operations like + -> gluster volume start + -> gluster volume info + -> gluster volume status + -> gluster volume stop + -> Create a volume using the FQDN of the host + -> perform basic operations like + -> gluster volume start + -> gluster volume info + -> gluster volume status + -> gluster volume stop + ''' + # Peer probing using short name + for server in self.servers[1:]: + ret, hostname, _ = g.run(server, "hostname -s") + self.assertEqual(ret, 0, ("Unable to get short name " + "for server % s" % server)) + ret, _, _ = peer_probe(self.mnode, hostname) + self.assertEqual(ret, 0, "Unable to peer" + "probe to the server % s" % hostname) + g.log.info("Peer probe succeeded for server %s", hostname) + self.peer_probe = True + + # Create a volume + self.volname = "test-vol" + self.brick_list = form_bricks_list(self.mnode, self.volname, 3, + self.servers, + self.all_servers_info) + g.log.info("Creating a volume") + ret, _, _ = volume_create(self.mnode, self.volname, + self.brick_list, force=False) + self.assertEqual(ret, 0, "Unable" + "to create volume % s" % self.volname) + g.log.info("Volume created successfuly % s", self.volname) + + # Start a volume + g.log.info("Start a volume") + ret, _, _ = volume_start(self.mnode, self.volname) + self.assertEqual(ret, 0, "Unable" + "to start volume % s" % self.volname) + g.log.info("Volume started successfuly % s", self.volname) + + # Get volume info + g.log.info("get volume info") + volinfo = get_volume_info(self.mnode, self.volname) + self.assertIsNotNone(volinfo, "Failed to get the volume " + "info for %s" % self.volname) + + # Get volume status + vol_status = get_volume_status(self.mnode, self.volname) + self.assertIsNotNone(vol_status, "Failed to get volume " + "status for %s" % self.volname) + + # stop volume + ret, _, _ = volume_stop(self.mnode, self.volname) + self.assertEqual(ret, 0, "Unable" + "to stop volume % s" % self.volname) + g.log.info("Volume stopped successfuly % s", self.volname) + + # Create a volume + self.volname = "test-vol-fqdn" + + self.brick_list = form_bricks_list(self.mnode, self.volname, 3, + self.servers, + self.all_servers_info) + + # Getting FQDN (Full qualified domain name) of each host and + # replacing ip with FQDN name for each brick for example + # 10.70.37.219:/bricks/brick0/vol1 is a brick, here ip is replaced + # with FQDN name now brick looks like + # dhcp35-219.lab.eng.blr.redhat.com:/bricks/brick0/vol1 + + my_brick_list = [] + for brick in self.brick_list: + fqdn_list = brick.split(":") + fqdn = socket.getfqdn(fqdn_list[0]) + fqdn = fqdn + ":" + fqdn_list[1] + my_brick_list.append(fqdn) + + g.log.info("Creating a volume") + ret, _, _ = volume_create(self.mnode, self.volname, + my_brick_list, force=False) + self.assertEqual(ret, 0, "Unable" + "to create volume % s" % self.volname) + g.log.info("Volume created successfuly % s", self.volname) + + # Start a volume + g.log.info("Start a volume") + ret, _, _ = volume_start(self.mnode, self.volname) + self.assertEqual(ret, 0, "Unable" + "to start volume % s" % self.volname) + g.log.info("Volume started successfuly % s", self.volname) + + # Get volume info + g.log.info("get volume info") + volinfo = get_volume_info(self.mnode, self.volname) + self.assertIsNotNone(volinfo, "Failed to get the volume " + "info for %s" % self.volname) + + # Get volume status + vol_status = get_volume_status(self.mnode, self.volname) + self.assertIsNotNone(vol_status, "Failed to get volume " + "status for %s" % self.volname) + + # stop volume + ret, _, _ = volume_stop(self.mnode, self.volname) + self.assertEqual(ret, 0, "Unable" + "to stop volume % s" % self.volname) + g.log.info("Volume stopped successfuly % s", self.volname) -- cgit