You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ra...@apache.org on 2017/04/18 09:48:46 UTC

[cloudstack] branch master updated (b8dd08c -> d96b3cd)

This is an automated email from the ASF dual-hosted git repository.

rajani pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git.

      from  b8dd08c   Merge pull request #2036 from rafaelweingartner/midoneDisablingForRetirement
      adds  e82a635   CLOUDSTACK-9876: Removed test test_01_test_vm_volume_snapshot as we no longer have that restriction and now after fix for CLOUDSTACK-8663 we allow VM and volume snapshots to exist together
      adds  41b7eee   Merge pull request #2043 from anshul1886/CLOUDSTACK-9876
       new  d96b3cd   Merge release branch 4.9 to master

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "adds" were already present in the repository and have only
been added to this reference.


Summary of changes:
 test/integration/smoke/test_vm_snapshots.py | 124 +---------------------------
 1 file changed, 1 insertion(+), 123 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
['"commits@cloudstack.apache.org" <co...@cloudstack.apache.org>'].

[cloudstack] 01/01: Merge release branch 4.9 to master

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rajani pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git

commit d96b3cd19c1657e1048b418a0125127ff7ad02e1
Merge: b8dd08c 41b7eee
Author: Rajani Karuturi <ra...@accelerite.com>
AuthorDate: Tue Apr 18 15:17:00 2017 +0530

    Merge release branch 4.9 to master
    
    * 4.9:
      CLOUDSTACK-9876: Removed test test_01_test_vm_volume_snapshot as we no longer have that restriction and now after fix for CLOUDSTACK-8663 we allow VM and volume snapshots to exist together

 test/integration/smoke/test_vm_snapshots.py | 124 +---------------------------
 1 file changed, 1 insertion(+), 123 deletions(-)

diff --cc test/integration/smoke/test_vm_snapshots.py
index ce1d038,9295ec1..4bfe66a
--- a/test/integration/smoke/test_vm_snapshots.py
+++ b/test/integration/smoke/test_vm_snapshots.py
@@@ -288,376 -277,3 +286,256 @@@ class TestVmSnapshot(cloudstackTestCase
              None,
              "Check list vm snapshot has be deleted"
          )
 +
