Ejemplo n.º 1
0
 def create_domain_account_user(parentDomain=None):
     domain  =  Domain.create(cls.api_client,
                              cls.services["domain"],
                              parentdomainid=parentDomain.id if parentDomain else None)
     cls._cleanup.append(domain)
     # Create an Account associated with domain
     account = Account.create(cls.api_client,
                              cls.services["account"],
                              domainid=domain.id)
     cls._cleanup.append(account)
     # Create an User, Project, Volume associated with account
     user    = User.create(cls.api_client,
                           cls.services["user"],
                           account=account.name,
                           domainid=account.domainid)
     cls._cleanup.append(user)
     project = Project.create(cls.api_client,
                              cls.services["project"],
                              account=account.name,
                              domainid=account.domainid)
     cls._cleanup.append(project)
     volume  = Volume.create(cls.api_client,
                             cls.services["volume"],
                             zoneid=cls.zone.id,
                             account=account.name,
                             domainid=account.domainid,
                             diskofferingid=cls.disk_offering.id)
     cls._cleanup.append(volume)
     return {'domain':domain, 'account':account, 'user':user, 'project':project, 'volume':volume}
    def test_04_concurrent_snapshots_create_volume(self):
        """Test while parent concurrent snapshot job in progress,create volume
            from completed snapshot

            1.Configure the concurrent.snapshots.threshold.perhost=3
            2.Deploy a Linux VM using default CentOS template, use small
            service offering, disk offering.
            3.Perform snapshot on root disk of this newly created VM
            4.while parent concurrent snapshot job in progress,create volume
            from completed snapshot"""

        # Validate the following
        # a.Able to create Volume from snapshots
        # b.check all snapshots jobs are running concurrently on back grounds
        # c.listSnapshots should list this newly created snapshot.

        self.debug("Create virtual machine and snapshot on ROOT disk thread")
        self.create_Snapshot_VM()

        self.debug("Verify whether snapshots were created properly or not?")
        self.verify_Snapshots()

        self.debug("Fetch the list of snapshots belong to account: %s" %
                                                    self.account.name)
        snapshots = self.get_Snapshots_For_Account(
                                                self.account.name,
                                                self.account.domainid)
        jobs = []
        for snapshot in snapshots:
            self.debug("Create a volume from snapshot: %s" % snapshot.name)
            jobs.append(self.create_Volume_from_Snapshot(snapshot))

        # Verify IO usage by submitting the concurrent jobs
        self.testClient.submitCmdsAndWait(jobs)

        self.debug("Verifying if volume created properly or not?")
        volumes = Volume.list(self.apiclient,
                              account=self.account.name,
                              domainid=self.account.domainid,
                              listall=True,
                              type='ROOT')

        self.assertNotEqual(volumes,
                            None,
                            "Check if result exists in list item call")
        for volume in volumes:
            self.debug("Volume: %s, state: %s" % (volume.name, volume.state))
            self.assertEqual(volume.state,
                         "Ready",
                         "Check new volume state in list volumes call")

        self.debug("Test completed successfully.")
        return
