Merge "Increase to 255 the length of the user name."
diff --git a/tempest/README.rst b/tempest/README.rst
index 892b0f8..8f07a07 100644
--- a/tempest/README.rst
+++ b/tempest/README.rst
@@ -12,13 +12,13 @@
 and guidelines. Below is the proposed Havana restructuring for Tempest
 to make this clear.
 
-tempest/
-   api/ - API tests
-   cli/ - CLI tests
-   scenario/ - complex scenario tests
-   stress/ - stress tests
-   thirdparty/ - 3rd party api tests
-   whitebox/ - white box testing
+| tempest/
+|    api/ - API tests
+|    cli/ - CLI tests
+|    scenario/ - complex scenario tests
+|    stress/ - stress tests
+|    thirdparty/ - 3rd party api tests
+|    whitebox/ - white box testing
 
 Each of these directories contains different types of tests. What
 belongs in each directory, the rules and examples for good tests, are
diff --git a/tempest/api/compute/images/test_images.py b/tempest/api/compute/images/test_images.py
index 1ef30d4..a74bb68 100644
--- a/tempest/api/compute/images/test_images.py
+++ b/tempest/api/compute/images/test_images.py
@@ -15,8 +15,6 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import testtools
-
 from tempest.api import compute
 from tempest.api.compute import base
 from tempest import clients
@@ -100,11 +98,10 @@
         self.assertRaises(exceptions.Duplicate, self.client.create_image,
                           server['id'], snapshot_name)
 
-    @testtools.skip("Until Bug #1039739 is fixed")
     @attr(type=['negative', 'gate'])
     def test_create_image_when_server_is_rebooting(self):
         # Return error when creating an image of server that is rebooting
-        resp, server = self.create_server()
+        resp, server = self.create_server(wait_until='ACTIVE')
         self.servers_client.reboot(server['id'], 'HARD')
 
         snapshot_name = rand_name('test-snap-')
diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py
index e0e40cb..8068284 100644
--- a/tempest/api/network/base.py
+++ b/tempest/api/network/base.py
@@ -73,6 +73,7 @@
         cidr = netaddr.IPNetwork(cls.network_cfg.tenant_network_cidr)
         mask_bits = cls.network_cfg.tenant_network_mask_bits
         # Find a cidr that is not in use yet and create a subnet with it
