def create_snap(value, volname, snap, clone, counter): # Creating snapshots g.log.info("Starting to Create snapshot") for snap_count in value: ret, _, _ = snap_create(self.mnode, volname, "snap%s" % snap_count) self.assertEqual(ret, 0, ("Failed to create " "snapshot for volume %s" % volname)) g.log.info( "Snapshot snap%s created successfully" " for volume %s", snap_count, volname) # Validate snapshot list g.log.info("Starting to list all snapshots") ret, out, _ = snap_list(self.mnode) self.assertEqual( ret, 0, ("Failed to list snapshot of volume %s" % volname)) v_list = out.strip().split('\n') self.assertEqual(len(v_list), counter, "Failed to validate " "all snapshots") g.log.info( "Snapshot listed and Validated for volume %s" " successfully", volname) if counter == 40: return 0 # Creating a Clone of snapshot: g.log.info("Starting to Clone Snapshot") ret, _, _ = snap_clone(self.mnode, snap, clone) self.assertEqual(ret, 0, "Failed to clone %s" % clone) g.log.info("Clone volume %s created successfully", clone) # Start cloned volumes g.log.info("starting to Validate clone volumes are started") ret, _, _ = volume_start(self.mnode, clone) self.assertEqual(ret, 0, "Failed to start %s" % clone) g.log.info("%s started successfully", clone) # log Cloned Volume information g.log.info("Logging Volume info and Volume status") ret = log_volume_info_and_status(self.mnode, clone) self.assertTrue("Failed to Log Info and Status of Volume %s" % clone) g.log.info("Successfully Logged Info and Status") return counter + 10
def test_snap_rebalance(self): # pylint: disable=too-many-statements, too-many-locals """ Snapshot rebalance contains tests which verifies snapshot clone, creating snapshot and performing I/O on mountpoints Steps: 1. Create snapshot of a volume 2. Activate snapshot 3. Clone snapshot and Activate 4. Mount Cloned volume 5. Perform I/O on mount point 6. Calculate areequal for bricks and mountpoints 7. Add-brick more brick to cloned volume 8. Initiate Re-balance 9. validate areequal of bricks and mountpoints """ # 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 %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) # Creating a Clone of snapshot: g.log.info("creating Clone Snapshot") ret, _, _ = snap_clone(self.mnode, self.snap, self.clone) self.assertEqual(ret, 0, ("Failed to clone volume %s" % self.clone)) g.log.info("clone volume %s created successfully", self.clone) # Starting clone volume g.log.info("starting clone volume") ret, _, _ = volume_start(self.mnode, self.clone) self.assertEqual(ret, 0, "Failed to start %s" % self.clone) g.log.info("clone volume %s started successfully", self.clone) # Mounting a clone volume g.log.info("Mounting created clone volume") ret, _, _ = mount_volume(self.clone, self.mount_type, self.mount1, self.mnode, self.clients[0]) self.assertEqual(ret, 0, "clone Volume mount failed for %s" % self.clone) g.log.info("cloned volume %s mounted Successfully", self.clone) # Validate clone volume mounted or not g.log.info("Validate clone volume mounted or not") ret = is_mounted(self.clone, self.mount1, self.mnode, self.clients[0], self.mount_type) self.assertTrue( ret, "Cloned Volume not mounted on mount point: %s" % self.mount1) g.log.info("Cloned Volume %s mounted on %s", self.clone, self.mount1) # write files to mountpoint g.log.info("Starting IO on %s mountpoint...", self.mount1) all_mounts_procs = [] cmd = ("/usr/bin/env python %s create_files " "-f 10 --base-file-name file %s" % (self.script_upload_path, self.mount1)) proc = g.run(self.clients[0], cmd) all_mounts_procs.append(proc) self.check_arequal() # expanding volume g.log.info("Starting to expand volume") ret = expand_volume(self.mnode, self.volname, self.servers, self.all_servers_info) self.assertTrue(ret, "Failed to expand volume %s" % self.clone) g.log.info("Expand volume successful") ret, _, _ = rebalance_start(self.mnode, self.clone) self.assertEqual(ret, 0, "Failed to start rebalance") g.log.info("Successfully started rebalance on the " "volume %s", self.clone) # Log Rebalance status g.log.info("Log Rebalance status") _, _, _ = rebalance_status(self.mnode, self.clone) # Wait for rebalance to complete g.log.info("Waiting for rebalance to complete") ret = wait_for_rebalance_to_complete(self.mnode, self.clone) self.assertTrue(ret, ("Rebalance is not yet complete " "on the volume %s", self.clone)) g.log.info("Rebalance is successfully complete on " "the volume %s", self.clone) # Check Rebalance status after rebalance is complete g.log.info("Checking Rebalance status") ret, _, _ = rebalance_status(self.mnode, self.clone) self.assertEqual(ret, 0, ("Failed to get rebalance status for " "the volume %s", self.clone)) g.log.info("Successfully got rebalance status of the " "volume %s", self.clone) self.check_arequal()
def test_clone_delete_snap(self): """ clone from snap of one volume * Create and Mount the volume * Enable some volume options * Creating 2 snapshots and activate * reset the volume * create a clone of snapshots created * Mount both the clones * Perform I/O on mount point * Check volume options of cloned volumes * Create snapshot of the cloned snapshot volume * cleanup snapshots and volumes """ # pylint: disable=too-many-statements, too-many-locals # Enabling Volume options on the volume and validating g.log.info("Enabling volume options for volume %s ", self.volname) options = {" features.uss": "enable"} ret = set_volume_options(self.mnode, self.volname, options) self.assertTrue( ret, ("Failed to set volume options for volume %s" % self.volname)) g.log.info("Successfully set volume options" "for volume %s", self.volname) # Validate feature.uss enabled or not g.log.info("Validating feature.uss is enabled") option = "features.uss" vol_option = get_volume_options(self.mnode, self.volname, option) self.assertEqual(vol_option['features.uss'], 'enable', "Failed" " to validate " "volume options") g.log.info("Successfully validated volume options" "for volume %s", self.volname) # Creating snapshot g.log.info("Starting to Create snapshot") for snap_count in range(0, 2): ret, _, _ = snap_create(self.mnode, self.volname, "snap%s" % snap_count) self.assertEqual( ret, 0, ("Failed to create snapshot for volume %s" % self.volname)) g.log.info("Snapshot snap%s created successfully" "for volume %s", snap_count, self.volname) # Activating snapshot g.log.info("Starting to Activate Snapshot") for snap_count in range(0, 2): ret, _, _ = snap_activate(self.mnode, "snap%s" % snap_count) self.assertEqual( ret, 0, ("Failed to Activate snapshot snap%s" % snap_count)) g.log.info("Snapshot snap%s activated successfully", snap_count) # Reset volume: g.log.info("Starting to Reset Volume") ret, _, _ = volume_reset(self.mnode, self.volname, force=False) self.assertEqual(ret, 0, ("Failed to reset volume %s" % self.volname)) g.log.info("Reset Volume on volume %s is Successful", self.volname) # Validate feature.uss enabled or not g.log.info("Validating feature.uss is enabled") option = "features.uss" vol_option = get_volume_options(self.mnode, self.volname, option) self.assertEqual(vol_option['features.uss'], 'off', "Failed" " to validate " "volume options") g.log.info("Successfully validated volume options" "for volume %s", self.volname) # Verify volume's all process are online g.log.info("Starting to Verify volume's all process are online") ret = verify_all_process_of_volume_are_online(self.mnode, self.volname) self.assertTrue(ret, ("Volume %s : All process are" "not online" % self.volname)) g.log.info("Volume %s : All process are online", self.volname) # Creating and starting a Clone of snapshot g.log.info("Starting to Clone Snapshot") for clone_count in range(0, 2): ret, _, _ = snap_clone(self.mnode, "snap%s" % clone_count, "clone%s" % clone_count) self.assertEqual(ret, 0, ("Failed to clone clone%s volume" % clone_count)) g.log.info("clone%s volume created successfully", clone_count) # Start Cloned volume g.log.info("starting to Validate clone volumes are started") for clone_count in range(0, 2): ret, _, _ = volume_start(self.mnode, "clone%s" % clone_count) self.assertEqual(ret, 0, ("Failed to start clone%s" % clone_count)) g.log.info("clone%s started successfully", clone_count) g.log.info("All the clone volumes are started Successfully") # Validate Volume start of cloned volume g.log.info("Starting to Validate Volume start") for clone_count in range(0, 2): vol_info = get_volume_info(self.mnode, "clone%s" % clone_count) if vol_info["clone%s" % clone_count]['statusStr'] != 'Started': raise ExecutionError("Failed to get volume info for clone%s" % clone_count) g.log.info("Volume clone%s is in Started state", clone_count) # Validate feature.uss enabled or not g.log.info("Validating feature.uss is enabled") option = "features.uss" for clone_count in range(0, 2): vol_option = get_volume_options(self.mnode, "clone%s" % clone_count, option) self.assertEqual(vol_option['features.uss'], 'enable', "Failed" " to validate" "volume options") g.log.info( "Successfully validated volume options" "for volume clone%s", clone_count) # Mount both the cloned volumes g.log.info("Mounting Cloned Volumes") for mount_obj in range(0, 2): self.mpoint = "/mnt/clone%s" % mount_obj cmd = "mkdir -p %s" % self.mpoint ret, _, _ = g.run(self.clients[0], cmd) self.assertEqual(ret, 0, ("Creation of directory %s" "for mounting" "volume %s failed: Directory already" "present" % (self.mpoint, "clone%s" % mount_obj))) g.log.info( "Creation of directory %s for mounting volume %s " "success", self.mpoint, ("clone%s" % mount_obj)) ret, _, _ = mount_volume("clone%s" % mount_obj, self.mount_type, self.mpoint, self.mnode, self.clients[0]) self.assertEqual(ret, 0, ("clone%s is not mounted" % mount_obj)) g.log.info("clone%s is mounted Successfully", mount_obj) # Perform I/O on mount # Start I/O on all mounts g.log.info("Starting to Perform I/O on Mountpoint") all_mounts_procs = [] for mount_obj in range(0, 2): cmd = ("cd /mnt/clone%s/; for i in {1..10};" "do touch file$i; done; cd;") % mount_obj proc = g.run(self.clients[0], cmd) all_mounts_procs.append(proc) g.log.info("I/O on mountpoint is successful") # create snapshot g.log.info("Starting to Create snapshot of clone volume") ret0, _, _ = snap_create(self.mnode, "clone0", "snap2") self.assertEqual(ret0, 0, "Failed to create the snapshot" "snap2 from clone0") g.log.info("Snapshots snap2 created successfully from clone0") ret1, _, _ = snap_create(self.mnode, "clone1", "snap3") self.assertEqual(ret1, 0, "Failed to create the snapshot snap3" "from clone1") g.log.info("Snapshots snap3 created successfully from clone1") # Listing all Snapshots present g.log.info("Starting to list all snapshots") ret, _, _ = snap_list(self.mnode) self.assertEqual(ret, 0, ("Failed to list snapshots present")) g.log.info("Snapshots successfully listed")
def test_snap_self_heal(self): """ Steps: 1. create a volume 2. mount volume 3. create snapshot of that volume 4. Activate snapshot 5. Clone snapshot and Mount 6. Perform I/O 7. Bring Down Few bricks from volume without affecting the volume or cluster. 8. Perform I/O 9. Bring back down bricks to online 10. Validate heal is complete with areequal """ # pylint: disable=too-many-statements, too-many-locals # 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 %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 ret, _, _ = snap_list(self.mnode) self.assertEqual(ret, 0, ("Failed to list all the snapshot")) g.log.info("Snapshot list command was successful") # Creating a Clone volume from snapshot: g.log.info("Starting to Clone volume from Snapshot") ret, _, _ = snap_clone(self.mnode, self.snap, self.clone) self.assertEqual(ret, 0, ("Failed to clone %s from snapshot %s" % (self.clone, self.snap))) g.log.info("%s created successfully", self.clone) # start clone volumes g.log.info("start to created clone volumes") ret, _, _ = volume_start(self.mnode, self.clone) self.assertEqual(ret, 0, "Failed to start clone %s" % self.clone) g.log.info("clone volume %s started successfully", self.clone) # Mounting a clone volume g.log.info("Mounting a clone volume") ret, _, _ = mount_volume(self.clone, self.mount_type, self.mount1, self.mnode, self.clients[0]) self.assertEqual(ret, 0, "Failed to mount clone Volume %s" % self.clone) g.log.info("Clone volume %s mounted Successfully", self.clone) # Checking cloned volume mounted or not ret = is_mounted(self.clone, self.mount1, self.mnode, self.clients[0], self.mount_type) self.assertTrue( ret, "Failed to mount clone volume on mount point: %s" % self.mount1) g.log.info("clone Volume %s mounted on %s", self.clone, self.mount1) # write files on all mounts g.log.info("Starting IO on all mounts...") g.log.info("mounts: %s", self.mount1) all_mounts_procs = [] cmd = ("python %s create_files " "-f 10 --base-file-name file %s" % (self.script_upload_path, self.mount1)) proc = g.run(self.clients[0], cmd) all_mounts_procs.append(proc) g.log.info("Successful in creating I/O on mounts") # get the bricks from the volume g.log.info("Fetching bricks for the volume : %s", self.clone) bricks_list = get_all_bricks(self.mnode, self.clone) g.log.info("Brick List : %s", bricks_list) # Select bricks to bring offline g.log.info("Starting to bring bricks to offline") bricks_to_bring_offline_dict = (select_bricks_to_bring_offline( self.mnode, self.volname)) bricks_to_bring_offline = filter( None, (bricks_to_bring_offline_dict['hot_tier_bricks'] + bricks_to_bring_offline_dict['cold_tier_bricks'] + bricks_to_bring_offline_dict['volume_bricks'])) g.log.info("Brick to bring offline: %s ", bricks_to_bring_offline) ret = bring_bricks_offline(self.clone, bricks_to_bring_offline) self.assertTrue(ret, "Failed to bring the bricks offline") g.log.info("Successful in bringing bricks: %s offline", bricks_to_bring_offline) # Offline Bricks list offline_bricks = get_offline_bricks_list(self.mnode, self.clone) self.assertIsNotNone( offline_bricks, "Failed to get offline bricklist" "for volume %s" % self.clone) for bricks in offline_bricks: self.assertIn(bricks, bricks_to_bring_offline, "Failed to validate " "Bricks offline") g.log.info("Bricks Offline: %s", offline_bricks) # Online Bricks list online_bricks = get_online_bricks_list(self.mnode, self.clone) self.assertIsNotNone( online_bricks, "Failed to get online bricks" " for volume %s" % self.clone) g.log.info("Bricks Online: %s", online_bricks) # write files mountpoint g.log.info("Starting IO on all mounts...") g.log.info("mounts: %s", self.mount1) all_mounts_procs = [] cmd = ("python %s create_files " "-f 10 --base-file-name file %s" % (self.script_upload_path, self.mount1)) proc = g.run(self.clients[0], cmd) all_mounts_procs.append(proc) g.log.info("Successful in creating I/O on mounts") # Bring all bricks online g.log.info("bring all bricks online") ret = bring_bricks_online(self.mnode, self.clone, bricks_to_bring_offline) self.assertTrue(ret, "Failed to bring bricks online") g.log.info("Successful in bringing all bricks online") # Validate Bricks are online g.log.info("Validating all bricks are online") ret = are_bricks_online(self.mnode, self.clone, bricks_list) self.assertTrue(ret, "Failed to bring all the bricks online") g.log.info("bricks online: %s", bricks_list) # Wait for volume processes to be online g.log.info("Wait for volume processes to be online") ret = wait_for_volume_process_to_be_online(self.mnode, self.clone) self.assertTrue(ret, ("Failed to wait for volume %s processes to " "be online" % self.clone)) g.log.info( "Successful in waiting for volume %s processes to be " "online", self.clone) # Verify volume's all process are online g.log.info("Verifying volume's all process are online") ret = verify_all_process_of_volume_are_online(self.mnode, self.clone) self.assertTrue( ret, ("Volume %s : All process are not online" % self.clone)) g.log.info("Volume %s : All process are online", self.clone) # wait for the heal process to complete g.log.info("waiting for heal process to complete") ret = monitor_heal_completion(self.mnode, self.volname) self.assertTrue(ret, "Failed to complete the heal process") g.log.info("Successfully completed heal process") # Check areequal # get the subvolumes g.log.info("Starting to get sub-volumes for volume %s", self.clone) subvols = get_subvols(self.mnode, self.clone) num_subvols = len(subvols['volume_subvols']) g.log.info("Number of subvolumes in volume %s:", num_subvols) # Get arequals and compare g.log.info("Starting to Compare areequals") for i in range(0, num_subvols): # Get arequal for first brick subvol_brick_list = subvols['volume_subvols'][i] node, brick_path = subvol_brick_list[0].split(':') command = ('arequal-checksum -p %s ' '-i .glusterfs -i .landfill -i .trashcan' % brick_path) ret, arequal, _ = g.run(node, command) first_brick_total = arequal.splitlines()[-1].split(':')[-1] # Get arequal for every brick and compare with first brick for brick in subvol_brick_list: node, brick_path = brick.split(':') command = ('arequal-checksum -p %s ' '-i .glusterfs -i .landfill -i .trashcan' % brick_path) ret, brick_arequal, _ = g.run(node, command) self.assertFalse(ret, 'Failed to get arequal on brick %s' % brick) g.log.info('Getting arequal for %s is successful', brick) brick_total = brick_arequal.splitlines()[-1].split(':')[-1] self.assertEqual( first_brick_total, brick_total, 'Arequals for subvol and %s are not equal' % brick) g.log.info('Arequals for subvol and %s are equal', brick) g.log.info('All arequals are equal for distributed-replicated')
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")
def test_snap_clone_snapd(self): """ Steps: 1. create a volume 2. Create a snapshots and activate 3. Clone the snapshot and mount it 4. Check for snapd daemon 5. enable uss and validate snapd 5. stop cloned volume 6. Validate snapd 7. start cloned volume 8. validate snapd 9. Create 5 more snapshot 10. Validate total number of snapshots created. 11. Activate 5 snapshots 12. Enable USS 13. Validate snapd 14. kill snapd on all nodes 15. validate snapd running 16. force start clone volume 17. validate snaps inside .snaps directory """ # pylint: disable=too-many-statements, too-many-locals # Starting I/O 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_async(mount_obj.client_system, cmd, user=mount_obj.user) all_mounts_procs.append(proc) # Validate I/O ret = validate_io_procs(all_mounts_procs, self.mounts) self.assertTrue(ret, "IO failed on some of the clients") g.log.info("IO is successful on all mounts") # Creating 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 %s created successfully for " "volume %s", self.snap, self.volname) # Activating created snapshots ret, _, _ = snap_activate(self.mnode, self.snap) self.assertEqual(ret, 0, ("Failed to activate snapshot %s" % self.snap)) g.log.info("Snapshot snap%s activated successfully", self.snap) # Snapshot list self.assertIsNotNone( get_snap_list(self.mnode), "Failed to list snapshot") g.log.info("Snapshot list command Successful") # Creating and starting a Clone of snapshot: ret, _, _ = snap_clone(self.mnode, self.snap, self.clone_vol1) self.assertEqual(ret, 0, "Failed to clone %s" % self.clone_vol1) g.log.info("Clone volume %s created successfully", self.clone_vol1) # Start the clone volumes ret, _, _ = volume_start(self.mnode, self.clone_vol1) self.assertEqual(ret, 0, "Failed to start %s" % self.clone_vol1) g.log.info("%s started successfully", self.clone_vol1) # Form server list brick_list = get_all_bricks(self.mnode, self.clone_vol1) for bricks in brick_list: self.server_lists.append(bricks.split(":")[0]) self.server_list = list(set(self.server_lists)) # Get volume info vol_info = get_volume_info(self.mnode, self.clone_vol1) self.assertIsNotNone(vol_info, "Failed to get vol info") g.log.info("Successfully in getting vol info") # Redefining mounts for cloned volume self.mount_points, self.mounts_dict_list = [], [] for client in self.all_clients_info: mount = { 'protocol': self.mount_type, 'server': self.mnode, 'volname': self.volname, 'client': self.all_clients_info[client], 'mountpoint': (path.join( "%s" % self.mpoint)), 'options': '' } self.mounts_dict_list.append(mount) self.mount1 = create_mount_objs(self.mounts_dict_list) self.mount_points.append(self.mpoint) g.log.info("Successfully made entry in self.mount1") # FUSE mount clone1 volume for mount_obj in self.mounts: ret, _, _ = mount_volume(self.clone_vol1, self.mount_type, self.mpoint, self.mnode, mount_obj.client_system) self.assertEqual(ret, 0, "Volume mount failed for clone1") g.log.info("%s mounted Successfully", self.clone_vol1) # Validate clone volume is mounted or not ret = is_mounted(self.clone_vol1, self.mpoint, self.mnode, mount_obj.client_system, self.mount_type) self.assertTrue(ret, "Volume not mounted on mount point: " "%s" % self.mpoint) g.log.info("Volume %s mounted on %s", self.clone_vol1, self.mpoint) # Log Cloned Volume information ret = log_volume_info_and_status(self.mnode, self.clone_vol1) self.assertTrue("Failed to Log Info and Status of Volume " "%s" % self.clone_vol1) g.log.info("Successfully Logged Info and Status") # Validate snapd running on all nodes self.validate_snapd(check_condition=False) # Enable USS ret, _, _ = enable_uss(self.mnode, self.clone_vol1) self.assertEqual(ret, 0, "Failed to enable USS on cloned volume") g.log.info("Successfully enabled USS on Cloned volume") # Validate USS running self.validate_uss() # Validate snapd running on all nodes self.validate_snapd() # Stop cloned volume ret, _, _ = volume_stop(self.mnode, self.clone_vol1) self.assertEqual(ret, 0, "Failed to stop cloned volume " "%s" % self.clone_vol1) g.log.info("Successfully Stopped Cloned volume %s", self.clone_vol1) # Validate snapd running on all nodes self.validate_snapd(check_condition=False) # Start cloned volume ret, _, _ = volume_start(self.mnode, self.clone_vol1) self.assertEqual(ret, 0, "Failed to start cloned volume" " %s" % self.clone_vol1) g.log.info("Successfully started cloned volume" " %s", self.clone_vol1) # Validate snapd running on all nodes self.validate_snapd() # Create 5 snapshots self.snaps_list = [('test_snap_clone_snapd-snap%s' % i)for i in range(0, 5)] for snapname in self.snaps_list: ret, _, _ = snap_create(self.mnode, self.clone_vol1, snapname) self.assertEqual(ret, 0, ("Failed to create snapshot for volume" " %s" % self.clone_vol1)) g.log.info("Snapshot %s created successfully for volume " "%s", snapname, self.clone_vol1) # Validate USS running self.validate_uss() # Check snapshot under .snaps directory self.check_snaps() # Activate Snapshots for snapname in self.snaps_list: ret, _, _ = snap_activate(self.mnode, snapname) self.assertEqual(ret, 0, ("Failed to activate snapshot %s" % snapname)) g.log.info("Snapshot %s activated " "successfully", snapname) # Validate USS running self.validate_uss() # Validate snapshots under .snaps folder self.validate_snaps() # Kill snapd on node and validate snapd except management node for server in self.servers[1:]: ret, _, _ = terminate_snapd_on_node(server) self.assertEqual(ret, 0, "Failed to Kill snapd on node %s" % server) g.log.info("snapd Killed Successfully on node %s", server) # Check snapd running ret = is_snapd_running(server, self.clone_vol1) self.assertTrue(ret, "Unexpected: Snapd running on node: " "%s" % server) g.log.info("Expected: Snapd is not running on node:%s", server) # Check snapshots under .snaps folder g.log.info("Validating snapshots under .snaps") ret, _, _ = uss_list_snaps(self.clients[0], self.mpoint) self.assertEqual(ret, 0, "Target endpoint not connected") g.log.info("Successfully listed snapshots under .snaps") # Kill snapd in management node ret, _, _ = terminate_snapd_on_node(self.servers[0]) self.assertEqual(ret, 0, "Failed to Kill snapd on node %s" % self.servers[0]) g.log.info("snapd Killed Successfully on node %s", self.servers[0]) # Validate snapd running on all nodes self.validate_snapd(check_condition=False) # Validating snapshots under .snaps ret, _, _ = uss_list_snaps(self.clients[0], self.mpoint) self.assertNotEqual(ret, 0, "Unexpected: Successfully listed " "snapshots under .snaps") g.log.info("Expected: Target endpoint not connected") # Start the Cloned volume(force start) ret, _, _ = volume_start(self.mnode, self.clone_vol1, force=True) self.assertEqual(ret, 0, "Failed to start cloned volume " "%s" % self.clone_vol1) g.log.info("Successfully Started Cloned volume %s", self.clone_vol1) # Validate snapd running on all nodes self.validate_snapd() # Validate snapshots under .snaps folder self.validate_snaps()