def test_ops_when_one_node_is_down(self): # pylint: disable=too-many-statements """ Test Case: 1) Create a N node gluster cluster. 2) Stop gluster on one node. 3) Execute gluster peer status on other node. 4) Execute gluster v list on other node. 5) Execute gluster v info on other node. """ # Fetching a random server from list. self.random_server = randint(1, len(self.servers) - 1) # Stopping glusterd on one node. ret = stop_glusterd(self.servers[self.random_server]) self.assertTrue(ret, "Failed to stop glusterd on one node.") g.log.info("Successfully stopped glusterd on one node.") # Running peer status on another node. ret, _, err = peer_status(self.mnode) self.assertEqual(ret, 0, ("Failed to get peer status from %s with " "error message %s" % (self.mnode, err))) g.log.info("Successfully got peer status from %s.", self.mnode) # Running volume list on another node. ret, _, _ = volume_list(self.mnode) self.assertEqual(ret, 0, "Failed to get volume list.") g.log.info("Successfully got volume list from %s.", self.mnode) # Running volume info on another node. ret, _, _ = volume_info(self.mnode) self.assertEqual(ret, 0, "Failed to get volume info.") g.log.info("Successfully got volume info from %s.", self.mnode)
def test_snap_del_original_volume(self): # pylint: disable=too-many-statements """ Steps: 1. Create and mount distributed-replicated volume 2. Perform I/O on mountpoints 3. Create snapshot 4. activate snapshot created in step3 5. clone created snapshot in step3 6. delete original volume 7. Validate clone volume """ # Perform I/O all_mounts_procs = [] g.log.info("Generating data for %s:" "%s", self.mounts[0].client_system, self.mounts[0].mountpoint) # Create files g.log.info('Creating files...') command = ("/usr/bin/env python %s create_files -f 100 " "--fixed-file-size 1k %s" % (self.script_upload_path, self.mounts[0].mountpoint)) proc = g.run_async(self.mounts[0].client_system, command, user=self.mounts[0].user) all_mounts_procs.append(proc) self.io_validation_complete = False # Validate IO self.assertTrue(validate_io_procs(all_mounts_procs, self.mounts[0]), "IO failed on some of the clients") self.io_validation_complete = True # Creating snapshot g.log.info("Starting to Create snapshot") ret, _, _ = snap_create(self.mnode, self.volname, self.snap) self.assertEqual(ret, 0, ("Failed to create snapshot %s for " "volume %s" % (self.snap, self.volname))) g.log.info("Snapshot %s created successfully for volume " "%s", self.snap, self.volname) # Activating snapshot g.log.info("Starting to Activate Snapshot") ret, _, _ = snap_activate(self.mnode, self.snap) self.assertEqual(ret, 0, ("Failed to Activate snapshot " "%s" % self.snap)) g.log.info("Snapshot %s activated successfully", self.snap) # snapshot list g.log.info("getting snapshot list") ret, out, _ = snap_list(self.mnode) self.assertEqual( ret, 0, ("Failed to list snapshot of volume %s" % self.volname)) self.assertIn( self.snap, out, "Failed to validate snapshot" " %s in snap list" % self.snap) g.log.info("Snapshot list command for volume %s is " "successful", self.volname) # Creating a Clone of snapshot: g.log.info("Starting to create Clone of Snapshot") ret, _, _ = snap_clone(self.mnode, self.snap, self.clone) self.assertEqual(ret, 0, ("Failed to create clone volume %s " "from snapshot %s" % (self.clone, self.snap))) g.log.info("Clone Volume %s created successfully from snapshot " "%s", self.clone, self.snap) # After cloning a volume wait for 5 second to start the volume sleep(5) # Validate clone volumes are started: g.log.info("starting to Validate clone volumes are started") ret, _, _ = volume_start(self.mnode, self.clone) self.assertEqual(ret, 0, ("Failed to start cloned volume " "%s" % self.clone)) g.log.info("Volume %s started successfully", self.clone) for mount_obj in self.mounts: # Unmount Volume g.log.info("Starting to Unmount Volume %s", self.volname) ret = umount_volume(mount_obj.client_system, mount_obj.mountpoint, mtype=self.mount_type) self.assertTrue(ret, ("Failed to Unmount Volume %s" % self.volname)) g.log.info("Successfully Unmounted Volume %s", self.volname) # Delete original volume g.log.info("deleting original volume") ret = cleanup_volume(self.mnode, self.volname) self.assertTrue(ret, ("Failed to delete volume %s" % self.volname)) g.log.info("successfully deleted volume %s", self.volname) # get volume info g.log.info("Getting and validating cloned volume %s", self.clone) vol_info = get_volume_info(self.mnode, self.clone) self.assertIsNotNone( vol_info, "Failed to get volume info " "for cloned volume %s" % self.clone) self.assertEqual( vol_info[self.clone]['statusStr'], 'Started', "Unexpected: cloned volume is not started " "%s " % self.clone) g.log.info("Volume %s is in Started state", self.clone) # Volume status g.log.info("Getting volume status") ret, out, _ = volume_status(self.mnode, self.clone) self.assertEqual(ret, 0, "Failed to get volume status for" " %s" % self.clone) vol = out.strip().split("\n") vol1 = vol[0].strip().split(":") self.assertEqual( vol1[1], " %s" % self.clone, "Failed to " "get volume status for volume %s" % self.clone) g.log.info("Volume Status is Successful for %s clone volume", self.clone) # Volume list validate g.log.info("Starting to list volume") ret, vol_list, _ = volume_list(self.mnode) self.assertEqual(ret, 0, "Failed to get volume list") vol_list1 = vol_list.strip().split("\n") self.assertIn( "%s" % self.clone, vol_list1, "Failed to validate " "volume list for volume %s" % self.clone) g.log.info("Volume list validated Successfully for" "volume %s", self.clone)
def test_snap_clone_validate(self): """ CloneSnapTest contains tests which verifies Clone volume created from snapshot Steps: 1. Create a volume 2. Mount the volume 3. Perform I/O on mount poit 4. Create a snapshot 5. Activate the snapshot created in step 4 6. Create 10 clones from snapshot created in step 4 7. Verify Information about the volumes along with the original volume. 8. Validate total number of clone volumes and existing volume with volume list """ # write files on all mounts g.log.info("Starting IO on all mounts...") g.log.info("mounts: %s", self.mounts) all_mounts_procs = [] for mount_obj in self.mounts: cmd = ("/usr/bin/env python %s create_files " "-f 10 --base-file-name file %s" % (self.script_upload_path, mount_obj.mountpoint)) proc = g.run(self.clients[0], cmd) all_mounts_procs.append(proc) g.log.info("Successfully Performed I/O on all mount points") # Creating snapshot: g.log.info("Starting to Create snapshot") ret, _, _ = snap_create(self.mnode, self.volname, self.snap) self.assertEqual( ret, 0, ("Failed to create snapshot for volume %s" % self.volname)) g.log.info("Snapshot snap1 created successfully for volume %s", self.volname) # Activating snapshot g.log.info("Starting to Activate Snapshot") ret, _, _ = snap_activate(self.mnode, self.snap) self.assertEqual(ret, 0, ("Failed to Activate snapshot %s" % self.snap)) g.log.info("Snapshot %s activated successfully", self.snap) # Creating and starting a Clone of snapshot: g.log.info("Starting to Clone Snapshot") for count in range(1, 11): self.clone = "clone%s" % count ret, _, _ = snap_clone(self.mnode, self.snap, self.clone) self.assertEqual(ret, 0, "Failed to clone %s" % self.clone) g.log.info("%s created successfully", self.clone) # Start clone volumes g.log.info("starting to Validate clone volumes are started") for count in range(1, 11): self.clone = "clone%s" % count ret, _, _ = volume_start(self.mnode, self.clone) self.assertEqual(ret, 0, ("Failed to start %s" % self.clone)) g.log.info("%s started successfully", self.clone) # Validate Volume Started g.log.info("Validating volume started") for count in range(1, 11): self.clone = "clone%s" % count vol_info = get_volume_info(self.mnode, self.clone) if vol_info[self.clone]['statusStr'] != 'Started': raise ExecutionError("Volume %s failed to start" % self.clone) g.log.info("Volume %s is in Started state", self.clone) # validate with list information # with 10 clone volume and 1 existing volume g.log.info("Validating with list information") ret, out, _ = volume_list(self.mnode) vlist = out.strip().split('\n') self.assertEqual(len(vlist), 11, "Failed to validate volume list") g.log.info("Successfully validated volumes in list")