Ejemplo n.º 3
0
    def test_04_concurrent_snapshots_create_volume(self):
        """Test while parent concurrent snapshot job in progress,create volume
            from completed snapshot

            1.Configure the concurrent.snapshots.threshold.perhost=3
            2.Deploy a Linux VM using default CentOS template, use small
            service offering, disk offering.
            3.Perform snapshot on root disk of this newly created VM
            4.while parent concurrent snapshot job in progress,create volume
            from completed snapshot"""

        # Validate the following
        # a.Able to create Volume from snapshots
        # b.check all snapshots jobs are running concurrently on back grounds
        # c.listSnapshots should list this newly created snapshot.

        self.debug("Create virtual machine and snapshot on ROOT disk thread")
        self.create_Snapshot_VM()

        self.debug("Verify whether snapshots were created properly or not?")
        self.verify_Snapshots()

        self.debug("Fetch the list of snapshots belong to account: %s" %
                   self.account.name)
        snapshots = self.get_Snapshots_For_Account(self.account.name,
                                                   self.account.domainid)
        jobs = []
        for snapshot in snapshots:
            self.debug("Create a volume from snapshot: %s" % snapshot.name)
            jobs.append(self.create_Volume_from_Snapshot(snapshot))

        # Verify IO usage by submitting the concurrent jobs
        self.testClient.submitCmdsAndWait(jobs)

        self.debug("Verifying if volume created properly or not?")
        volumes = Volume.list(self.apiclient,
                              account=self.account.name,
                              domainid=self.account.domainid,
                              listall=True,
                              type='ROOT')

        self.assertNotEqual(volumes, None,
                            "Check if result exists in list item call")
        for volume in volumes:
            self.debug("Volume: %s, state: %s" % (volume.name, volume.state))
            self.assertEqual(volume.state, "Ready",
                             "Check new volume state in list volumes call")

        self.debug("Test completed successfully.")
        return
Ejemplo n.º 4
0
    def create_Snapshot_On_Root_Disk(self, virtual_machine):
        try:
            volumes = Volume.list(self.apiclient,
                                  virtualmachineid=virtual_machine.id,
                                  type='ROOT',
                                  listall=True)
            self.assertEqual(isinstance(volumes, list), True,
                             "Check list response returns a valid list")
            volume = volumes[0]

            cmd = createSnapshot.createSnapshotCmd()
            cmd.volumeid = volume.id
            cmd.account = self.account.name
            cmd.domainid = self.account.domainid
            return cmd
        except Exception as e:
            self.fail('Unable to create new job for snapshot: %s' % e)
    def create_Snapshot_On_Root_Disk(self, virtual_machine):
        try:
            volumes = Volume.list(
                                  self.apiclient,
                                  virtualmachineid=virtual_machine.id,
                                  type='ROOT',
                                  listall=True
                                  )
            self.assertEqual(
                            isinstance(volumes, list),
                            True,
                            "Check list response returns a valid list"
                        )
            volume = volumes[0]

            cmd = createSnapshot.createSnapshotCmd()
            cmd.volumeid = volume.id
            cmd.account = self.account.name
            cmd.domainid = self.account.domainid
            return cmd
        except Exception as e:
            self.fail('Unable to create new job for snapshot: %s' % e)
Ejemplo n.º 6
0
 def create_domain_account_user(parentDomain=None):
     domain = Domain.create(
         cls.api_client,
         cls.services["domain"],
         parentdomainid=parentDomain.id if parentDomain else None)
     cls._cleanup.append(domain)
     # Create an Account associated with domain
     account = Account.create(cls.api_client,
                              cls.services["account"],
                              domainid=domain.id)
     cls._cleanup.append(account)
     # Create an User, Project, Volume associated with account
     user = User.create(cls.api_client,
                        cls.services["user"],
                        account=account.name,
                        domainid=account.domainid)
     cls._cleanup.append(user)
     project = Project.create(cls.api_client,
                              cls.services["project"],
                              account=account.name,
                              domainid=account.domainid)
     cls._cleanup.append(project)
     volume = Volume.create(cls.api_client,
                            cls.services["volume"],
                            zoneid=cls.zone.id,
                            account=account.name,
                            domainid=account.domainid,
                            diskofferingid=cls.disk_offering.id)
     cls._cleanup.append(volume)
     return {
         'domain': domain,
         'account': account,
         'user': user,
         'project': project,
         'volume': volume
     }
 def get_root_device_uuid_for_vm(cls, vm_id, root_device_id):
     volumes = Volume.list(cls.api_client,
                           virtualmachineid=vm_id,
                           listall=True)
     return volumes[root_device_id].id
    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
Ejemplo n.º 9
0
    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 get_root_device_uuid_for_vm(cls, vm_id, root_device_id):
     volumes = Volume.list(cls.api_client, virtualmachineid=vm_id, listall=True)
     return volumes[root_device_id].id