Test Case to check "swift object expiry"

Adds object expiry test case to "test_object_expiry.py" so as to
validate the object expiry support by trying to GET object after
expiry time.

Implements: blueprint add-swift-object-expiry-test
Change-Id: I1a29e8ae57e9f8661c21000775153bda78b0c689
diff --git a/tempest/tests/object_storage/test_object_expiry.py b/tempest/tests/object_storage/test_object_expiry.py
new file mode 100644
index 0000000..8437d55
--- /dev/null
+++ b/tempest/tests/object_storage/test_object_expiry.py
@@ -0,0 +1,93 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2012 OpenStack, LLC
+# 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 nose.plugins.attrib import attr
+from tempest.common.utils.data_utils import arbitrary_string
+from tempest.common.utils.data_utils import rand_name
+from tempest import exceptions
+from tempest.tests.object_storage import base
+from time import sleep
+import unittest2 as unittest
+
+
+class ObjectExpiryTest(base.BaseObjectTest):
+
+    @classmethod
+    def setUpClass(cls):
+        super(ObjectExpiryTest, cls).setUpClass()
+
+        #Create a container
+        cls.container_name = rand_name(name='TestContainer')
+        cls.container_client.create_container(cls.container_name)
+
+    @classmethod
+    def tearDownClass(cls):
+        """The test script fails in tear down class
+        as the container contains expired objects (LP bug 1069849).
+        But delete action for the expired object is raising
+        NotFound exception and also non empty container cannot be deleted."""
+
+        #Get list of all object in the container
+        objlist = \
+            cls.container_client.list_all_container_objects(cls.container_name)
+
+        #Attempt to delete every object in the container
+        if objlist:
+            for obj in objlist:
+                resp, _ = cls.object_client.delete_object(cls.container_name,
+                                                          obj['name'])
+
+        #Attempt to delete the container
+        resp, _ = cls.container_client.delete_container(cls.container_name)
+
+    @unittest.skip('Until bug 1069849 is resolved.')
+    @attr(type='regression')
+    def test_get_object_after_expiry_time(self):
+        """GET object after expiry time"""
+        #TODO(harika-vakadi): Similar test case has to be created for
+        # "X-Delete-At", after this test case works.
+
+        #Create Object
+        object_name = rand_name(name='TestObject')
+        data = arbitrary_string()
+        resp, _ = self.object_client.create_object(self.container_name,
+                                                   object_name, data)
+
+        #Update object metadata with expiry time of 3 seconds
+        metadata = {'X-Delete-After': '3'}
+        resp, _ = \
+            self.object_client.update_object_metadata(self.container_name,
+                                                      object_name, metadata,
+                                                      metadata_prefix='')
+
+        resp, _ = \
+            self.object_client.list_object_metadata(self.container_name,
+                                                    object_name)
+
+        self.assertEqual(resp['status'], '200')
+        self.assertIn('x-delete-at', resp)
+
+        resp, body = self.object_client.get_object(self.container_name,
+                                                   object_name)
+        self.assertEqual(resp['status'], '200')
+        # Check data
+        self.assertEqual(body, data)
+        # Sleep for over 5 seconds, so that object is expired
+        sleep(5)
+        # Verification of raised exception after object gets expired
+        self.assertRaises(exceptions.NotFound, self.object_client.get_object,
+                          self.container_name, object_name)