orchestration: Add test for resource_registry environment

Adds support for passing files argument to the create/update
calls in the json client, and adds a simple test of defining
a provider resource, which is a user-defined resource type,
mapped via the "resource_registry" section of the environment
file, with the filename looked up by a key in the files map.

Change-Id: I87fd1f2b1cf2c68c22d53891d99c8cd6b6b7c777
Partial-Bug: #1317095
diff --git a/tempest/api/orchestration/base.py b/tempest/api/orchestration/base.py
index df3efdb..d4bda19 100644
--- a/tempest/api/orchestration/base.py
+++ b/tempest/api/orchestration/base.py
@@ -61,12 +61,13 @@
 
     @classmethod
     def create_stack(cls, stack_name, template_data, parameters={},
-                     environment=None):
+                     environment=None, files=None):
         resp, body = cls.client.create_stack(
             stack_name,
             template=template_data,
             parameters=parameters,
-            environment=environment)
+            environment=environment,
+            files=files)
         stack_id = resp['location'].split('/')[-1]
         stack_identifier = '%s/%s' % (stack_name, stack_id)
         cls.stacks.append(stack_identifier)
diff --git a/tempest/api/orchestration/stacks/test_environment.py b/tempest/api/orchestration/stacks/test_environment.py
index 7ed65e8..b2d347b 100644
--- a/tempest/api/orchestration/stacks/test_environment.py
+++ b/tempest/api/orchestration/stacks/test_environment.py
@@ -40,3 +40,29 @@
 
         random_value = self.get_stack_output(stack_identifier, 'random_value')
         self.assertEqual(20, len(random_value))
+
+    @test.attr(type='gate')
+    def test_environment_provider_resource(self):
+        """Test passing resource_registry defining a provider resource."""
+        stack_name = data_utils.rand_name('heat')
+        template = '''
+heat_template_version: 2013-05-23
+resources:
+  random:
+    type: My:Random::String
+outputs:
+    random_value:
+        value: {get_attr: [random, random_value]}
+'''
+        environment = {'resource_registry':
+                       {'My:Random::String': 'my_random.yaml'}}
+        files = {'my_random.yaml': self.load_template('random_string')}
+
+        stack_identifier = self.create_stack(stack_name, template,
+                                             environment=environment,
+                                             files=files)
+        self.client.wait_for_stack_status(stack_identifier, 'CREATE_COMPLETE')
+
+        # random_string.yaml specifies a length of 10
+        random_value = self.get_stack_output(stack_identifier, 'random_value')
+        self.assertEqual(10, len(random_value))
diff --git a/tempest/services/orchestration/json/orchestration_client.py b/tempest/services/orchestration/json/orchestration_client.py
index 1bbdb07..c459f28 100644
--- a/tempest/services/orchestration/json/orchestration_client.py
+++ b/tempest/services/orchestration/json/orchestration_client.py
@@ -46,7 +46,7 @@
 
     def create_stack(self, name, disable_rollback=True, parameters={},
                      timeout_mins=60, template=None, template_url=None,
-                     environment=None):
+                     environment=None, files=None):
         headers, body = self._prepare_update_create(
             name,
             disable_rollback,
@@ -54,14 +54,15 @@
             timeout_mins,
             template,
             template_url,
-            environment)
+            environment,
+            files)
         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, environment=None):
+                     template_url=None, environment=None, files=None):
         headers, body = self._prepare_update_create(
             name,
             disable_rollback,
@@ -78,14 +79,15 @@
     def _prepare_update_create(self, name, disable_rollback=True,
                                parameters={}, timeout_mins=60,
                                template=None, template_url=None,
-                               environment=None):
+                               environment=None, files=None):
         post_body = {
             "stack_name": name,
             "disable_rollback": disable_rollback,
             "parameters": parameters,
             "timeout_mins": timeout_mins,
             "template": "HeatTemplateFormatVersion: '2012-12-12'\n",
-            "environment": environment
+            "environment": environment,
+            "files": files
         }
         if template:
             post_body['template'] = template