Merge "Pass SSL options to swiftclient explicitly" into mcp/pike
diff --git a/heat_tempest_plugin/common/test.py b/heat_tempest_plugin/common/test.py
index dbd2e27..f75385f 100644
--- a/heat_tempest_plugin/common/test.py
+++ b/heat_tempest_plugin/common/test.py
@@ -34,6 +34,7 @@
 
 LOG = logging.getLogger(__name__)
 _LOG_FORMAT = "%(levelname)8s [%(name)s] %(message)s"
+_resource_types = None
 
 
 def call_until_true(duration, sleep_for, func, *args, **kwargs):
@@ -86,6 +87,29 @@
     return skipper(test_method)
 
 
+def requires_resource_type(resource_type):
+    '''Decorator for tests requiring a resource type.
+
+    The decorated test will be skipped when the resource type is not available.
+    '''
+    def decorator(test_method):
+        conf = getattr(config.CONF, 'heat_plugin', None)
+        if not conf or conf.auth_url is None:
+            return test_method
+
+        global _resource_types
+        if not _resource_types:
+            manager = clients.ClientManager(conf)
+            obj_rtypes = manager.orchestration_client.resource_types.list()
+            _resource_types = list(t.resource_type for t in obj_rtypes)
+        rtype_available = resource_type and resource_type in _resource_types
+        skipper = testtools.skipUnless(
+            rtype_available,
+            "%s resource type not available, skipping test." % resource_type)
+        return skipper(test_method)
+    return decorator
+
+
 class HeatIntegrationTest(testtools.testcase.WithAttributes,
                           testscenarios.WithScenarios,
                           testtools.TestCase):
diff --git a/heat_tempest_plugin/config.py b/heat_tempest_plugin/config.py
index ced87e3..5bf5161 100644
--- a/heat_tempest_plugin/config.py
+++ b/heat_tempest_plugin/config.py
@@ -156,6 +156,11 @@
     cfg.StrOpt('hidden_stack_tag',
                default='data-processing-cluster',
                help="Tag to be considered as hidden for stack tags tests"),
+    cfg.BoolOpt('vm_to_heat_api_insecure',
+                default=False,
+                help="Set this to True if VM images used for tests "
+                     "can not verify a (self-signed) SSL certificate "
+                     "of public Heat endpoint."),
 ]
 
 
diff --git a/heat_tempest_plugin/tests/api/gabbits/stacks.yaml b/heat_tempest_plugin/tests/api/gabbits/stacks.yaml
index c230984..f66aa0d 100644
--- a/heat_tempest_plugin/tests/api/gabbits/stacks.yaml
+++ b/heat_tempest_plugin/tests/api/gabbits/stacks.yaml
@@ -12,7 +12,7 @@
   response_headers:
     content-type: application/json
 
-- name: create empty stack
+- name: create empty stack smoke
   POST: /stacks
   request_headers:
     content-type: application/json
@@ -30,7 +30,7 @@
     location: //stacks/$ENVIRON['PREFIX']-empty/[a-f0-9-]+/
 
 
-- name: poll for empty CREATE_COMPLETE
+- name: poll for empty CREATE_COMPLETE smoke
   GET: $LOCATION
   redirects: True
   poll:
@@ -39,17 +39,17 @@
   response_json_paths:
     $.stack.stack_status: CREATE_COMPLETE
 
-- name: show empty stack
+- name: show empty stack smoke
   GET: $LAST_URL
   redirects: True
   status: 200
 
-- name: delete empty stack
+- name: delete empty stack smoke
   DELETE: $LAST_URL
   redirects: True
   status: 204
 
-- name: create stack
+- name: create stack smoke
   POST: /stacks
   request_headers:
     content-type: application/json
@@ -76,7 +76,7 @@
   response_headers:
     location: //stacks/$ENVIRON['PREFIX']-stack/[a-f0-9-]+/
 
-- name: poll for stack CREATE_COMPLETE
+- name: poll for stack CREATE_COMPLETE smoke
   GET: $LOCATION
   redirects: True
   poll:
@@ -85,12 +85,12 @@
   response_json_paths:
     $.stack.stack_status: CREATE_COMPLETE
 
-- name: show stack
+- name: show stack smoke
   GET: $LAST_URL
   redirects: True
   status: 200
 
-- name: update stack
+- name: update stack smoke
   PUT: $LAST_URL
   request_headers:
     content-type: application/json
@@ -117,7 +117,7 @@
 
   status: 202
 
-- name: poll for stack UPDATE_COMPLETE
+- name: poll for stack UPDATE_COMPLETE smoke
   GET: $LAST_URL
   redirects: True
   poll:
