def test_02_accountSnapshotClean(self): """Test snapshot cleanup after account deletion """ # Validate the following # 1. listAccounts API should list out the newly created account # 2. listVirtualMachines() command should return the deployed VM. # State of this VM should be "Running" # 3. a)listSnapshots should list the snapshot that was created. # b)verify that secondary storage NFS share contains the reqd volume # under /secondary/snapshots/$accountid/$volumeid/$snapshot_id # 4. a)listAccounts should not list account that is deleted # b) snapshot image($snapshot_id) should be deleted from the # /secondary/snapshots/$accountid/$volumeid/ accounts = list_accounts(self.apiclient, id=self.account.id) self.assertEqual(isinstance(accounts, list), True, "Check list response returns a valid list") self.assertNotEqual(len(accounts), 0, "Check list Accounts response") # VM should be in 'Running' state virtual_machines = list_virtual_machines(self.apiclient, id=self.virtual_machine.id) self.assertEqual(isinstance(virtual_machines, list), True, "Check list response returns a valid list") self.assertNotEqual(len(virtual_machines), 0, "Check list virtual machines response") for virtual_machine in virtual_machines: self.debug("VM ID: %s, VM state: %s" % (virtual_machine.id, virtual_machine.state)) self.assertEqual(virtual_machine.state, "Running", "Check list VM response for Running state") # Verify the snapshot was created or not snapshots = list_snapshots(self.apiclient, id=self.snapshot.id) self.assertEqual(isinstance(snapshots, list), True, "Check list response returns a valid list") self.assertNotEqual(snapshots, None, "No such snapshot %s found" % self.snapshot.id) self.assertEqual(snapshots[0].id, self.snapshot.id, "Check snapshot id in list resources call") self.assertTrue( is_snapshot_on_nfs(self.apiclient, self.dbclient, self.config, self.zone.id, self.snapshot.id), "Snapshot was not found on NFS", ) self.debug("Deleting account: %s" % self.account.name) # Delete account self.account.delete(self.apiclient) # Wait for account cleanup interval wait_for_cleanup(self.apiclient, configs=["account.cleanup.interval"]) with self.assertRaises(Exception): accounts = list_accounts(self.apiclient, id=self.account.id) self.assertFalse( is_snapshot_on_nfs(self.apiclient, self.dbclient, self.config, self.zone.id, self.snapshot.id), "Snapshot was still found on NFS after account gc", ) return
def test_04_delete_snapshot(self): """Test Delete Snapshot """ #1. Snapshot the Volume #2. Delete the snapshot #3. Verify snapshot is removed by calling List Snapshots API #4. Verify snapshot was removed from image store volumes = list_volumes(self.apiclient, virtualmachineid=self.virtual_machine.id, type='DATADISK', listall=True) self.assertEqual(isinstance(volumes, list), True, "Check list response returns a valid list") snapshot = Snapshot.create(self.apiclient, volumes[0].id, account=self.account.name, domainid=self.account.domainid) snapshot.delete(self.apiclient) snapshots = list_snapshots(self.apiclient, id=snapshot.id) self.assertEqual(snapshots, None, "Check if result exists in list item call") self.assertFalse( is_snapshot_on_nfs(self.apiclient, self.dbclient, self.config, self.zone.id, snapshot.id)) return
def test_02_snapshot_data_disk(self): """Test Snapshot Data Disk """ volume = list_volumes( self.apiclient, virtualmachineid=self.virtual_machine_with_disk.id, type='DATADISK', listall=True) self.assertEqual(isinstance(volume, list), True, "Check list response returns a valid list") self.debug("Creating a Snapshot from data volume: %s" % volume[0].id) snapshot = Snapshot.create(self.apiclient, volume[0].id, account=self.account.name, domainid=self.account.domainid) snapshots = list_snapshots(self.apiclient, id=snapshot.id) self.assertEqual(isinstance(snapshots, list), True, "Check list response returns a valid list") self.assertNotEqual(snapshots, None, "Check if result exists in list item call") self.assertEqual(snapshots[0].id, snapshot.id, "Check resource id in list resources call") self.assertTrue( is_snapshot_on_nfs(self.apiclient, self.dbclient, self.config, self.zone.id, snapshot.id)) return
def test_02_snapshot_data_disk(self): """Test Snapshot Data Disk """ volume = list_volumes( self.apiclient, virtualmachineid=self.virtual_machine_with_disk.id, type='DATADISK', listall=True ) self.assertEqual( isinstance(volume, list), True, "Check list response returns a valid list" ) self.debug("Creating a Snapshot from data volume: %s" % volume[0].id) snapshot = Snapshot.create( self.apiclient, volume[0].id, account=self.account.name, domainid=self.account.domainid ) snapshots = list_snapshots( self.apiclient, id=snapshot.id ) self.assertEqual( isinstance(snapshots, list), True, "Check list response returns a valid list" ) self.assertNotEqual( snapshots, None, "Check if result exists in list item call" ) self.assertEqual( snapshots[0].id, snapshot.id, "Check resource id in list resources call" ) self.assertTrue(is_snapshot_on_nfs(self.apiclient, self.dbclient, self.config, self.zone.id, snapshot.id)) return
def test_04_delete_snapshot(self): """Test Delete Snapshot """ #1. Snapshot the Volume #2. Delete the snapshot #3. Verify snapshot is removed by calling List Snapshots API #4. Verify snapshot was removed from image store volumes = list_volumes( self.apiclient, virtualmachineid=self.virtual_machine.id, type='DATADISK', listall=True ) self.assertEqual( isinstance(volumes, list), True, "Check list response returns a valid list" ) snapshot = Snapshot.create( self.apiclient, volumes[0].id, account=self.account.name, domainid=self.account.domainid ) snapshot.delete(self.apiclient) snapshots = list_snapshots( self.apiclient, id=snapshot.id ) self.assertEqual( snapshots, None, "Check if result exists in list item call" ) self.assertFalse(is_snapshot_on_nfs(self.apiclient, self.dbclient, self.config, self.zone.id, snapshot.id)) return
def test_04_snapshot_limit(self): """Test snapshot limit in snapshot policies """ # Validate the following # 1. Perform hourly recurring snapshot on the root disk of VM and keep # the maxsnapshots as 1 # 2. listSnapshots should list the snapshot that was created # snapshot folder in secondary storage should contain only one # snapshot image(/secondary/snapshots/$accountid/$volumeid/) # Get the Root disk of VM volumes = list_volumes( self.apiclient, virtualmachineid=self.virtual_machine.id, type='ROOT', listall=True ) self.assertEqual( isinstance(volumes, list), True, "Check list response returns a valid list" ) volume = volumes[0] # Create a snapshot policy recurring_snapshot = SnapshotPolicy.create( self.apiclient, volume.id, self.services["recurring_snapshot"] ) self.cleanup.append(recurring_snapshot) snapshot_policy = list_snapshot_policy( self.apiclient, id=recurring_snapshot.id, volumeid=volume.id ) self.assertEqual( isinstance(snapshot_policy, list), True, "Check list response returns a valid list" ) self.assertNotEqual( snapshot_policy, None, "Check if result exists in list item call" ) self.assertEqual( snapshot_policy[0].id, recurring_snapshot.id, "Check recurring snapshot id in list resources call" ) self.assertEqual( snapshot_policy[0].maxsnaps, self.services["recurring_snapshot"]["maxsnaps"], "Check interval type in list resources call" ) # Sleep for (maxsnaps+1) hours to verify # only maxsnaps snapshots are retained time.sleep( (self.services["recurring_snapshot"]["maxsnaps"]) * 3600 ) # Verify the snapshot was created or not snapshots = list_snapshots( self.apiclient, volumeid=volume.id, intervaltype=\ self.services["recurring_snapshot"]["intervaltype"], snapshottype='RECURRING', listall=True ) self.assertEqual( isinstance(snapshots, list), True, "Check list response returns a valid list" ) self.assertEqual( len(snapshots), self.services["recurring_snapshot"]["maxsnaps"], "Check maximum number of recurring snapshots retained" ) snapshot = snapshots[0] # Sleep to ensure that snapshot is reflected in sec storage time.sleep(self.services["sleep"]) self.assertTrue(is_snapshot_on_nfs(self.apiclient, self.dbclient, self.config, self.zone.id, snapshot.id)) return
def test_01_createVM_snapshotTemplate(self): """Test create VM, Snapshot and Template """ # Validate the following # 1. Deploy VM using default template, small service offering # and small data disk offering. # 2. Perform snapshot on the root disk of this VM. # 3. Create a template from snapshot. # 4. Create a instance from above created template. # 5. listSnapshots should list the snapshot that was created. # 6. verify that secondary storage NFS share contains the reqd # volume under /secondary/snapshots/$accountid/$volumeid/$snapshot_uuid # 7. verify backup_snap_id was non null in the `snapshots` table # 8. listTemplates() should return the newly created Template, # and check for template state as READY" # 9. listVirtualMachines() command should return the deployed VM. # State of this VM should be Running. #Create Virtual Machine self.virtual_machine = VirtualMachine.create( self.apiclient, self.services["server"], templateid=self.template.id, accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) self.debug("Created VM with ID: %s" % self.virtual_machine.id) # Get the Root disk of VM volumes = list_volumes( self.apiclient, virtualmachineid=self.virtual_machine.id, type='ROOT', listall=True ) volume = volumes[0] # Create a snapshot from the ROOTDISK snapshot = Snapshot.create(self.apiclient, volumes[0].id) self.debug("Snapshot created: ID - %s" % snapshot.id) self.cleanup.append(snapshot) snapshots = list_snapshots( self.apiclient, id=snapshot.id ) self.assertEqual( isinstance(snapshots, list), True, "Check list response returns a valid list" ) self.assertNotEqual( snapshots, None, "Check if result exists in list snapshots call" ) self.assertEqual( snapshots[0].id, snapshot.id, "Check snapshot id in list resources call" ) self.debug("select backup_snap_id, account_id, volume_id from snapshots where uuid = '%s';" \ % snapshot.id) snapshot_uuid = snapshot.id # Generate template from the snapshot template = Template.create_from_snapshot( self.apiclient, snapshot, self.services["templates"] ) self.debug("Created template from snapshot: %s" % template.id) self.cleanup.append(template) templates = list_templates( self.apiclient, templatefilter=\ self.services["templates"]["templatefilter"], id=template.id ) self.assertNotEqual( templates, None, "Check if result exists in list item call" ) self.assertEqual( templates[0].isready, True, "Check new template state in list templates call" ) # Deploy new virtual machine using template new_virtual_machine = VirtualMachine.create( self.apiclient, self.services["server"], templateid=template.id, accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_offering.id ) self.debug("Created VM with ID: %s from template: %s" % ( new_virtual_machine.id, template.id )) self.cleanup.append(new_virtual_machine) # Newly deployed VM should be 'Running' virtual_machines = list_virtual_machines( self.apiclient, id=new_virtual_machine.id, account=self.account.name, domainid=self.account.domainid ) self.assertEqual( isinstance(virtual_machines, list), True, "Check list response returns a valid list" ) self.assertNotEqual( len(virtual_machines), 0, "Check list virtual machines response" ) for virtual_machine in virtual_machines: self.assertEqual( virtual_machine.state, 'Running', "Check list VM response for Running state" ) self.assertTrue(is_snapshot_on_nfs(self.apiclient, self.dbclient, self.config, self.zone.id, snapshot_uuid)) return
def test_01_snapshot_on_rootVolume(self): """Test create VM with default cent os template and create snapshot on root disk of the vm """ # Validate the following # 1. Deploy a Linux VM using default CentOS template, use small service # offering, disk offering # 2. Create snapshot on the root disk of this newly cteated vm # 3. listSnapshots should list the snapshot that was created. # 4. verify that secondary storage NFS share contains the reqd # volume under /secondary/snapshots/$accountid/$volumeid/$snapshot_uuid # 5. verify backup_snap_id was non null in the `snapshots` table # Create virtual machine with small systerm offering and disk offering new_virtual_machine = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], templateid=self.template.id, zoneid=self.zone.id, accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_offering.id, diskofferingid=self.disk_offering.id, ) self.debug("Virtual machine got created with id: %s" % new_virtual_machine.id) list_virtual_machine_response = VirtualMachine.list( self.apiclient, id=new_virtual_machine.id) self.assertEqual(isinstance(list_virtual_machine_response, list), True, "Check listVirtualMachines returns a valid list") self.assertNotEqual(len(list_virtual_machine_response), 0, "Check listVirtualMachines response") self.cleanup.append(new_virtual_machine) # Getting root volume id of the vm created above list_volume_response = Volume.list( self.apiclient, virtualmachineid=list_virtual_machine_response[0].id, type="ROOT", account=self.account.name, domainid=self.account.domainid) self.assertEqual(isinstance(list_volume_response, list), True, "Check listVolumes returns a valid list") self.assertNotEqual(len(list_volume_response), 0, "Check listVolumes response") self.debug( "Snapshot will be created on the volume with voluem id: %s" % list_volume_response[0].id) # Perform snapshot on the root volume root_volume_snapshot = Snapshot.create( self.apiclient, volume_id=list_volume_response[0].id) self.debug("Created snapshot: %s for vm: %s" % ( root_volume_snapshot.id, list_virtual_machine_response[0].id)) list_snapshot_response = Snapshot.list( self.apiclient, id=root_volume_snapshot.id, account=self.account.name, domainid=self.account.domainid) self.assertEqual(isinstance(list_snapshot_response, list), True, "Check listSnapshots returns a valid list") self.assertNotEqual(len(list_snapshot_response), 0, "Check listSnapshots response") # Verify Snapshot state self.assertEqual( list_snapshot_response[0].state in [ 'BackedUp', 'CreatedOnPrimary' ], True, "Snapshot state is not as expected. It is %s" % list_snapshot_response[0].state ) self.assertEqual( list_snapshot_response[0].volumeid, list_volume_response[0].id, "Snapshot volume id is not matching with the vm's volume id") self.cleanup.append(root_volume_snapshot) # Below code is to verify snapshots in the backend and in db. # Verify backup_snap_id field in the snapshots table for the snapshot created, it should not be null self.debug("select id, removed, backup_snap_id from snapshots where uuid = '%s';" % root_volume_snapshot.id) qryresult = self.dbclient.execute("select id, removed, backup_snap_id from snapshots where uuid = '%s';" % root_volume_snapshot.id) self.assertNotEqual(len(qryresult), 0, "Check sql query to return snapshots list") snapshot_qry_response = qryresult[0] snapshot_id = snapshot_qry_response[0] is_removed = snapshot_qry_response[1] backup_snap_id = snapshot_qry_response[2] self.assertNotEqual(is_removed, "NULL", "Snapshot is removed from CS, please check the logs") msg = "Backup snapshot id is set to null for the backedup snapshot :%s" % snapshot_id self.assertNotEqual(backup_snap_id, "NULL", msg ) # Check if the snapshot is present on the secondary storage self.assertTrue(is_snapshot_on_nfs(self.apiclient, self.dbclient, self.config, self.zone.id, root_volume_snapshot.id)) return
def test_04_snapshot_limit(self): """Test snapshot limit in snapshot policies """ # Validate the following # 1. Perform hourly recurring snapshot on the root disk of VM and keep # the maxsnapshots as 1 # 2. listSnapshots should list the snapshot that was created # snapshot folder in secondary storage should contain only one # snapshot image(/secondary/snapshots/$accountid/$volumeid/) # Get the Root disk of VM volumes = list_volumes(self.apiclient, virtualmachineid=self.virtual_machine.id, type='ROOT', listall=True) self.assertEqual(isinstance(volumes, list), True, "Check list response returns a valid list") volume = volumes[0] # Create a snapshot policy recurring_snapshot = SnapshotPolicy.create( self.apiclient, volume.id, self.services["recurring_snapshot"]) self.cleanup.append(recurring_snapshot) snapshot_policy = list_snapshot_policy(self.apiclient, id=recurring_snapshot.id, volumeid=volume.id) self.assertEqual(isinstance(snapshot_policy, list), True, "Check list response returns a valid list") self.assertNotEqual(snapshot_policy, None, "Check if result exists in list item call") self.assertEqual(snapshot_policy[0].id, recurring_snapshot.id, "Check recurring snapshot id in list resources call") self.assertEqual(snapshot_policy[0].maxsnaps, self.services["recurring_snapshot"]["maxsnaps"], "Check interval type in list resources call") # Sleep for (maxsnaps+1) hours to verify # only maxsnaps snapshots are retained time.sleep((self.services["recurring_snapshot"]["maxsnaps"]) * 3600) # Verify the snapshot was created or not snapshots = list_snapshots( self.apiclient, volumeid=volume.id, intervaltype=\ self.services["recurring_snapshot"]["intervaltype"], snapshottype='RECURRING', listall=True ) self.assertEqual(isinstance(snapshots, list), True, "Check list response returns a valid list") self.assertEqual( len(snapshots), self.services["recurring_snapshot"]["maxsnaps"], "Check maximum number of recurring snapshots retained") snapshot = snapshots[0] # Sleep to ensure that snapshot is reflected in sec storage time.sleep(self.services["sleep"]) self.assertTrue( is_snapshot_on_nfs(self.apiclient, self.dbclient, self.config, self.zone.id, snapshot.id)) return
def test_01_createVM_snapshotTemplate(self): """Test create VM, Snapshot and Template """ # Validate the following # 1. Deploy VM using default template, small service offering # and small data disk offering. # 2. Perform snapshot on the root disk of this VM. # 3. Create a template from snapshot. # 4. Create a instance from above created template. # 5. listSnapshots should list the snapshot that was created. # 6. verify that secondary storage NFS share contains the reqd # volume under /secondary/snapshots/$accountid/$volumeid/$snapshot_uuid # 7. verify backup_snap_id was non null in the `snapshots` table # 8. listTemplates() should return the newly created Template, # and check for template state as READY" # 9. listVirtualMachines() command should return the deployed VM. # State of this VM should be Running. #Create Virtual Machine self.virtual_machine = VirtualMachine.create( self.apiclient, self.services["server"], templateid=self.template.id, accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_offering.id) self.debug("Created VM with ID: %s" % self.virtual_machine.id) # Get the Root disk of VM volumes = list_volumes(self.apiclient, virtualmachineid=self.virtual_machine.id, type='ROOT', listall=True) volume = volumes[0] # Create a snapshot from the ROOTDISK snapshot = Snapshot.create(self.apiclient, volumes[0].id) self.debug("Snapshot created: ID - %s" % snapshot.id) self.cleanup.append(snapshot) snapshots = list_snapshots(self.apiclient, id=snapshot.id) self.assertEqual(isinstance(snapshots, list), True, "Check list response returns a valid list") self.assertNotEqual(snapshots, None, "Check if result exists in list snapshots call") self.assertEqual(snapshots[0].id, snapshot.id, "Check snapshot id in list resources call") self.debug("select backup_snap_id, account_id, volume_id from snapshots where uuid = '%s';" \ % snapshot.id) snapshot_uuid = snapshot.id # Generate template from the snapshot template = Template.create_from_snapshot(self.apiclient, snapshot, self.services["templates"]) self.debug("Created template from snapshot: %s" % template.id) self.cleanup.append(template) templates = list_templates( self.apiclient, templatefilter=\ self.services["templates"]["templatefilter"], id=template.id ) self.assertNotEqual(templates, None, "Check if result exists in list item call") self.assertEqual(templates[0].isready, True, "Check new template state in list templates call") # Deploy new virtual machine using template new_virtual_machine = VirtualMachine.create( self.apiclient, self.services["server"], templateid=template.id, accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_offering.id) self.debug("Created VM with ID: %s from template: %s" % (new_virtual_machine.id, template.id)) self.cleanup.append(new_virtual_machine) # Newly deployed VM should be 'Running' virtual_machines = list_virtual_machines( self.apiclient, id=new_virtual_machine.id, account=self.account.name, domainid=self.account.domainid) self.assertEqual(isinstance(virtual_machines, list), True, "Check list response returns a valid list") self.assertNotEqual(len(virtual_machines), 0, "Check list virtual machines response") for virtual_machine in virtual_machines: self.assertEqual(virtual_machine.state, 'Running', "Check list VM response for Running state") self.assertTrue( is_snapshot_on_nfs(self.apiclient, self.dbclient, self.config, self.zone.id, snapshot_uuid)) return
def test_01_snapshot_on_rootVolume(self): """Test create VM with default cent os template and create snapshot on root disk of the vm """ # Validate the following # 1. Deploy a Linux VM using default CentOS template, use small service # offering, disk offering # 2. Create snapshot on the root disk of this newly cteated vm # 3. listSnapshots should list the snapshot that was created. # 4. verify that secondary storage NFS share contains the reqd # volume under /secondary/snapshots/$accountid/$volumeid/$snapshot_uuid # 5. verify backup_snap_id was non null in the `snapshots` table # Create virtual machine with small systerm offering and disk offering new_virtual_machine = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], templateid=self.template.id, zoneid=self.zone.id, accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_offering.id, diskofferingid=self.disk_offering.id, ) self.debug("Virtual machine got created with id: %s" % new_virtual_machine.id) list_virtual_machine_response = VirtualMachine.list( self.apiclient, id=new_virtual_machine.id) self.assertEqual(isinstance(list_virtual_machine_response, list), True, "Check listVirtualMachines returns a valid list") self.assertNotEqual(len(list_virtual_machine_response), 0, "Check listVirtualMachines response") self.cleanup.append(new_virtual_machine) # Getting root volume id of the vm created above list_volume_response = Volume.list( self.apiclient, virtualmachineid=list_virtual_machine_response[0].id, type="ROOT", account=self.account.name, domainid=self.account.domainid) self.assertEqual(isinstance(list_volume_response, list), True, "Check listVolumes returns a valid list") self.assertNotEqual(len(list_volume_response), 0, "Check listVolumes response") self.debug( "Snapshot will be created on the volume with voluem id: %s" % list_volume_response[0].id) # Perform snapshot on the root volume root_volume_snapshot = Snapshot.create( self.apiclient, volume_id=list_volume_response[0].id) self.debug( "Created snapshot: %s for vm: %s" % (root_volume_snapshot.id, list_virtual_machine_response[0].id)) list_snapshot_response = Snapshot.list(self.apiclient, id=root_volume_snapshot.id, account=self.account.name, domainid=self.account.domainid) self.assertEqual(isinstance(list_snapshot_response, list), True, "Check listSnapshots returns a valid list") self.assertNotEqual(len(list_snapshot_response), 0, "Check listSnapshots response") # Verify Snapshot state self.assertEqual( list_snapshot_response[0].state in ['BackedUp', 'CreatedOnPrimary'], True, "Snapshot state is not as expected. It is %s" % list_snapshot_response[0].state) self.assertEqual( list_snapshot_response[0].volumeid, list_volume_response[0].id, "Snapshot volume id is not matching with the vm's volume id") self.cleanup.append(root_volume_snapshot) # Below code is to verify snapshots in the backend and in db. # Verify backup_snap_id field in the snapshots table for the snapshot created, it should not be null self.debug( "select id, removed, backup_snap_id from snapshots where uuid = '%s';" % root_volume_snapshot.id) qryresult = self.dbclient.execute( "select id, removed, backup_snap_id from snapshots where uuid = '%s';" % root_volume_snapshot.id) self.assertNotEqual(len(qryresult), 0, "Check sql query to return snapshots list") snapshot_qry_response = qryresult[0] snapshot_id = snapshot_qry_response[0] is_removed = snapshot_qry_response[1] backup_snap_id = snapshot_qry_response[2] self.assertNotEqual( is_removed, "NULL", "Snapshot is removed from CS, please check the logs") msg = "Backup snapshot id is set to null for the backedup snapshot :%s" % snapshot_id self.assertNotEqual(backup_snap_id, "NULL", msg) # Check if the snapshot is present on the secondary storage self.assertTrue( is_snapshot_on_nfs(self.apiclient, self.dbclient, self.config, self.zone.id, root_volume_snapshot.id)) return
def test_02_accountSnapshotClean(self): """Test snapshot cleanup after account deletion """ # Validate the following # 1. listAccounts API should list out the newly created account # 2. listVirtualMachines() command should return the deployed VM. # State of this VM should be "Running" # 3. a)listSnapshots should list the snapshot that was created. # b)verify that secondary storage NFS share contains the reqd volume # under /secondary/snapshots/$accountid/$volumeid/$snapshot_id # 4. a)listAccounts should not list account that is deleted # b) snapshot image($snapshot_id) should be deleted from the # /secondary/snapshots/$accountid/$volumeid/ accounts = list_accounts(self.apiclient, id=self.account.id) self.assertEqual(isinstance(accounts, list), True, "Check list response returns a valid list") self.assertNotEqual(len(accounts), 0, "Check list Accounts response") # VM should be in 'Running' state virtual_machines = list_virtual_machines(self.apiclient, id=self.virtual_machine.id) self.assertEqual(isinstance(virtual_machines, list), True, "Check list response returns a valid list") self.assertNotEqual(len(virtual_machines), 0, "Check list virtual machines response") for virtual_machine in virtual_machines: self.debug("VM ID: %s, VM state: %s" % (virtual_machine.id, virtual_machine.state)) self.assertEqual(virtual_machine.state, 'Running', "Check list VM response for Running state") # Verify the snapshot was created or not snapshots = list_snapshots(self.apiclient, id=self.snapshot.id) self.assertEqual(isinstance(snapshots, list), True, "Check list response returns a valid list") self.assertNotEqual(snapshots, None, "No such snapshot %s found" % self.snapshot.id) self.assertEqual(snapshots[0].id, self.snapshot.id, "Check snapshot id in list resources call") self.assertTrue( is_snapshot_on_nfs(self.apiclient, self.dbclient, self.config, self.zone.id, self.snapshot.id), "Snapshot was not found on NFS") self.debug("Deleting account: %s" % self.account.name) # Delete account self.account.delete(self.apiclient) # Wait for account cleanup interval wait_for_cleanup(self.apiclient, configs=["account.cleanup.interval"]) accounts = list_accounts(self.apiclient, id=self.account.id) self.assertEqual( accounts, None, "List accounts should return empty list after account deletion") self.assertFalse( is_snapshot_on_nfs(self.apiclient, self.dbclient, self.config, self.zone.id, self.snapshot.id), "Snapshot was still found on NFS after account gc") return