harikrishna-patnala commented on a change in pull request #5008:
URL: https://github.com/apache/cloudstack/pull/5008#discussion_r699005166
##########
File path: test/integration/smoke/test_service_offerings.py
##########
@@ -614,6 +615,204 @@ def test_04_change_offering_small(self):
)
return
+ @attr(tags=["advanced", "advancedns", "smoke"], required_hardware="true")
+ def test_05_disk_offering_strictness_true(self):
+ """Test to see change service offering is not possible when disk
offering strictness is set to true
+ """
+ # Validate the following
+ # 1. Create service offering linked a disk offering and disk offering
strictness is true
+ # 2. Create a VM with that service offering
+ # 3. Create another service offering with a different disk offering
+ # 4. Try change service offering for VM and it will fail since disk
offering strictness is true (not allowed to change the disk offering)
+
+ if self.hypervisor.lower() == "lxc":
+ self.skipTest("Skipping this test for {} due to bug
CS-38153".format(self.hypervisor))
+ offering_data = {
+ 'displaytext': 'TestDiskOfferingStrictnessTrue',
+ 'cpuspeed': 512,
+ 'cpunumber': 2,
+ 'name': 'TestDiskOfferingStrictnessTrue',
+ 'memory': 1024,
+ 'diskofferingstrictness': True
+ }
+
+ self.serviceOfferingWithDiskOfferingStrictnessTrue =
ServiceOffering.create(
+ self.apiclient,
+ offering_data,
+ )
+
self._cleanup.append(self.serviceOfferingWithDiskOfferingStrictnessTrue)
+
+ self.virtual_machine_with_diskoffering_strictness_true =
VirtualMachine.create(
+ self.apiclient,
+ self.services["small"],
+ accountid=self.account.name,
+ domainid=self.account.domainid,
+
serviceofferingid=self.serviceOfferingWithDiskOfferingStrictnessTrue.id,
+ mode=self.services["mode"]
+ )
+
+ try:
+
self.virtual_machine_with_diskoffering_strictness_true.stop(self.apiclient)
+
+ timeout = self.services["timeout"]
+
+ while True:
+ time.sleep(self.services["sleep"])
+
+ # Ensure that VM is in stopped state
+ list_vm_response = list_virtual_machines(
+ self.apiclient,
+
id=self.virtual_machine_with_diskoffering_strictness_true.id
+ )
+
+ if isinstance(list_vm_response, list):
+ vm = list_vm_response[0]
+ if vm.state == 'Stopped':
+ self.debug("VM state: %s" % vm.state)
+ break
+
+ if timeout == 0:
+ raise Exception(
+ "Failed to stop VM (ID: %s) in change service
offering" % vm.id)
+
+ timeout = timeout - 1
+ except Exception as e:
+ self.fail("Failed to stop VM: %s" % e)
+
+ offering_data = {
+ 'displaytext': 'TestDiskOfferingStrictnessTrue2',
+ 'cpuspeed': 1000,
+ 'cpunumber': 2,
+ 'name': 'TestDiskOfferingStrictnessTrue2',
+ 'memory': 1024,
+ 'diskofferingstrictness': True
+ }
+
+ self.serviceOfferingWithDiskOfferingStrictnessTrue2 =
ServiceOffering.create(
+ self.apiclient,
+ offering_data,
+ )
+
self._cleanup.append(self.serviceOfferingWithDiskOfferingStrictnessTrue2)
+ cmd =
changeServiceForVirtualMachine.changeServiceForVirtualMachineCmd()
+ cmd.id = self.virtual_machine_with_diskoffering_strictness_true.id
+ cmd.serviceofferingid =
self.serviceOfferingWithDiskOfferingStrictnessTrue2.id
+
+ with self.assertRaises(Exception) as e:
+ self.apiclient.changeServiceForVirtualMachine(cmd)
+ self.debug("Upgrade VM with new service offering having different
disk offering operation failed as expected with exception: %s" %
+ e.exception)
+ return
+
+ @attr(tags=["advanced", "advancedns", "smoke"], required_hardware="true")
+ def test_06_disk_offering_strictness_false(self):
+ """Test to see change service offering is possible when disk offering
strictness is set to false
+ """
+ # Validate the following
+ # 1. Create service offering linked a disk offering and disk offering
strictness is false
+ # 2. Create a VM with that service offering
+ # 3. Create another service offering with a different disk offering
and disk offering strictness is false
+ # 4. Try change service offering for VM should succeed
+
+ if self.hypervisor.lower() == "lxc":
+ self.skipTest("Skipping this test for {} due to bug
CS-38153".format(self.hypervisor))
+
+ offering_data = {
+ 'displaytext': 'TestDiskOfferingStrictnessFalse',
+ 'cpuspeed': 512,
+ 'cpunumber': 2,
+ 'name': 'TestDiskOfferingStrictnessFalse',
+ 'memory': 1024,
+ 'diskofferingstrictness': False
+ }
+
+ self.serviceOfferingWithDiskOfferingStrictnessFalse =
ServiceOffering.create(
+ self.apiclient,
+ offering_data,
+ )
+
self._cleanup.append(self.serviceOfferingWithDiskOfferingStrictnessFalse)
+
+ self.virtual_machine_with_diskoffering_strictness_false =
VirtualMachine.create(
+ self.apiclient,
+ self.services["small"],
+ accountid=self.account.name,
+ domainid=self.account.domainid,
+
serviceofferingid=self.serviceOfferingWithDiskOfferingStrictnessFalse.id,
+ mode=self.services["mode"]
+ )
+
+ try:
+
self.virtual_machine_with_diskoffering_strictness_false.stop(self.apiclient)
+
+ timeout = self.services["timeout"]
+
+ while True:
+ time.sleep(self.services["sleep"])
+
+ # Ensure that VM is in stopped state
+ list_vm_response = list_virtual_machines(
+ self.apiclient,
+
id=self.virtual_machine_with_diskoffering_strictness_false.id
+ )
+
+ if isinstance(list_vm_response, list):
+ vm = list_vm_response[0]
+ if vm.state == 'Stopped':
+ self.debug("VM state: %s" % vm.state)
+ break
+
+ if timeout == 0:
+ raise Exception(
+ "Failed to stop VM (ID: %s) in change service
offering" % vm.id)
+
+ timeout = timeout - 1
+ except Exception as e:
+ self.fail("Failed to stop VM: %s" % e)
+
+ self.disk_offering2 = DiskOffering.create(
+ self.apiclient,
+ self.services["disk_offering"],
+ )
+ self._cleanup.append(self.disk_offering2)
+ offering_data = {
Review comment:
Yes, it is test case specific. Resolving the previous comments too.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]