@@ -126,7 +126,7 @@
   response_json_paths:
     $.stack.stack_status: UPDATE_COMPLETE
 
-- name: patch update stack
+- name: patch update stack smoke
   PATCH: $LAST_URL
   request_headers:
     content-type: application/json
@@ -135,7 +135,7 @@
 
   status: 202
 
-- name: poll for stack patch UPDATE_COMPLETE
+- name: poll for stack patch UPDATE_COMPLETE smoke
   GET: $LAST_URL
   redirects: True
   poll:
@@ -143,23 +143,23 @@
     delay: 1.0
   response_json_paths:
     $.stack.stack_status: UPDATE_COMPLETE
-    $.stack.updated_time: /^(?!$HISTORY['poll for stack UPDATE_COMPLETE'].$RESPONSE['$.stack.updated_time'])/
+    $.stack.updated_time: /^(?!$HISTORY['poll for stack UPDATE_COMPLETE smoke'].$RESPONSE['$.stack.updated_time'])/
 
-- name: list stack outputs
+- name: list stack outputs smoke
   GET: $LAST_URL/outputs
   redirects: True
   status: 200
   response_json_paths:
     $.outputs[0].output_key: output_value
 
-- name: get stack output
+- name: get stack output smoke
   GET: $LAST_URL/output_value
   redirects: True
   status: 200
   response_json_paths:
     $.output.output_value: new_patched_value
 
-- name: delete stack
+- name: delete stack smoke
   DELETE: /stacks/$ENVIRON['PREFIX']-stack
   redirects: True
   status: 204
diff --git a/heat_tempest_plugin/tests/functional/test_create_update_neutron_trunk.py b/heat_tempest_plugin/tests/functional/test_create_update_neutron_trunk.py
index 41f6505..4be8d8c 100644
--- a/heat_tempest_plugin/tests/functional/test_create_update_neutron_trunk.py
+++ b/heat_tempest_plugin/tests/functional/test_create_update_neutron_trunk.py
@@ -17,6 +17,7 @@
 
 from tempest.lib import decorators
 
+from heat_tempest_plugin.common import test
 from heat_tempest_plugin.tests.functional import functional_base
 from tempest.common import utils
 