+        failure = None
         for subnet_cidr in cidr.subnet(mask_bits):
             try:
                 resp, body = cls.client.create_subnet(network['id'],
@@ -82,6 +83,12 @@
                 is_overlapping_cidr = 'overlaps with another subnet' in str(e)
                 if not is_overlapping_cidr:
                     raise
+                # save the failure in case all of the CIDRs are overlapping
+                failure = e
+
+        if not body and failure:
+            raise failure
+
         subnet = body['subnet']
         cls.subnets.append(subnet)
         return subnet
diff --git a/tempest/api/volume/base.py b/tempest/api/volume/base.py
index 2839da4..fc510cb 100644
--- a/tempest/api/volume/base.py
+++ b/tempest/api/volume/base.py
@@ -128,9 +128,9 @@
         resp, snapshot = cls.snapshots_client.create_snapshot(volume_id,
                                                               **kwargs)
         assert 200 == resp.status
+        cls.snapshots.append(snapshot)
         cls.snapshots_client.wait_for_snapshot_status(snapshot['id'],
                                                       'available')
-        cls.snapshots.append(snapshot)
         return snapshot
 
     #NOTE(afazekas): these create_* and clean_* could be defined
@@ -141,8 +141,8 @@
         """Wrapper utility that returns a test volume."""
         resp, volume = cls.volumes_client.create_volume(size, **kwargs)
         assert 200 == resp.status
-        cls.volumes_client.wait_for_volume_status(volume['id'], 'available')
         cls.volumes.append(volume)
+        cls.volumes_client.wait_for_volume_status(volume['id'], 'available')
         return volume
 
     @classmethod
diff --git a/tempest/api/volume/test_volumes_get.py b/tempest/api/volume/test_volumes_get.py
index 68ab745..eda7153 100644
--- a/tempest/api/volume/test_volumes_get.py
+++ b/tempest/api/volume/test_volumes_get.py
@@ -21,7 +21,6 @@
 
 
 class VolumesGetTest(base.BaseVolumeTest):
-
     _interface = "json"
 
     @classmethod
@@ -29,22 +28,17 @@
         super(VolumesGetTest, cls).setUpClass()
         cls.client = cls.volumes_client
 
-    def _volume_create_get_delete(self, image_ref=None):
+    def _volume_create_get_delete(self, **kwargs):
         # Create a volume, Get it's details and Delete the volume
         try:
             volume = {}
-            v_name = rand_name('Volume-')
-            metadata = {'Type': 'work'}
+            v_name = rand_name('Volume')
+            metadata = {'Type': 'Test'}
             #Create a volume
-            if not image_ref:
-                resp, volume = self.client.create_volume(size=1,
-                                                         display_name=v_name,
-                                                         metadata=metadata)
-            else:
-                resp, volume = self.client.create_volume(size=1,
-                                                         display_name=v_name,
-                                                         metadata=metadata,
-                                                         imageRef=image_ref)
+            resp, volume = self.client.create_volume(size=1,
+                                                     display_name=v_name,
+                                                     metadata=metadata,
+                                                     **kwargs)
             self.assertEqual(200, resp.status)
             self.assertTrue('id' in volume)
             self.assertTrue('display_name' in volume)
@@ -107,11 +101,17 @@
 
     @attr(type='smoke')
     def test_volume_create_get_delete(self):
-        self._volume_create_get_delete(image_ref=None)
+        self._volume_create_get_delete()
 
     @attr(type='smoke')
-    def test_volume_from_image(self):
-        self._volume_create_get_delete(image_ref=self.config.compute.image_ref)
+    def test_volume_create_get_delete_from_image(self):
+        self._volume_create_get_delete(imageRef=self.config.compute.image_ref)
+
+    @attr(type='gate')
+    def test_volume_create_get_delete_as_clone(self):
+        origin = self.create_volume(size=1,
+                                    display_name="Volume Origin")
+        self._volume_create_get_delete(source_volid=origin['id'])
 
 
 class VolumesGetTestXML(VolumesGetTest):
diff --git a/tempest/hacking/checks.py b/tempest/hacking/checks.py
index 93cf89d..5e941da 100644
--- a/tempest/hacking/checks.py
+++ b/tempest/hacking/checks.py
@@ -66,3 +66,4 @@
 def factory(register):
     register(skip_bugs)
     register(import_no_clients_in_api)
+    register(import_no_files_in_tests)
diff --git a/tempest/whitebox/test_servers_whitebox.py b/tempest/whitebox/test_servers_whitebox.py
index cd3c026..2694b95 100644
--- a/tempest/whitebox/test_servers_whitebox.py
+++ b/tempest/whitebox/test_servers_whitebox.py
@@ -50,70 +50,6 @@
             except exceptions.NotFound:
                 continue
 
-    def test_create_server_vcpu_quota_full(self):
-        # Disallow server creation when tenant's vcpu quota is full
-        quotas = self.meta.tables['quotas']
-        stmt = (quotas.select().
-                where(quotas.c.project_id == self.tenant_id).
-                where(quotas.c.resource == 'cores'))
-        result = self.connection.execute(stmt).first()
-
-        # Set vcpu quota for tenant if not already set
-        if not result:
-            cores_hard_limit = 2
-            stmt = quotas.insert().values(deleted=0,
-                                          project_id=self.tenant_id,
-                                          resource='cores',
-                                          hard_limit=cores_hard_limit)
-
-            self.connection.execute(stmt, autocommit=True)
-        else:
-            cores_hard_limit = result.hard_limit
-
-        # Create servers assuming 1 VCPU per instance i.e flavor_id=1
-        try:
-            for count in range(cores_hard_limit + 1):
-                self.create_server()
-        except exceptions.OverLimit:
-            pass
-        else:
-            self.fail("Could create servers over the VCPU quota limit")
-        finally:
-            stmt = quotas.delete()
-            self.connection.execute(stmt, autocommit=True)
-
-    def test_create_server_memory_quota_full(self):
-        # Disallow server creation when tenant's memory quota is full
-        quotas = self.meta.tables['quotas']
-        stmt = (quotas.select().
-                where(quotas.c.project_id == self.tenant_id).
-                where(quotas.c.resource == 'ram'))
-        result = self.connection.execute(stmt).first()
-
-        # Set memory quota for tenant if not already set
-        if not result:
-            ram_hard_limit = 1024
-            stmt = quotas.insert().values(deleted=0,
-                                          project_id=self.tenant_id,
-                                          resource='ram',
-                                          hard_limit=ram_hard_limit)
-
-            self.connection.execute(stmt, autocommit=True)
-        else:
-            ram_hard_limit = result.hard_limit
-
-        try:
-            # Set a hard range of 3 servers for reaching the RAM quota
-            for count in range(3):
-                self.create_server()
-        except exceptions.OverLimit:
-            pass
-        else:
-            self.fail("Could create servers over the RAM quota limit")
-        finally:
-            stmt = quotas.delete()
-            self.connection.execute(stmt, autocommit=True)
-
     def update_state(self, server_id, vm_state, task_state, deleted=0):
         """Update states of an instance in database for validation."""
         if not task_state: