Skip to content

Commit 63ff683

Browse files
author
SrikanteswaraRao Talluri
committed
Merge branch '4.5'
2 parents 4bfb7f2 + b3faab6 commit 63ff683

2 files changed

Lines changed: 75 additions & 28 deletions

File tree

‎test/integration/component/test_dynamic_compute_offering.py‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ class TestScaleVmDynamicServiceOffering(cloudstackTestCase):
423423
def setUpClass(cls):
424424
cloudstackTestClient = super(TestScaleVmDynamicServiceOffering,cls).getClsTestClient()
425425
cls.api_client = cloudstackTestClient.getApiClient()
426+
cls.hypervisor = cloudstackTestClient.getHypervisorInfo()
426427

427428
# Fill services from the external config file
428429
cls.services = cloudstackTestClient.getParsedTestDataConfig()
@@ -438,7 +439,23 @@ def setUpClass(cls):
438439
)
439440
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
440441
cls.services["virtual_machine"]["template"] = cls.template.id
442+
441443
cls._cleanup = []
444+
cls.serviceOffering_static_1 = ServiceOffering.create(cls.api_client,
445+
cls.services["service_offering"])
446+
cls._cleanup.append(cls.serviceOffering_static_1)
447+
448+
if cls.hypervisor.lower() == "vmware":
449+
virtual_machine = VirtualMachine.create(cls.api_client,cls.services["virtual_machine"],
450+
serviceofferingid=cls.serviceOffering_static_1.id, mode=cls.zone.networktype)
451+
cls._cleanup.append(virtual_machine)
452+
sshClient = virtual_machine.get_ssh_client()
453+
result = str(
454+
sshClient.execute("service vmware-tools status")).lower()
455+
if not "running" in result:
456+
cls.tearDownClass()
457+
raise unittest.SkipTest("Skipping scale VM operation because\
458+
VMware tools are not installed on the VM")
442459
return
443460

444461
@classmethod

‎test/integration/smoke/test_scale_vm.py‎

Lines changed: 58 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
# to you under the Apache License, Version 2.0 (the
66
# "License"); you may not use this file except in compliance
77
# with the License. You may obtain a copy of the License at
8-
#
8+
#
99
# http://www.apache.org/licenses/LICENSE-2.0
10-
#
10+
#
1111
# Unless required by applicable law or agreed to in writing,
1212
# software distributed under the License is distributed on an
1313
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -16,27 +16,34 @@
1616
# under the License.
1717
""" P1 tests for Scaling up Vm
1818
"""
19-
#Import Local Modules
20-
import marvin
19+
# Import Local Modules
2120
from marvin.codes import FAILED
22-
from marvin.cloudstackTestCase import *
23-
from marvin.cloudstackAPI import *
24-
from marvin.lib.utils import *
25-
from marvin.lib.base import *
26-
from marvin.lib.common import *
21+
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
22+
from marvin.cloudstackAPI import scaleVirtualMachine
23+
from marvin.lib.utils import cleanup_resources
24+
from marvin.lib.base import (Account,
25+
VirtualMachine,
26+
ServiceOffering)
27+
from marvin.lib.common import (get_zone,
28+
get_template,
29+
get_domain)
2730
from nose.plugins.attrib import attr
2831

2932
_multiprocess_shared_ = True
3033

34+
3135
class TestScaleVm(cloudstackTestCase):
36+
3237
@classmethod
3338
def setUpClass(cls):
3439
testClient = super(TestScaleVm, cls).getClsTestClient()
3540
cls.apiclient = testClient.getApiClient()
3641
cls.services = testClient.getParsedTestDataConfig()
3742
cls.hypervisor = cls.testClient.getHypervisorInfo()
3843
if cls.hypervisor.lower() in ('kvm', 'hyperv', 'lxc'):
39-
raise unittest.SkipTest("ScaleVM is not supported on KVM, Hyper-V or LXC. Hence, skipping the test")
44+
raise unittest.SkipTest(
45+
"ScaleVM is not supported on KVM, Hyper-V or LXC.\
46+
Hence, skipping the test")
4047

4148
# Get Zone, Domain and templates
4249
domain = get_domain(cls.apiclient)
@@ -49,7 +56,8 @@ def setUpClass(cls):
4956
cls.services["ostype"]
5057
)
5158
if template == FAILED:
52-
assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
59+
assert False, "get_template() failed to return template\
60+
with description %s" % cls.services["ostype"]
5361

5462
# Set Zones and disk offerings ??
5563
cls.services["small"]["zoneid"] = zone.id
@@ -72,7 +80,7 @@ def setUpClass(cls):
7280
cls.services["service_offerings"]["big"]
7381
)
7482

