summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgholt <z-launchpad@brim.net>2012-08-06 20:53:24 +0000
committergholt <z-launchpad@brim.net>2012-08-06 20:53:24 +0000
commit61932d85066e646b9d7fabb58fc5ac1dd2ab9eb3 (patch)
tree278999507d050510697be1aa15dd477693eb4d74
parentb06bfa69a6be450026447a596dae47cba7b057ef (diff)
downloadswift-61932d85066e646b9d7fabb58fc5ac1dd2ab9eb3.tar.gz
Fixed bug where expirer would get confused by...
Fixed bug where expirer would get confused by odd deletion times. Since this has already rolled out, I just capped things at ten 9s, or Sat Nov 20 17:46:39 2286. I can't wait for the Y2286 world panic. :/ Change-Id: Iba10963faa344a418a1fa573d5c85f4ff864b574
-rw-r--r--swift/obj/server.py4
-rw-r--r--test/unit/obj/test_server.py35
2 files changed, 39 insertions, 0 deletions
diff --git a/swift/obj/server.py b/swift/obj/server.py
index c88a40614..4e68ac829 100644
--- a/swift/obj/server.py
+++ b/swift/obj/server.py
@@ -471,6 +471,10 @@ class ObjectController(object):
:param headers_in: dictionary of headers from the original request
:param objdevice: device name that the object is in
"""
+ # Quick cap that will work from now until Sat Nov 20 17:46:39 2286
+ # At that time, Swift will be so popular and pervasive I will have
+ # created income for thousands of future programmers.
+ delete_at = max(min(delete_at, 9999999999), 0)
host = partition = contdevice = None
headers_out = {'x-timestamp': headers_in['x-timestamp'],
'x-trans-id': headers_in.get('x-trans-id', '-')}
diff --git a/test/unit/obj/test_server.py b/test/unit/obj/test_server.py
index 96e2af024..ecb88f5a0 100644
--- a/test/unit/obj/test_server.py
+++ b/test/unit/obj/test_server.py
@@ -1641,6 +1641,41 @@ class TestObjectController(unittest.TestCase):
'x-trans-id': '-'},
'sda1'])
+ def test_delete_at_negative(self):
+ # Test negative is reset to 0
+ given_args = []
+
+ def fake_async_update(*args):
+ given_args.extend(args)
+
+ self.object_controller.async_update = fake_async_update
+ self.object_controller.delete_at_update(
+ 'PUT', -2, 'a', 'c', 'o', {'x-timestamp': '1'}, 'sda1')
+ self.assertEquals(given_args, [
+ 'PUT', '.expiring_objects', '0', '0-a/c/o', None, None, None,
+ {'x-size': '0', 'x-etag': 'd41d8cd98f00b204e9800998ecf8427e',
+ 'x-content-type': 'text/plain', 'x-timestamp': '1',
+ 'x-trans-id': '-'},
+ 'sda1'])
+
+ def test_delete_at_cap(self):
+ # Test past cap is reset to cap
+ given_args = []
+
+ def fake_async_update(*args):
+ given_args.extend(args)
+
+ self.object_controller.async_update = fake_async_update
+ self.object_controller.delete_at_update(
+ 'PUT', 12345678901, 'a', 'c', 'o', {'x-timestamp': '1'}, 'sda1')
+ self.assertEquals(given_args, [
+ 'PUT', '.expiring_objects', '9999936000', '9999999999-a/c/o', None,
+ None, None,
+ {'x-size': '0', 'x-etag': 'd41d8cd98f00b204e9800998ecf8427e',
+ 'x-content-type': 'text/plain', 'x-timestamp': '1',
+ 'x-trans-id': '-'},
+ 'sda1'])
+
def test_delete_at_update_put_with_info(self):
given_args = []