Merge "Proposing a change to remove user validation tests"
diff --git a/tempest/api/orchestration/base.py b/tempest/api/orchestration/base.py
index 0e50ac3..6d6000a 100644
--- a/tempest/api/orchestration/base.py
+++ b/tempest/api/orchestration/base.py
@@ -62,15 +62,15 @@
cls.config.identity.uri
)
- def create_stack(self, stack_name, template_data, parameters={}):
- resp, body = self.client.create_stack(
+ @classmethod
+ def create_stack(cls, stack_name, template_data, parameters={}):
+ resp, body = cls.client.create_stack(
stack_name,
template=template_data,
parameters=parameters)
- self.assertEqual('201', resp['status'])
stack_id = resp['location'].split('/')[-1]
stack_identifier = '%s/%s' % (stack_name, stack_id)
- self.stacks.append(stack_identifier)
+ cls.stacks.append(stack_identifier)
return stack_identifier
@classmethod
@@ -88,11 +88,11 @@
except Exception:
pass
- def _create_keypair(self, namestart='keypair-heat-'):
+ @classmethod
+ def _create_keypair(cls, namestart='keypair-heat-'):
kp_name = rand_name(namestart)
- resp, body = self.keypairs_client.create_keypair(kp_name)
- self.assertEqual(body['name'], kp_name)
- self.keypairs.append(kp_name)
+ resp, body = cls.keypairs_client.create_keypair(kp_name)
+ cls.keypairs.append(kp_name)
return body
@classmethod
diff --git a/tempest/api/orchestration/stacks/test_instance_cfn_init.py b/tempest/api/orchestration/stacks/test_instance_cfn_init.py
index e3b8162..add8588 100644
--- a/tempest/api/orchestration/stacks/test_instance_cfn_init.py
+++ b/tempest/api/orchestration/stacks/test_instance_cfn_init.py
@@ -119,23 +119,21 @@
raise cls.skipException("No image available to test")
cls.client = cls.orchestration_client
- def setUp(self):
- super(InstanceCfnInitTestJSON, self).setUp()
stack_name = rand_name('heat')
- if self.orchestration_cfg.keypair_name:
- keypair_name = self.orchestration_cfg.keypair_name
+ if cls.orchestration_cfg.keypair_name:
+ keypair_name = cls.orchestration_cfg.keypair_name
else:
- self.keypair = self._create_keypair()
- keypair_name = self.keypair['name']
+ cls.keypair = cls._create_keypair()
+ keypair_name = cls.keypair['name']
# create the stack
- self.stack_identifier = self.create_stack(
+ cls.stack_identifier = cls.create_stack(
stack_name,
- self.template,
+ cls.template,
parameters={
'KeyName': keypair_name,
- 'InstanceType': self.orchestration_cfg.instance_type,
- 'ImageId': self.orchestration_cfg.image_ref
+ 'InstanceType': cls.orchestration_cfg.instance_type,
+ 'ImageId': cls.orchestration_cfg.image_ref
})
@attr(type='gate')
diff --git a/tempest/config.py b/tempest/config.py
index 8795b33..f6fd1d9 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -15,9 +15,12 @@
# License for the specific language governing permissions and limitations
# under the License.
+from __future__ import print_function
+
import os
import sys
+
from oslo.config import cfg
from tempest.common import log as logging
@@ -559,7 +562,7 @@
if not os.path.exists(path):
msg = "Config file %(path)s not found" % locals()
- print >> sys.stderr, RuntimeError(msg)
+ print(RuntimeError(msg), file=sys.stderr)
else:
config_files.append(path)
diff --git a/tempest/services/orchestration/json/orchestration_client.py b/tempest/services/orchestration/json/orchestration_client.py
index 6b0e7e3..22f3f26 100644
--- a/tempest/services/orchestration/json/orchestration_client.py
+++ b/tempest/services/orchestration/json/orchestration_client.py
@@ -46,6 +46,35 @@
def create_stack(self, name, disable_rollback=True, parameters={},
timeout_mins=60, template=None, template_url=None):
+ headers, body = self._prepare_update_create(
+ name,
+ disable_rollback,
+ parameters,
+ timeout_mins,
+ template,
+ template_url)
+ uri = 'stacks'
+ resp, body = self.post(uri, headers=headers, body=body)
+ return resp, body
+
+ def update_stack(self, stack_identifier, name, disable_rollback=True,
+ parameters={}, timeout_mins=60, template=None,
+ template_url=None):
+ headers, body = self._prepare_update_create(
+ name,
+ disable_rollback,
+ parameters,
+ timeout_mins,
+ template,
+ template_url)
+
+ uri = "stacks/%s" % stack_identifier
+ resp, body = self.put(uri, headers=headers, body=body)
+ return resp, body
+
+ def _prepare_update_create(self, name, disable_rollback=True,
+ parameters={}, timeout_mins=60,
+ template=None, template_url=None):
post_body = {
"stack_name": name,
"disable_rollback": disable_rollback,
@@ -58,9 +87,13 @@
if template_url:
post_body['template_url'] = template_url
body = json.dumps(post_body)
- uri = 'stacks'
- resp, body = self.post(uri, headers=self.headers, body=body)
- return resp, body
+
+ # Password must be provided on stack create so that heat
+ # can perform future operations on behalf of the user
+ headers = dict(self.headers)
+ headers['X-Auth-Key'] = self.password
+ headers['X-Auth-User'] = self.user
+ return headers, body
def get_stack(self, stack_identifier):
"""Returns the details of a single stack."""