Add "delete a shelved server" tests

This patch adds "delete a shelved server" tests.

Change-Id: Ie43a19a34c1b01c313142fc8e9f6f009dd35d7d3
diff --git a/tempest/api/compute/servers/test_delete_server.py b/tempest/api/compute/servers/test_delete_server.py
index 488afb6..6a9b996 100644
--- a/tempest/api/compute/servers/test_delete_server.py
+++ b/tempest/api/compute/servers/test_delete_server.py
@@ -14,8 +14,11 @@
 #    under the License.
 
 from tempest.api.compute import base
+from tempest import config
 from tempest import test
 
+CONF = config.CONF
+
 
 class DeleteServersTestJSON(base.BaseV2ComputeTest):
     # NOTE: Server creations of each test class should be under 10
@@ -59,6 +62,24 @@
         resp, _ = self.client.delete_server(server['id'])
         self.assertEqual('204', resp['status'])
 
+    @test.attr(type='gate')
+    def test_delete_server_while_in_shelved_state(self):
+        # Delete a server while it's VM state is Shelved
+        resp, server = self.create_test_server(wait_until='ACTIVE')
+        resp, body = self.client.shelve_server(server['id'])
+        self.assertEqual(202, resp.status)
+
+        offload_time = CONF.compute.shelved_offload_time
+        if offload_time >= 0:
+            self.client.wait_for_server_status(server['id'],
+                                               'SHELVED_OFFLOADED',
+                                               extra_timeout=offload_time)
+        else:
+            self.client.wait_for_server_status(server['id'],
+                                               'SHELVED')
+        resp, _ = self.client.delete_server(server['id'])
+        self.assertEqual('204', resp['status'])
+
 
 class DeleteServersTestXML(DeleteServersTestJSON):
     _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_delete_server.py b/tempest/api/compute/v3/servers/test_delete_server.py
index 0e62ea4..e98e1b7 100644
--- a/tempest/api/compute/v3/servers/test_delete_server.py
+++ b/tempest/api/compute/v3/servers/test_delete_server.py
@@ -13,8 +13,11 @@
 #    under the License.
 
 from tempest.api.compute import base
+from tempest import config
 from tempest import test
 
+CONF = config.CONF
+
 
 class DeleteServersV3Test(base.BaseV3ComputeTest):
     # NOTE: Server creations of each test class should be under 10
@@ -57,3 +60,22 @@
         self.client.wait_for_server_status(server['id'], 'PAUSED')
         resp, _ = self.client.delete_server(server['id'])
         self.assertEqual('204', resp['status'])
+
+    @test.attr(type='gate')
+    def test_delete_server_while_in_shelved_state(self):
+        # Delete a server while it's VM state is Shelved
+        resp, server = self.create_test_server(wait_until='ACTIVE')
+        resp, body = self.client.shelve_server(server['id'])
+        self.assertEqual(202, resp.status)
+
+        offload_time = CONF.compute.shelved_offload_time
+        if offload_time >= 0:
+            self.client.wait_for_server_status(server['id'],
+                                               'SHELVED_OFFLOADED',
+                                               extra_timeout=offload_time)
+        else:
+            self.client.wait_for_server_status(server['id'],
+                                               'SHELVED')
+
+        resp, _ = self.client.delete_server(server['id'])
+        self.assertEqual('204', resp['status'])