Merge "Add negative resize server action test"
diff --git a/tempest/api/compute/admin/test_quotas.py b/tempest/api/compute/admin/test_quotas.py
index 3fc20ac..ded0477 100644
--- a/tempest/api/compute/admin/test_quotas.py
+++ b/tempest/api/compute/admin/test_quotas.py
@@ -36,8 +36,6 @@
         cls.identity_admin_client = cls._get_identity_admin_client()
         cls.sg_client = cls.security_groups_client
 
-        resp, tenants = cls.identity_admin_client.list_tenants()
-
         # NOTE(afazekas): these test cases should always create and use a new
         # tenant most of them should be skipped if we can't do that
         cls.demo_tenant_id = cls.isolated_creds.get_primary_user().get(
diff --git a/tempest/api/compute/security_groups/test_security_group_rules.py b/tempest/api/compute/security_groups/test_security_group_rules.py
index 9dc164d..d61acfb 100644
--- a/tempest/api/compute/security_groups/test_security_group_rules.py
+++ b/tempest/api/compute/security_groups/test_security_group_rules.py
@@ -15,12 +15,12 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+import uuid
+
 from tempest.api.compute import base
 from tempest.common.utils import data_utils
-from tempest import config
 from tempest import exceptions
 from tempest.test import attr
-from tempest.test import skip_because
 
 
 class SecurityGroupRulesTestJSON(base.BaseV2ComputeTest):
@@ -30,6 +30,7 @@
     def setUpClass(cls):
         super(SecurityGroupRulesTestJSON, cls).setUpClass()
         cls.client = cls.security_groups_client
+        cls.neutron_available = cls.config.service_available.neutron
 
     @attr(type='gate')
     def test_security_group_rules_create(self):
@@ -93,14 +94,14 @@
         self.addCleanup(self.client.delete_security_group_rule, rule['id'])
         self.assertEqual(200, resp.status)
 
-    @skip_because(bug="1182384",
-                  condition=config.TempestConfig().service_available.neutron)
-    @attr(type=['negative', 'gate'])
+    @attr(type=['negative', 'smoke'])
     def test_security_group_rules_create_with_invalid_id(self):
         # Negative test: Creation of Security Group rule should FAIL
         # with invalid Parent group id
         # Adding rules to the invalid Security Group id
         parent_group_id = data_utils.rand_int_id(start=999)
+        if self.neutron_available:
+            parent_group_id = str(uuid.uuid4())
         ip_protocol = 'tcp'
         from_port = 22
         to_port = 22
@@ -185,15 +186,16 @@
                           self.client.create_security_group_rule,
                           secgroup_id, ip_protocol, from_port, to_port)
 
-    @skip_because(bug="1182384",
-                  condition=config.TempestConfig().service_available.neutron)
-    @attr(type=['negative', 'gate'])
+    @attr(type=['negative', 'smoke'])
     def test_security_group_rules_delete_with_invalid_id(self):
         # Negative test: Deletion of Security Group rule should be FAIL
         # with invalid rule id
+        group_rule_id = data_utils.rand_int_id(start=999)
+        if self.neutron_available:
+            group_rule_id = str(uuid.uuid4())
         self.assertRaises(exceptions.NotFound,
                           self.client.delete_security_group_rule,
-                          data_utils.rand_int_id(start=999))
+                          group_rule_id)
 
     @attr(type='gate')
     def test_security_group_rules_list(self):
diff --git a/tempest/api/compute/security_groups/test_security_groups.py b/tempest/api/compute/security_groups/test_security_groups.py
index 6e08700..7cb96af 100644
--- a/tempest/api/compute/security_groups/test_security_groups.py
+++ b/tempest/api/compute/security_groups/test_security_groups.py
@@ -16,6 +16,7 @@
 #    under the License.
 
 import testtools
+import uuid
 
 from tempest.api.compute import base
 from tempest.common.utils import data_utils
@@ -32,6 +33,7 @@
     def setUpClass(cls):
         super(SecurityGroupsTestJSON, cls).setUpClass()
         cls.client = cls.security_groups_client
+        cls.neutron_available = cls.config.service_available.neutron
 
     def _delete_security_group(self, securitygroup_id):
         resp, _ = self.client.delete_security_group(securitygroup_id)
@@ -108,9 +110,7 @@
                          "The fetched Security Group is different "
                          "from the created Group")
 