- class TestSnapshots(cloudstackTestCase):
- 
-     @classmethod
-     def setUpClass(cls):
-         try:
-             cls._cleanup = []
-             cls.testClient = super(TestSnapshots, cls).getClsTestClient()
-             cls.api_client = cls.testClient.getApiClient()
-             cls.services = cls.testClient.getParsedTestDataConfig()
-             cls.unsupportedHypervisor = False
-             cls.hypervisor = cls.testClient.getHypervisorInfo()
-             if cls.hypervisor.lower() in (KVM.lower(), "hyperv", "lxc", XEN_SERVER.lower()):
-                 cls.unsupportedHypervisor = True
-                 return
-             # Get Domain, Zone, Template
-             cls.domain = get_domain(cls.api_client)
-             cls.zone = get_zone(
-                 cls.api_client,
-                 cls.testClient.getZoneForTests())
-             cls.template = get_template(
-                 cls.api_client,
-                 cls.zone.id,
-                 cls.services["ostype"]
-             )
-             if cls.zone.localstorageenabled:
-                 cls.storagetype = 'local'
-                 cls.services["service_offerings"][
-                     "tiny"]["storagetype"] = 'local'
-             else:
-                 cls.storagetype = 'shared'
-                 cls.services["service_offerings"][
-                     "tiny"]["storagetype"] = 'shared'
- 
-             cls.services['mode'] = cls.zone.networktype
-             cls.services["virtual_machine"]["hypervisor"] = cls.hypervisor
-             cls.services["virtual_machine"]["zoneid"] = cls.zone.id
-             cls.services["virtual_machine"]["template"] = cls.template.id
-             cls.services["custom_volume"]["zoneid"] = cls.zone.id
-             # Creating Disk offering, Service Offering and Account
-             cls.service_offering = ServiceOffering.create(
-                 cls.api_client,
-                 cls.services["service_offerings"]["tiny"]
-             )
-             cls._cleanup.append(cls.service_offering)
-             cls.account = Account.create(
-                 cls.api_client,
-                 cls.services["account"],
-                 domainid=cls.domain.id
-             )
-             cls._cleanup.append(cls.account)
-         except Exception as e:
-             cls.tearDownClass()
-             raise Exception("Warning: Exception in setup : %s" % e)
-         return
- 
-     def setUp(self):
- 
-         self.apiclient = self.testClient.getApiClient()
-         self.dbclient = self.testClient.getDbConnection()
-         self.cleanup = []
- 
-         if self.unsupportedHypervisor:
-             self.skipTest("Skipping test because unsupported\
-                     hypervisor %s" % self.hypervisor)
- 
-     def tearDown(self):
-         # Clean up, terminate the created resources
-         cleanup_resources(self.apiclient, self.cleanup)
-         return
- 
-     @classmethod
-     def tearDownClass(cls):
-         try:
-             cleanup_resources(cls.api_client, cls._cleanup)
-         except Exception as e:
-             raise Exception("Warning: Exception during cleanup : %s" % e)
- 
-         return
- 
-     @attr(tags=["advanced", "basic", "smoke"], required_hardware="true")
-     def test_01_test_vm_volume_snapshot(self):
-         """
-         @Desc: Test that Volume snapshot for root volume is not allowed
-         when VM snapshot is present for the VM
-         @Steps:
-         1: Deploy a VM and create a VM snapshot for VM
-         2: Try to create snapshot for the root volume of the VM,
-         It should expect Exception
-         """
- 
-         # Creating Virtual Machine
-         virtual_machine = VirtualMachine.create(
-             self.apiclient,
-             self.services["virtual_machine"],
-             accountid=self.account.name,
-             domainid=self.account.domainid,
-             serviceofferingid=self.service_offering.id,
-         )
- 
-         VmSnapshot.create(
-             self.apiclient,
-             virtual_machine.id,
-         )
- 
-         volumes = Volume.list(self.apiclient,
-                               virtualmachineid=virtual_machine.id,
-                               type="ROOT",
-                               listall=True)
- 
-         self.assertEqual(validateList(volumes)[0], PASS,
-                 "Failed to get root volume of the VM")
- 
-         volume = volumes[0]
- 
-         with self.assertRaises(Exception):
-             Snapshot.create(self.apiclient,
-                             volume_id=volume.id)
- 
-         return
- 
 +class Utils:
 +    
 +    def __init__(self):
 +        self.added_service_offerings = {
 +            'testOffering1' : {'displaytext': 'Test Offering 1', 'cpuspeed': 600, 'cpunumber': 1, 'name': 'Test Offering 1', 'memory': 256}, 
 +            'testOffering2' : {'displaytext': 'Test Offering 2', 'cpuspeed': 600, 'cpunumber': 2, 'name': 'Test Offering 2', 'memory': 512}                            
 +        }
 +    
 +class TestChangeServiceOfferingForVmWithSnapshots(cloudstackTestCase):
 +        
 +    @classmethod
 +    def setUpClass(cls):
 +        try:
 +            cls._cleanup = []
 +            cls.testClient = super(TestChangeServiceOfferingForVmWithSnapshots, cls).getClsTestClient()
 +            cls.api_client = cls.testClient.getApiClient()
 +            cls.services = cls.testClient.getParsedTestDataConfig()
 +            cls.hypervisor = cls.testClient.getHypervisorInfo()
 +            cls.unsupportedHypervisor = False
 +            if cls.hypervisor.lower() in (KVM.lower(), "hyperv", "lxc"):
 +                cls.unsupportedHypervisor = True
 +                return
 +            
 +            cls.domain = get_domain(cls.api_client)
 +            cls.zone = get_zone(
 +                cls.api_client,
 +                cls.testClient.getZoneForTests()
 +            )
 +            cls.services["small"]["zoneid"] = cls.zone.id
 +            cls.template = get_template(
 +                cls.api_client,
 +                cls.zone.id,
 +                cls.services["ostype"]
 +            )
 +            if cls.template == FAILED:
 +                assert False, "get_template() failed to return template\
 +                    with description %s" % cls.services["ostype"]
 +            
 +            test_offerings = Utils().added_service_offerings
 +            for offering in test_offerings:
 +                cls.services["service_offerings"][offering] = test_offerings[offering]
 +                
 +            # Create 2 different service offerings
 +            cls.service_offering_1 = ServiceOffering.create(
 +                cls.api_client,
 +                cls.services["service_offerings"]["testOffering1"]
 +            )
 +            cls._cleanup.append(cls.service_offering_1)
 +            
 +            cls.service_offering_2 = ServiceOffering.create(
 +                cls.api_client,
 +                cls.services["service_offerings"]["testOffering2"]
 +            )
 +            cls._cleanup.append(cls.service_offering_2)
 +            
 +            cls.account = Account.create(
 +                cls.api_client,
 +                cls.services["account"],
 +                domainid=cls.domain.id
 +            )
 +            cls._cleanup.append(cls.account)
 +            
 +        except Exception as e:
 +            cls.tearDownClass()
 +            raise Exception("Warning: Exception in setup : %s" % e)
 +        return
 +
 +    def setUp(self):
 +        self.apiclient = self.testClient.getApiClient()
 +        self.dbclient = self.testClient.getDbConnection()
 +        self.cleanup = []
 +        
 +        if self.unsupportedHypervisor:
 +            self.skipTest("Skipping test because unsupported hypervisor\
 +                    %s" % self.hypervisor)
 +        
 +    def tearDown(self):
 +        # Clean up, terminate the created resources
 +        cleanup_resources(self.apiclient, self.cleanup)
 +        return
 +
 +    @classmethod
 +    def tearDownClass(cls):
 +        try:
 +            cleanup_resources(cls.api_client, cls._cleanup)
 +        except Exception as e:
 +            raise Exception("Warning: Exception during cleanup : %s" % e)
 +
 +        return
 +    
 +    def wait_vm_start(self, apiclient, vmid, timeout, sleep):
 +        while timeout:
 +            vms = VirtualMachine.list(apiclient, id=vmid)
 +            vm_list_validation_result = validateList(vms)
 +            if vm_list_validation_result[0] == PASS and vm_list_validation_result[1].state == RUNNING:
 +                return timeout
 +            time.sleep(sleep)
 +            timeout = timeout - 1
 +
 +        return timeout
 +    
 +    def checkCPUAndMemory(self, ssh, service_offering):
 +        cpuinfo = ssh.execute("cat /proc/cpuinfo")
 +        cpu_cnt = len([i for i in cpuinfo if "processor" in i])
 +        # 'cpu MHz\t\t: 2660.499'
 +        cpu_speed = [i for i in cpuinfo if "cpu MHz" in i][0].split()[3]
 +        meminfo = ssh.execute("cat /proc/meminfo")
 +        # MemTotal:        1017464 kB
 +        total_mem = [i for i in meminfo if "MemTotal" in i][0].split()[1]
 +
 +        self.debug(
 +            "CPU count: %s, CPU Speed: %s, Mem Info: %s" % (cpu_cnt, cpu_speed, total_mem)
 +        )
 +        self.assertAlmostEqual(
 +            int(cpu_cnt),
 +            service_offering.cpunumber,
 +            "Check CPU Count for service offering"
 +        )
 +
 +        range = 40
 +        if self.hypervisor.lower() == "hyperv":
 +            range = 200
 +        self.assertTrue(
 +            isAlmostEqual(int(int(total_mem) / 1024),
 +                          int(service_offering.memory),
 +                          range=range
 +            ),
 +            "Check Memory(kb) for service offering"
 +        )
 +
 +    @attr(tags=["advanced", "smoke"], required_hardware="true")
 +    def test_change_service_offering_for_vm_with_snapshots(self):
 +        """Test to change service offering for instances with vm snapshots
 +        """
 +        
 +        # 1) Create Virtual Machine using service offering 1
 +        self.debug("Creating VM using Service Offering 1")
 +        virtual_machine = VirtualMachine.create(
 +            self.apiclient,
 +            self.services["small"],
 +            accountid=self.account.name,
 +            domainid=self.account.domainid,
 +            templateid=self.template.id,
 +            zoneid=self.zone.id,
 +            hypervisor=self.hypervisor,
 +            mode=self.zone.networktype,
 +            serviceofferingid=self.service_offering_1.id
 +        )
 +        
 +        # Verify Service OFfering 1 CPU cores and memory
 +        try:
 +            ssh_client = virtual_machine.get_ssh_client(reconnect=True)
 +            self.checkCPUAndMemory(ssh_client, self.service_offering_1)
 +        except Exception as e:
 +            self.fail("SSH failed for virtual machine: %s - %s" % (virtual_machine.ipaddress, e))
 +        
 +        # 2) Take VM Snapshot
 +        self.debug("Taking VM Snapshot for VM - ID: %s" % virtual_machine.id)
 +        vm_snapshot = VmSnapshot.create(
 +            self.apiclient,
 +            virtual_machine.id,
 +        )
 +        
 +        # 3) Stop Virtual Machine
 +        self.debug("Stopping VM - ID: %s" % virtual_machine.id)
 +        try:
 +            virtual_machine.stop(self.apiclient)
 +        except Exception as e:
 +            self.fail("Failed to stop VM: %s" % e)
 +        
 +        # 4) Change service offering for VM with snapshots from Service Offering 1 to Service Offering 2
 +        self.debug("Changing service offering from Service Offering 1 to Service Offering 2 for VM - ID: %s" % virtual_machine.id)
 +        virtual_machine.change_service_offering(self.apiclient, self.service_offering_2.id)
 +        
 +        # 5) Start VM
 +        self.debug("Starting VM - ID: %s" % virtual_machine.id)
 +        try:
 +            virtual_machine.start(self.apiclient)
 +        except Exception as e:
 +            self.fail("Failed to start virtual machine: %s, %s" % (virtual_machine.name, e))
 +        
 +        # Wait for vm to start
 +        timeout = self.wait_vm_start(self.apiclient, virtual_machine.id, self.services["timeout"],
 +                            self.services["sleep"])
 +        if timeout == 0:
 +            self.fail("The virtual machine %s failed to start even after %s minutes"
 +                   % (virtual_machine.name, self.services["timeout"]))
 +        
 +        list_vm_response = list_virtual_machines(
 +            self.apiclient,
 +            id=virtual_machine.id
 +        )
 +        self.assertEqual(
 +            isinstance(list_vm_response, list),
 +            True,
 +            "Check list response returns a valid list"
 +        )
 +        self.assertNotEqual(
 +            len(list_vm_response),
 +            0,
 +            "Check VM avaliable in List Virtual Machines"
 +        )
 +        self.assertEqual(
 +            list_vm_response[0].state,
 +            "Running",
 +            "Check virtual machine is in running state"
 +        )
 +        self.assertEqual(
 +            list_vm_response[0].id,
 +            virtual_machine.id,
 +            "Check virtual machine id"
 +        )
 +        
 +        # 6) Verify service offering has changed
 +        try:
 +            ssh_client_2 = virtual_machine.get_ssh_client(reconnect=True)
 +            self.checkCPUAndMemory(ssh_client_2, self.service_offering_2)
 +        except Exception as e:
 +            self.fail("SSH failed for virtual machine: %s - %s" % (virtual_machine.ipaddress, e))
 +        
 +        # 7) Stop Virtual Machine
 +        self.debug("Stopping VM - ID: %s" % virtual_machine.id)
 +        try:
 +            virtual_machine.stop(self.apiclient)
 +        except Exception as e:
 +            self.fail("Failed to stop VM: %s" % e)
 +        
 +        # 8) Revert to VM Snapshot
 +        self.debug("Revert to vm snapshot: %s" % vm_snapshot.id)
 +        try:
 +            VmSnapshot.revertToSnapshot(
 +                self.apiclient,
 +                vm_snapshot.id
 +            )
 +        except Exception as e:
 +            self.fail("Failed to revert to VM Snapshot: %s - %s" % (vm_snapshot.id, e))
 +        
 +        # 9) Start VM
 +        self.debug("Starting VM - ID: %s" % virtual_machine.id)
 +        try:
 +            virtual_machine.start(self.apiclient)
 +        except Exception as e:
 +            self.fail("Failed to start virtual machine: %s, %s" % (virtual_machine.name, e))
 +            
 +        # 10) Verify service offering has changed to Service Offering 1 (from VM Snapshot)
 +        try:
 +            ssh_client_3 = virtual_machine.get_ssh_client(reconnect=True)
 +            self.checkCPUAndMemory(ssh_client_3, self.service_offering_1)
 +        except Exception as e:
 +            self.fail("SSH failed for virtual machine: %s - %s" % (virtual_machine.ipaddress, e))
 +        
 +        return

-- 
To stop receiving notification emails like this one, please contact
"commits@cloudstack.apache.org" <co...@cloudstack.apache.org>.