75-
#create a virtual machine
83+
# create a virtual machine
7684
cls.virtual_machine = VirtualMachine.create(
7785
cls.apiclient,
7886
cls.services["small"],
@@ -88,7 +96,9 @@ def setUpClass(cls):
8896

8997
@classmethod
9098
def tearDownClass(cls):
91-
cls.apiclient = super(TestScaleVm, cls).getClsTestClient().getApiClient()
99+
cls.apiclient = super(
100+
TestScaleVm,
101+
cls).getClsTestClient().getApiClient()
92102
cleanup_resources(cls.apiclient, cls._cleanup)
93103
return
94104

@@ -98,29 +108,48 @@ def setUp(self):
98108
self.cleanup = []
99109

100110
def tearDown(self):
101-
#Clean up, terminate the created ISOs
111+
# Clean up, terminate the created ISOs
102112
cleanup_resources(self.apiclient, self.cleanup)
103113
return
104114

105115
@attr(hypervisor="xenserver")
106116
@attr(tags=["advanced", "basic"], required_hardware="true")
107117
def test_01_scale_vm(self):
108-
"""Test scale virtual machine
118+
"""Test scale virtual machine
109119
"""
110120
# Validate the following
111-
# Scale up the vm and see if it scales to the new svc offering and is finally in running state
112-
113-
# VirtualMachine should be updated to tell cloudstack it has PV tools
114-
# available and successfully scaled. We will only mock that behaviour
115-
# here but it is not expected in production since the VM scaling is not
121+
# Scale up the vm and see if it scales to the new svc offering and is
122+
# finally in running state
123+
124+
# VirtualMachine should be updated to tell cloudstack
125+
# it has PV tools
126+
# available and successfully scaled. We will only mock
127+
# that behaviour
128+
# here but it is not expected in production since the VM
129+
# scaling is not
116130
# guaranteed until tools are installed, vm rebooted
117-
self.virtual_machine.update(self.apiclient, isdynamicallyscalable='true')
131+
132+
# If hypervisor is Vmware, then check if
133+
# the vmware tools are installed and the process is running
134+
# Vmware tools are necessary for scale VM operation
135+
if self.hypervisor.lower() == "vmware":
136+
sshClient = self.virtual_machine.get_ssh_client()
137+
result = str(
138+
sshClient.execute("service vmware-tools status")).lower()
139+
self.debug("and result is: %s" % result)
140+
if not "running" in result:
141+
self.skipTest("Skipping scale VM operation because\
142+
VMware tools are not installed on the VM")
143+
144+
self.virtual_machine.update(
145+
self.apiclient,
146+
isdynamicallyscalable='true')
118147

119148
self.debug("Scaling VM-ID: %s to service offering: %s and state %s" % (
120149
self.virtual_machine.id,
121150
self.big_offering.id,
122151
self.virtual_machine.state
123-
))
152+
))
124153

125154
cmd = scaleVirtualMachine.scaleVirtualMachineCmd()
126155
cmd.serviceofferingid = self.big_offering.id
@@ -150,12 +179,13 @@ def test_01_scale_vm(self):
150179
"Check virtual machine ID of scaled VM"
151180
)
152181

153-
self.debug("Scaling VM-ID: %s from service offering: %s to new service offering %s and the response says %s" % (
154-
self.virtual_machine.id,
155-
self.virtual_machine.serviceofferingid,
156-
self.big_offering.id,
157-
vm_response.serviceofferingid
158-
))
182+
self.debug(
183+
"Scaling VM-ID: %s from service offering: %s to new service\
184+
offering %s and the response says %s" %
185+
(self.virtual_machine.id,
186+
self.virtual_machine.serviceofferingid,
187+
self.big_offering.id,
188+
vm_response.serviceofferingid))
159189
self.assertEqual(
160190
vm_response.serviceofferingid,
161191
self.big_offering.id,

0 commit comments

Comments
 (0)