summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWriju Bhattacharya <wb338b@att.com>2017-08-01 18:09:56 -0400
committerWriju Bhattacharya <wb338b@att.com>2017-08-23 16:55:33 -0400
commit767623d98f8d5c009d23427736d9bfea6f05e101 (patch)
treecc468c91ab85e4a9970b790928fef7c4c5ea02f8
parentc9876c965fd389373fca4de35ab432c5f3fe4e1a (diff)
Added Tempest API client methods and Tempest tests for sessions and deployments
Added tests for following scenarios: * deploy session * list all deployments * list deployments (in a specific environment) * list a specific deployment's statuses Added application_catalog_client methods for following functionality: * list all deployments * list deployments (in a specific environment) * list a specific deployment's statuses Change-Id: I0ac1b2a6216fd1794ba06ee0b26e6c2c90118526
-rw-r--r--murano_tempest_tests/services/application_catalog/application_catalog_client.py28
-rw-r--r--murano_tempest_tests/tests/api/application_catalog/test_deployments.py86
-rw-r--r--murano_tempest_tests/tests/api/application_catalog/test_sessions.py27
3 files changed, 141 insertions, 0 deletions
diff --git a/murano_tempest_tests/services/application_catalog/application_catalog_client.py b/murano_tempest_tests/services/application_catalog/application_catalog_client.py
index ef2f546..3721850 100644
--- a/murano_tempest_tests/services/application_catalog/application_catalog_client.py
+++ b/murano_tempest_tests/services/application_catalog/application_catalog_client.py
@@ -207,6 +207,34 @@ class ApplicationCatalogClient(rest_client.RestClient):
207 self.expected_success(200, resp.status) 207 self.expected_success(200, resp.status)
208 return self._parse_resp(body) 208 return self._parse_resp(body)
209 209
210# ----------------------------Deployment methods-------------------------------
211
212 def list_deployments(self, environment_id):
213 uri = 'v1/environments/{0}/deployments'.format(
214 environment_id)
215 body = None
216
217 resp, body = self.get(uri, body)
218 self.expected_success(200, resp.status)
219 return self._parse_resp(body)
220
221 def list_deployment_statuses(self, environment_id, deployment_id):
222 uri = 'v1/environments/{0}/deployments/{1}'.format(
223 environment_id, deployment_id)
224 body = None
225
226 resp, body = self.get(uri, body)
227 self.expected_success(200, resp.status)
228 return self._parse_resp(body)
229
230 def list_all_deployments(self):
231 uri = 'v1/deployments'
232 body = None
233
234 resp, body = self.get(uri, body)
235 self.expected_success(200, resp.status)
236 return self._parse_resp(body)
237
210# -----------------------------Service methods--------------------------------- 238# -----------------------------Service methods---------------------------------
211 def create_service(self, environment_id, session_id, post_body): 239 def create_service(self, environment_id, session_id, post_body):
212 headers = self.get_headers() 240 headers = self.get_headers()
diff --git a/murano_tempest_tests/tests/api/application_catalog/test_deployments.py b/murano_tempest_tests/tests/api/application_catalog/test_deployments.py
new file mode 100644
index 0000000..4103e8e
--- /dev/null
+++ b/murano_tempest_tests/tests/api/application_catalog/test_deployments.py
@@ -0,0 +1,86 @@
1# Copyright (c) 2017 AT&T Corporation.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15from tempest.lib import decorators
16
17from murano_tempest_tests.tests.api.application_catalog import base
18from murano_tempest_tests import utils
19
20
21class TestDeployments(base.BaseApplicationCatalogTest):
22
23 def _create_and_deploy_env_session(self):
24 name = utils.generate_name('_create_and_deploy_env_session')
25 environment = self.application_catalog_client.create_environment(
26 name)
27 self.addCleanup(self.application_catalog_client.delete_environment,
28 environment['id'])
29 session = self.application_catalog_client.create_session(
30 environment['id'])
31 self.addCleanup(self.application_catalog_client.delete_session,
32 environment['id'], session['id'])
33 self.application_catalog_client.deploy_session(environment['id'],
34 session['id'])
35 utils.wait_for_environment_deploy(self.application_catalog_client,
36 environment['id'])
37 return environment
38
39 @decorators.idempotent_id('ea4f6f21-bd97-4b58-af93-6fe5417543f9')
40 def test_list_all_deployments(self):
41 # Given two environments with deployments
42 environment1 = self._create_and_deploy_env_session()
43 environment2 = self._create_and_deploy_env_session()
44
45 # When list_all_deployments is called
46 deployments = self.application_catalog_client.list_all_deployments()
47
48 # Then both environment's deployments are returned
49 self.assertEqual(2, len(deployments))
50 environment_ids = [d['environment_id'] for d in deployments]
51 self.assertIn(environment1['id'], environment_ids)
52 self.assertIn(environment2['id'], environment_ids)
53
54 @decorators.idempotent_id('d76706f6-9281-4fdc-9758-57da825311b1')
55 def test_list_deployments(self):
56 # Given two environments with deployments
57 environment1 = self._create_and_deploy_env_session()
58 self._create_and_deploy_env_session()
59
60 # When list_deployments is called for first environment
61 deployments = self.application_catalog_client.list_deployments(
62 environment1['id'])
63
64 # Then only the first environment's deployment is returned
65 self.assertEqual(1, len(deployments))
66 first_deployment = deployments[0]
67 self.assertEqual(environment1['id'],
68 first_deployment['environment_id'])
69
70 @decorators.idempotent_id('d6fbba34-92a9-49b3-9c49-e4b7a65eb6e8')
71 def test_list_deployment_statuses(self):
72 # Given an environment with a deployment
73 environment = self._create_and_deploy_env_session()
74 deployment = self.application_catalog_client.list_deployments(
75 environment['id'])[0]
76
77 # When list_deployment_statuses is called
78 statuses = self.application_catalog_client.list_deployment_statuses(
79 environment['id'], deployment['id'])
80
81 # Then the correct statuses for the deployment are returned
82 status_deployment_ids = set([s['task_id'] for s in statuses])
83 self.assertEqual([deployment['id']], list(status_deployment_ids))
84 status_texts = [s['text'] for s in statuses]
85 self.assertEqual(['Action deploy is scheduled', 'Deployment finished'],
86 sorted(status_texts))
diff --git a/murano_tempest_tests/tests/api/application_catalog/test_sessions.py b/murano_tempest_tests/tests/api/application_catalog/test_sessions.py
index 6eb670d..2159362 100644
--- a/murano_tempest_tests/tests/api/application_catalog/test_sessions.py
+++ b/murano_tempest_tests/tests/api/application_catalog/test_sessions.py
@@ -64,3 +64,30 @@ class TestSessions(base.BaseApplicationCatalogTest):
64 session_from_resp.pop('updated', None) 64 session_from_resp.pop('updated', None)
65 session_from_resp.pop('created', None) 65 session_from_resp.pop('created', None)
66 self.assertEqual(session, session_from_resp) 66 self.assertEqual(session, session_from_resp)
67
68 @decorators.idempotent_id('30a63368-e75a-4e00-ac91-c91b17e54a62')
69 def test_deploy_session(self):
70 # Given an environment with a session
71 name = utils.generate_name('_create_and_deploy_env_session')
72 environment = self.application_catalog_client.create_environment(
73 name)
74 self.addCleanup(self.application_catalog_client.delete_environment,
75 environment['id'])
76 session = self.application_catalog_client.create_session(
77 environment['id'])
78 self.addCleanup(self.application_catalog_client.delete_session,
79 environment['id'], session['id'])
80
81 # When deploy session is called
82 self.application_catalog_client.deploy_session(environment['id'],
83 session['id'])
84 utils.wait_for_environment_deploy(self.application_catalog_client,
85 environment['id'])
86
87 # Then there is only one deployment and it is in a success state
88 fetched_deployments = self.application_catalog_client.list_deployments(
89 environment['id'])
90 self.assertEqual(1, len(fetched_deployments))
91 first_deployment = fetched_deployments[0]
92 self.assertEqual(environment['id'], first_deployment['environment_id'])
93 self.assertEqual('success', first_deployment['state'])