@@ -72,6 +73,7 @@
 '''
 
 
+@test.requires_resource_type('OS::Neutron::Trunk')
 class UpdateTrunkTest(functional_base.FunctionalTestsBase):
 
     @staticmethod
diff --git a/heat_tempest_plugin/tests/functional/test_os_wait_condition.py b/heat_tempest_plugin/tests/functional/test_os_wait_condition.py
index dc78341..e3e4b53 100644
--- a/heat_tempest_plugin/tests/functional/test_os_wait_condition.py
+++ b/heat_tempest_plugin/tests/functional/test_os_wait_condition.py
@@ -29,6 +29,9 @@
   timeout:
     type: number
     default: 60
+  wc_extra_args:
+    type: string
+    default: ""
 resources:
   instance1:
     type: OS::Nova::Server
@@ -57,11 +60,11 @@
             wc_notify --data-binary ''{"status": "SUCCESS", "reason":
             "signal4", "data": "data4"}''
 
-            # check signals with the same number
+            # check signals with the same ID
 
-            wc_notify --data-binary ''{"status": "SUCCESS", "id": "5"}''
+            wc_notify --data-binary ''{"status": "SUCCESS", "id": "test5"}''
 
-            wc_notify --data-binary ''{"status": "SUCCESS", "id": "5"}''
+            wc_notify --data-binary ''{"status": "SUCCESS", "id": "test5"}''
 
             # loop for 20 signals without reasons and data
 
@@ -72,7 +75,10 @@
             '
           params:
             wc_notify:
-              get_attr: [wait_handle, curl_cli]
+              list_join:
+                - " "
+                - [ get_attr: [ wait_handle, curl_cli],
+                    get_param: wc_extra_args ]
 
   wait_condition:
     type: OS::Heat::WaitCondition
@@ -107,4 +113,6 @@
                   'image': self.conf.minimal_image_ref,
                   'network': self.conf.fixed_network_name,
                   'timeout': 120}
+        if self.conf.vm_to_heat_api_insecure:
+            params['wc_extra_args'] = '--insecure'
         self.stack_create(template=self.template, parameters=params)
diff --git a/heat_tempest_plugin/tests/scenario/templates/app_server_lbv2_neutron.yaml b/heat_tempest_plugin/tests/scenario/templates/app_server_lbv2_neutron.yaml
index f750a98..ca4117b 100644
--- a/heat_tempest_plugin/tests/scenario/templates/app_server_lbv2_neutron.yaml
+++ b/heat_tempest_plugin/tests/scenario/templates/app_server_lbv2_neutron.yaml
@@ -29,13 +29,20 @@
   subnet:
     type: string
 
+  wc_extra_args:
+    type: string
+    default: ""
+
 resources:
 
   config:
     type: OS::Test::WebAppConfig
     properties:
       app_port: { get_param: app_port }
-      wc_curl_cli: { get_attr: [ handle, curl_cli ] }
+      wc_curl_cli:
+        list_join:
+          - " "
+          - [ get_attr: [ handle, curl_cli ], get_param: wc_extra_args ]
 
   server:
     type: OS::Nova::Server
diff --git a/heat_tempest_plugin/tests/scenario/templates/app_server_neutron.yaml b/heat_tempest_plugin/tests/scenario/templates/app_server_neutron.yaml
index 9cbf82a..c098ff9 100644
--- a/heat_tempest_plugin/tests/scenario/templates/app_server_neutron.yaml
+++ b/heat_tempest_plugin/tests/scenario/templates/app_server_neutron.yaml
@@ -26,13 +26,20 @@
   timeout:
     type: number
 
+  wc_extra_args:
+    type: string
+    default: ""
+
 resources:
 
   config:
     type: OS::Test::WebAppConfig
     properties:
       app_port: { get_param: app_port }
-      wc_curl_cli: { get_attr: [ handle, curl_cli ] }
+      wc_curl_cli:
+        list_join:
+          - " "
+          - [ get_attr: [ handle, curl_cli ], get_param: wc_extra_args ]
 
   server:
     type: OS::Nova::Server
diff --git a/heat_tempest_plugin/tests/scenario/templates/test_autoscaling_lb_neutron.yaml b/heat_tempest_plugin/tests/scenario/templates/test_autoscaling_lb_neutron.yaml
index d47e787..033581a 100644
--- a/heat_tempest_plugin/tests/scenario/templates/test_autoscaling_lb_neutron.yaml
+++ b/heat_tempest_plugin/tests/scenario/templates/test_autoscaling_lb_neutron.yaml
@@ -27,6 +27,9 @@
   timeout:
     type: number
     default: 600
+  wc_extra_args:
+    type: string
+    default: ""
 
 resources:
 
@@ -55,6 +58,7 @@
           app_port: { get_param: app_port }
           pool_id: { get_resource: pool }
           timeout: { get_param: timeout }
+          wc_extra_args: { get_param: wc_extra_args }
 
   scale_up:
     type: OS::Heat::ScalingPolicy
diff --git a/heat_tempest_plugin/tests/scenario/templates/test_autoscaling_lbv2_neutron.yaml b/heat_tempest_plugin/tests/scenario/templates/test_autoscaling_lbv2_neutron.yaml
index 4702366..a26f7f7 100644
--- a/heat_tempest_plugin/tests/scenario/templates/test_autoscaling_lbv2_neutron.yaml
+++ b/heat_tempest_plugin/tests/scenario/templates/test_autoscaling_lbv2_neutron.yaml
@@ -27,6 +27,9 @@
   timeout:
     type: number
     default: 600
+  wc_extra_args:
+    type: string
+    default: ""
 
 resources:
 
@@ -56,6 +59,7 @@
           pool: { get_resource: pool }
           subnet: { get_param: subnet }
           timeout: { get_param: timeout }
+          wc_extra_args: { get_param: wc_extra_args }
 
   scale_up:
     type: OS::Heat::ScalingPolicy
diff --git a/heat_tempest_plugin/tests/scenario/templates/test_server_cfn_init.yaml b/heat_tempest_plugin/tests/scenario/templates/test_server_cfn_init.yaml
index 9f94717..0095146 100644
--- a/heat_tempest_plugin/tests/scenario/templates/test_server_cfn_init.yaml
+++ b/heat_tempest_plugin/tests/scenario/templates/test_server_cfn_init.yaml
@@ -13,6 +13,9 @@
     Type: String
   timeout:
     Type: Number
+  SignalExtraArgs:
+    Type: String
+    Default: ""
 Resources:
   CfnUser:
     Type: AWS::IAM::User
@@ -69,10 +72,11 @@
       UserData:
         Fn::Replace:
         - WaitHandle: {Ref: WaitHandle}
+          SignalExtraArgs: {Ref: SignalExtraArgs}
         - |
           #!/bin/bash -v
           /opt/aws/bin/cfn-init
-          /opt/aws/bin/cfn-signal -e 0 --data "`cat /tmp/smoke-status`" \
+          /opt/aws/bin/cfn-signal SignalExtraArgs -e 0 --data "`cat /tmp/smoke-status`" \
               --id smoke_status "WaitHandle"
   WaitHandle:
     Type: AWS::CloudFormation::WaitConditionHandle
diff --git a/heat_tempest_plugin/tests/scenario/templates/test_server_signal.yaml b/heat_tempest_plugin/tests/scenario/templates/test_server_signal.yaml
index 4466a5e..4556a2f 100644
--- a/heat_tempest_plugin/tests/scenario/templates/test_server_signal.yaml
+++ b/heat_tempest_plugin/tests/scenario/templates/test_server_signal.yaml
@@ -26,6 +26,9 @@
   user_data_format:
     type: string
     default: RAW
+  wc_extra_args:
+    type: string
+    default: ""
 resources:
   sg:
     type: OS::Neutron::SecurityGroup
@@ -86,7 +89,10 @@
             #!/bin/sh
             wc_notify --data-binary '{"status": "SUCCESS", "data": "test complete"}'
           params:
-            wc_notify: { get_attr: ['wait_handle', 'curl_cli'] }
+            wc_notify:
+              list_join:
+                - " "
+                - [ get_attr: ['wait_handle', 'curl_cli'], get_param: wc_extra_args ]
 
   server_floating_ip_assoc:
     type: OS::Neutron::FloatingIPAssociation
diff --git a/heat_tempest_plugin/tests/scenario/templates/test_volumes_create_from_backup.yaml b/heat_tempest_plugin/tests/scenario/templates/test_volumes_create_from_backup.yaml
index ab1edf8..bc288f7 100644
--- a/heat_tempest_plugin/tests/scenario/templates/test_volumes_create_from_backup.yaml
+++ b/heat_tempest_plugin/tests/scenario/templates/test_volumes_create_from_backup.yaml
@@ -39,6 +39,11 @@
     description: Description of volume
     default: A volume description
 
+  wc_extra_args:
+    type: string
+    description: extra options to add to CURL command
+    default: ""
+
 resources:
   volume:
     type: OS::Cinder::Volume
@@ -77,14 +82,15 @@
             then
               mount /dev/dev_name /mnt
               TESTDATA=$(cat /mnt/testfile)
-              curl -X PUT -H 'Content-Type:' --data-binary '{"Status": "SUCCESS", "Reason": "Test Complete", "Data": "Volume Data:'$TESTDATA'", "UniqueId": "instance1"}' "wc_url"
+              curl wc_extra_args -X PUT -H 'Content-Type:' --data-binary '{"Status": "SUCCESS", "Reason": "Test Complete", "Data": "Volume Data:'$TESTDATA'", "UniqueId": "instance1"}' "wc_url"
             else
-              curl -X PUT -H 'Content-Type:' --data-binary '{"Status": "FAILURE", "Reason": "Test Failed", "Data": "Expected device dev_name not found.", "UniqueId": "instance1"}' "wc_url"
+              curl wc_extra_args -X PUT -H 'Content-Type:' --data-binary '{"Status": "FAILURE", "Reason": "Test Failed", "Data": "Expected device dev_name not found.", "UniqueId": "instance1"}' "wc_url"
             fi
           params:
             wc_url: { get_resource: wait_handle }
             dev_name: { get_param: dev_name }
             rescan_timeout: { get_param: rescan_timeout }
+            wc_extra_args: { get_param: wc_extra_args }
 
   wait_handle:
     type: OS::Heat::UpdateWaitConditionHandle
diff --git a/heat_tempest_plugin/tests/scenario/templates/test_volumes_delete_snapshot.yaml b/heat_tempest_plugin/tests/scenario/templates/test_volumes_delete_snapshot.yaml
index 3893b52..b383220 100644
--- a/heat_tempest_plugin/tests/scenario/templates/test_volumes_delete_snapshot.yaml
+++ b/heat_tempest_plugin/tests/scenario/templates/test_volumes_delete_snapshot.yaml
@@ -45,6 +45,11 @@
     description: Size of volume
     default: 1
 
+  wc_extra_args:
+    type: string
+    description: extra options to add to CURL command
+    default: ""
+
 resources:
   volume:
     deletion_policy: 'Snapshot'
@@ -86,15 +91,16 @@
               mount /dev/dev_name /mnt
               echo "test_string" > /mnt/testfile
               umount /mnt
-              curl -X PUT -H 'Content-Type:' --data-binary '{"Status": "SUCCESS", "Reason": "Test Complete", "Data": "Completed volume configuration.", "UniqueId": "instance1"}' "wc_url"
+              curl wc_extra_args -X PUT -H 'Content-Type:' --data-binary '{"Status": "SUCCESS", "Reason": "Test Complete", "Data": "Completed volume configuration.", "UniqueId": "instance1"}' "wc_url"
             else
-              curl -X PUT -H 'Content-Type:' --data-binary '{"Status": "FAILURE", "Reason": "Test Failed", "Data": "Expected device dev_name not found.", "UniqueId": "instance1"}' "wc_url"
+              curl wc_extra_args -X PUT -H 'Content-Type:' --data-binary '{"Status": "FAILURE", "Reason": "Test Failed", "Data": "Expected device dev_name not found.", "UniqueId": "instance1"}' "wc_url"
             fi
           params:
             wc_url: { get_resource: wait_handle }
             dev_name: { get_param: dev_name }
             rescan_timeout: { get_param: rescan_timeout }
             test_string: { get_param: test_string }
+            wc_extra_args: { get_param: wc_extra_args }
 
   wait_handle:
     type: OS::Heat::UpdateWaitConditionHandle
diff --git a/heat_tempest_plugin/tests/scenario/test_autoscaling_lb.py b/heat_tempest_plugin/tests/scenario/test_autoscaling_lb.py
index b8ffa1f..e581838 100644
--- a/heat_tempest_plugin/tests/scenario/test_autoscaling_lb.py
+++ b/heat_tempest_plugin/tests/scenario/test_autoscaling_lb.py
@@ -74,6 +74,8 @@
             'lb_port': 80,
             'timeout': 600
         }
+        if self.conf.vm_to_heat_api_insecure:
+            parameters['wc_extra_args'] = '--insecure'
 
         app_server_template = self._load_template(
             __file__, self.app_server_template_name, self.sub_dir
diff --git a/heat_tempest_plugin/tests/scenario/test_autoscaling_lbv2.py b/heat_tempest_plugin/tests/scenario/test_autoscaling_lbv2.py
index 52957f5..675ec5d 100644
--- a/heat_tempest_plugin/tests/scenario/test_autoscaling_lbv2.py
+++ b/heat_tempest_plugin/tests/scenario/test_autoscaling_lbv2.py
@@ -73,6 +73,8 @@
             'subnet': self.conf.fixed_subnet_name,
             'public_net': self.conf.floating_network_name
         }
+        if self.conf.vm_to_heat_api_insecure:
+            parameters['wc_extra_args'] = '--insecure'
 
         app_server_template = self._load_template(
             __file__, self.app_server_template_name, self.sub_dir
diff --git a/heat_tempest_plugin/tests/scenario/test_server_cfn_init.py b/heat_tempest_plugin/tests/scenario/test_server_cfn_init.py
index 963d1ad..817e8c6 100644
--- a/heat_tempest_plugin/tests/scenario/test_server_cfn_init.py
+++ b/heat_tempest_plugin/tests/scenario/test_server_cfn_init.py
@@ -113,6 +113,8 @@
             'timeout': self.conf.build_timeout,
             'subnet': self.net['subnets'][0],
         }
+        if self.conf.vm_to_heat_api_insecure:
+            parameters['SignalExtraArgs'] = '--insecure'
 
         # Launch stack
         stack_id = self.launch_stack(
diff --git a/heat_tempest_plugin/tests/scenario/test_server_signal.py b/heat_tempest_plugin/tests/scenario/test_server_signal.py
index 1823087..167dfa0 100644
--- a/heat_tempest_plugin/tests/scenario/test_server_signal.py
+++ b/heat_tempest_plugin/tests/scenario/test_server_signal.py
@@ -33,7 +33,8 @@
             'timeout': self.conf.build_timeout,
             'user_data_format': user_data_format
         }
-
+        if self.conf.vm_to_heat_api_insecure:
+            parameters['wc_extra_args'] = '--insecure'
         # Launch stack
         sid = self.launch_stack(
             template_name="test_server_signal.yaml",
diff --git a/heat_tempest_plugin/tests/scenario/test_volumes.py b/heat_tempest_plugin/tests/scenario/test_volumes.py
index 57d0936..5a39aac 100644
--- a/heat_tempest_plugin/tests/scenario/test_volumes.py
+++ b/heat_tempest_plugin/tests/scenario/test_volumes.py
@@ -119,7 +119,8 @@
             'timeout': self.conf.build_timeout,
             'network': self.net['id']
         }
-
+        if self.conf.vm_to_heat_api_insecure:
+            parameters['wc_extra_args'] = '--insecure'
         # Launch stack
         stack_id = self.launch_stack(
             template_name='test_volumes_delete_snapshot.yaml',