Add test for resources deallocation
- Add test for resources deallocation after application removed from instance Change-Id: I2ea25b4fd8fb180624259fe4078ac5ddaa4c9bf3 Related-Bug: #1499563
This commit is contained in:
parent
e383b12b6c
commit
c997fcd6a2
@ -209,16 +209,26 @@ class DeployTestMixin(zip_utils.ZipUtilsMixin):
|
||||
return service
|
||||
|
||||
@classmethod
|
||||
def get_service_as_json(cls, environment, service_name):
|
||||
"""Get a service with specific name from environment in JSON format.
|
||||
def services_list(cls, environment):
|
||||
"""Get a list of environment services.
|
||||
|
||||
:param environment: Murano environment
|
||||
:param service_name: Service name
|
||||
:return:
|
||||
:return: List of <Service> objects
|
||||
"""
|
||||
for service in cls.murano_client().services.list(environment.id):
|
||||
return cls.murano_client().services.list(environment.id)
|
||||
|
||||
@classmethod
|
||||
def get_service(cls, environment, service_name, to_dict=True):
|
||||
"""Get a service with specific name from environment.
|
||||
|
||||
:param to_dict: Convert service to JSON or not to convert
|
||||
:param environment: Murano environment
|
||||
:param service_name: Service name
|
||||
:return: JSON or <Service> object
|
||||
"""
|
||||
for service in cls.services_list(environment):
|
||||
if service.name == service_name:
|
||||
return cls._convert_service(service)
|
||||
return cls._convert_service(service) if to_dict else service
|
||||
|
||||
@classmethod
|
||||
def _convert_service(cls, service):
|
||||
@ -231,6 +241,35 @@ class DeployTestMixin(zip_utils.ZipUtilsMixin):
|
||||
component = json.dumps(component)
|
||||
return yaml.load(component)
|
||||
|
||||
@classmethod
|
||||
def get_service_id(cls, service):
|
||||
"""Gets id on <Service> object.
|
||||
|
||||
:param service: <Service> object
|
||||
:return: ID of the Service
|
||||
"""
|
||||
serv = cls._convert_service(service)
|
||||
serv_id = serv['?']['id']
|
||||
return serv_id
|
||||
|
||||
@classmethod
|
||||
def delete_service(cls, environment, session, service):
|
||||
"""This function removes a specific service from environment.
|
||||
|
||||
:param environment: Murano environment
|
||||
:param session: Session fir urano environment
|
||||
:param service: <Service> object
|
||||
:return: Updated murano environment
|
||||
"""
|
||||
cls.murano_client().services.delete(
|
||||
environment.id, path='/{0}'.format(cls.get_service_id(service)),
|
||||
session_id=session.id)
|
||||
LOG.debug('Service with name {0} from environment {1} successfully '
|
||||
'removed'.format(environment.name, service.name))
|
||||
updated_env = cls.get_environment(environment)
|
||||
return updated_env
|
||||
|
||||
|
||||
# -----------------------------Packages methods--------------------------------
|
||||
|
||||
@classmethod
|
||||
@ -472,3 +511,7 @@ class DeployTestMixin(zip_utils.ZipUtilsMixin):
|
||||
for stack in cls.heat_client().stacks.list():
|
||||
if environment_id in stack.description:
|
||||
return stack
|
||||
|
||||
@classmethod
|
||||
def get_stack_template(cls, stack):
|
||||
return cls.heat_client().stacks.template(stack.stack_name)
|
||||
|
@ -206,6 +206,25 @@ class MuranoTestsCore(testtools.TestCase, testtools.testcase.WithAttributes,
|
||||
}
|
||||
}
|
||||
|
||||
def get_test_app(self):
|
||||
return {
|
||||
"instance": {
|
||||
"flavor": self.flavor,
|
||||
"image": self.linux,
|
||||
"assignFloatingIp": True,
|
||||
"?": {
|
||||
"type": "io.murano.resources.LinuxMuranoInstance",
|
||||
"id": str(uuid.uuid4())
|
||||
},
|
||||
"name": self.rand_name('mrntest')
|
||||
},
|
||||
"name": self.rand_name('dummy'),
|
||||
"?": {
|
||||
"type": "io.murano.apps.test.UpdateExecutor",
|
||||
"id": str(uuid.uuid4())
|
||||
}
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def upload_app(cls, app_dir, name, tags):
|
||||
"""Zip and upload application to Murano
|
||||
|
@ -12,8 +12,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
from nose.plugins.attrib import attr as tag
|
||||
|
||||
import murano.tests.functional.engine.manager as core
|
||||
@ -41,27 +39,37 @@ class MuranoDeploymentTest(core.MuranoTestsCore):
|
||||
|
||||
@tag('gate', 'all', 'coverage')
|
||||
def test_app_deployment(self):
|
||||
post_body = {
|
||||
"instance": {
|
||||
"flavor": self.flavor,
|
||||
"image": self.linux,
|
||||
"assignFloatingIp": True,
|
||||
"?": {
|
||||
"type": "io.murano.resources.LinuxMuranoInstance",
|
||||
"id": str(uuid.uuid4())
|
||||
},
|
||||
"name": "testMurano"
|
||||
},
|
||||
"name": "teMurano",
|
||||
"?": {
|
||||
"type": "io.murano.apps.test.UpdateExecutor",
|
||||
"id": str(uuid.uuid4())
|
||||
}
|
||||
}
|
||||
|
||||
post_body = self.get_test_app()
|
||||
environment_name = self.rand_name('dummyMurano')
|
||||
environment = self.create_environment(name=environment_name)
|
||||
session = self.create_session(environment)
|
||||
self.add_service(environment, post_body, session)
|
||||
self.deploy_environment(environment, session)
|
||||
self.wait_for_environment_deploy(environment)
|
||||
|
||||
@tag('gate', 'all', 'coverage')
|
||||
def test_resources_deallocation(self):
|
||||
app_1 = self.get_test_app()
|
||||
app_2 = self.get_test_app()
|
||||
environment_name = self.rand_name('dummyMurano')
|
||||
environment = self.create_environment(name=environment_name)
|
||||
session = self.create_session(environment)
|
||||
self.add_service(environment, app_1, session)
|
||||
self.add_service(environment, app_2, session)
|
||||
self.deploy_environment(environment, session)
|
||||
|
||||
environment = self.get_environment(environment)
|
||||
app_for_remove = self.get_service(environment, app_1['name'],
|
||||
to_dict=False)
|
||||
session = self.create_session(environment)
|
||||
environment = self.delete_service(environment, session, app_for_remove)
|
||||
self.deploy_environment(environment, session)
|
||||
|
||||
instance_name = app_1['instance']['name']
|
||||
stack = self._get_stack(environment.id)
|
||||
template = self.get_stack_template(stack)
|
||||
ip_addresses = '{0}-assigned-ip'.format(instance_name)
|
||||
floating_ip = '{0}-FloatingIPaddress'.format(instance_name)
|
||||
|
||||
self.assertNotIn(ip_addresses, template['outputs'])
|
||||
self.assertNotIn(floating_ip, template['outputs'])
|
||||
self.assertNotIn(instance_name, template['resources'])
|
||||
|
Loading…
Reference in New Issue
Block a user