-    @skip_because(bug="1182384",
-                  condition=config.TempestConfig().service_available.neutron)
-    @attr(type=['negative', 'gate'])
+    @attr(type=['negative', 'smoke'])
     def test_security_group_get_nonexistant_group(self):
         # Negative test:Should not be able to GET the details
         # of non-existent Security Group
@@ -121,6 +121,8 @@
         # Creating a non-existent Security Group id
         while True:
             non_exist_id = data_utils.rand_int_id(start=999)
+            if self.neutron_available:
+                non_exist_id = str(uuid.uuid4())
             if non_exist_id not in security_group_id:
                 break
         self.assertRaises(exceptions.NotFound, self.client.get_security_group,
@@ -198,9 +200,7 @@
                           self.client.delete_security_group,
                           default_security_group_id)
 
-    @skip_because(bug="1182384",
-                  condition=config.TempestConfig().service_available.neutron)
-    @attr(type=['negative', 'gate'])
+    @attr(type=['negative', 'smoke'])
     def test_delete_nonexistant_security_group(self):
         # Negative test:Deletion of a non-existent Security Group should Fail
         security_group_id = []
@@ -210,6 +210,8 @@
         # Creating non-existent Security Group
         while True:
             non_exist_id = data_utils.rand_int_id(start=999)
+            if self.neutron_available:
+                non_exist_id = str(uuid.uuid4())
             if non_exist_id not in security_group_id:
                 break
         self.assertRaises(exceptions.NotFound,
diff --git a/tempest/api/compute/servers/test_server_rescue.py b/tempest/api/compute/servers/test_server_rescue.py
index 925c5c3..837ab48 100644
--- a/tempest/api/compute/servers/test_server_rescue.py
+++ b/tempest/api/compute/servers/test_server_rescue.py
@@ -17,7 +17,6 @@
 
 from tempest.api.compute import base
 from tempest.common.utils.data_utils import rand_name
-import tempest.config
 from tempest import exceptions
 from tempest.test import attr
 
@@ -25,8 +24,6 @@
 class ServerRescueTestJSON(base.BaseV2ComputeTest):
     _interface = 'json'
 
-    run_ssh = tempest.config.TempestConfig().compute.run_ssh
-
     @classmethod
     def setUpClass(cls):
         super(ServerRescueTestJSON, cls).setUpClass()
diff --git a/tempest/api/compute/v3/images/test_images.py b/tempest/api/compute/v3/images/test_images.py
index 3f3c7bc..ac2deb4 100644
--- a/tempest/api/compute/v3/images/test_images.py
+++ b/tempest/api/compute/v3/images/test_images.py
@@ -123,43 +123,6 @@
                           self.servers_client.create_image,
                           test_uuid, snapshot_name)
 
-    @attr(type=['negative', 'gate'])
-    def test_delete_image_with_invalid_image_id(self):
-        # An image should not be deleted with invalid image id
-        self.assertRaises(exceptions.NotFound, self.client.delete_image,
-                          '!@$%^&*()')
-
-    @attr(type=['negative', 'gate'])
-    def test_delete_non_existent_image(self):
-        # Return an error while trying to delete a non-existent image
-
-        non_existent_image_id = '11a22b9-12a9-5555-cc11-00ab112223fa'
-        self.assertRaises(exceptions.NotFound, self.client.delete_image,
-                          non_existent_image_id)
-
-    @attr(type=['negative', 'gate'])
-    def test_delete_image_blank_id(self):
-        # Return an error while trying to delete an image with blank Id
-        self.assertRaises(exceptions.NotFound, self.client.delete_image, '')
-
-    @attr(type=['negative', 'gate'])
-    def test_delete_image_non_hex_string_id(self):
-        # Return an error while trying to delete an image with non hex id
-        image_id = '11a22b9-120q-5555-cc11-00ab112223gj'
-        self.assertRaises(exceptions.NotFound, self.client.delete_image,
-                          image_id)
-
-    @attr(type=['negative', 'gate'])
-    def test_delete_image_negative_image_id(self):
-        # Return an error while trying to delete an image with negative id
-        self.assertRaises(exceptions.NotFound, self.client.delete_image, -1)
-
-    @attr(type=['negative', 'gate'])
-    def test_delete_image_id_is_over_35_character_limit(self):
-        # Return an error while trying to delete image with id over limit
-        self.assertRaises(exceptions.NotFound, self.client.delete_image,
-                          '11a22b9-12a9-5555-cc11-00ab112223fa-3fac')
-
 
 class ImagesV3TestXML(ImagesV3TestJSON):
     _interface = 'xml'
diff --git a/tempest/api/image/v1/test_images.py b/tempest/api/image/v1/test_images.py
index 90ffeae..558e2ec 100644
--- a/tempest/api/image/v1/test_images.py
+++ b/tempest/api/image/v1/test_images.py
@@ -18,7 +18,6 @@
 import cStringIO as StringIO
 
 from tempest.api.image import base
-from tempest import exceptions
 from tempest.test import attr
 
 
@@ -26,17 +25,6 @@
     """Here we test the registration and creation of images."""
 
     @attr(type='gate')
-    def test_register_with_invalid_container_format(self):
-        # Negative tests for invalid data supplied to POST /images
-        self.assertRaises(exceptions.BadRequest, self.client.create_image,
-                          'test', 'wrong', 'vhd')
-
-    @attr(type='gate')
-    def test_register_with_invalid_disk_format(self):
-        self.assertRaises(exceptions.BadRequest, self.client.create_image,
-                          'test', 'bare', 'wrong')
-
-    @attr(type='gate')
     def test_register_then_upload(self):
         # Register, then upload an image
         properties = {'prop1': 'val1'}
@@ -108,6 +96,8 @@
         self.assertEqual(40, body.get('min_ram'))
         for key, val in properties.items():
             self.assertEqual(val, body.get('properties')[key])
+        resp, body = self.client.delete_image(body['id'])
+        self.assertEqual('200', resp['status'])
 
 
 class ListImagesTest(base.BaseV1ImageTest):
diff --git a/tempest/api/image/v1/test_images_negative.py b/tempest/api/image/v1/test_images_negative.py
new file mode 100644
index 0000000..1bcf120
--- /dev/null
+++ b/tempest/api/image/v1/test_images_negative.py
@@ -0,0 +1,72 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 IBM Corp.
+# All Rights Reserved.
+#
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
+#    not use this file except in compliance with the License. You may obtain
+#    a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+#    License for the specific language governing permissions and limitations
+#    under the License.
+
+from tempest.api.image import base
+from tempest import exceptions
+from tempest.test import attr
+
+
+class CreateDeleteImagesNegativeTest(base.BaseV1ImageTest):
+    """Here are negative tests for the deletion and creation of images."""
+
+    @attr(type=['negative', 'gate'])
+    def test_register_with_invalid_container_format(self):
+        # Negative tests for invalid data supplied to POST /images
+        self.assertRaises(exceptions.BadRequest, self.client.create_image,
+                          'test', 'wrong', 'vhd')
+
+    @attr(type=['negative', 'gate'])
+    def test_register_with_invalid_disk_format(self):
+        self.assertRaises(exceptions.BadRequest, self.client.create_image,
+                          'test', 'bare', 'wrong')
+
+    @attr(type=['negative', 'gate'])
+    def test_delete_image_with_invalid_image_id(self):
+        # An image should not be deleted with invalid image id
+        self.assertRaises(exceptions.NotFound, self.client.delete_image,
+                          '!@$%^&*()')
+
+    @attr(type=['negative', 'gate'])
+    def test_delete_non_existent_image(self):
+        # Return an error while trying to delete a non-existent image
+
+        non_existent_image_id = '11a22b9-12a9-5555-cc11-00ab112223fa'
+        self.assertRaises(exceptions.NotFound, self.client.delete_image,
+                          non_existent_image_id)
+
+    @attr(type=['negative', 'gate'])
+    def test_delete_image_blank_id(self):
+        # Return an error while trying to delete an image with blank Id
+        self.assertRaises(exceptions.NotFound, self.client.delete_image, '')
+
+    @attr(type=['negative', 'gate'])
+    def test_delete_image_non_hex_string_id(self):
+        # Return an error while trying to delete an image with non hex id
+        image_id = '11a22b9-120q-5555-cc11-00ab112223gj'
+        self.assertRaises(exceptions.NotFound, self.client.delete_image,
+                          image_id)
+
+    @attr(type=['negative', 'gate'])
+    def test_delete_image_negative_image_id(self):
+        # Return an error while trying to delete an image with negative id
+        self.assertRaises(exceptions.NotFound, self.client.delete_image, -1)
+
+    @attr(type=['negative', 'gate'])
+    def test_delete_image_id_is_over_35_character_limit(self):
+        # Return an error while trying to delete image with id over limit
+        self.assertRaises(exceptions.NotFound, self.client.delete_image,
+                          '11a22b9-12a9-5555-cc11-00ab112223fa-3fac')