From 8b8a2a3406e4af2a8c61427f5ea43aa7ab161961 Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Thu, 1 Mar 2018 23:30:00 +0000 Subject: [PATCH] Tolerate 404s during setUp/tearDown in func tests A couple times, I've seen tests fail in the gate because we got back a 404 while trying to clean out the test account. The story that gets us here seems to be: - One or more object servers take too long to respond to the initial DELETE request, so the test client gets back a 503 and sleeps so it can retry. - Meanwhile, the servers finish writing their tombstones and want to respond 204 (but probably *actually* respond 408 because the proxy killed the connection). - The test client sends its retry, and since the object servers now have tombstones, it gets back a 404. But the thing is, this is *outside of the test scope* anyway, we're just trying to get back to a sane state. If it's gone, s much the better! For an example of this, see the failures on patchset 3 of https://review.openstack.org/#/c/534978 (which both failed for the same reason on different tests). Change-Id: I9ab2fd430d4800f9f55275959a20e30f09d9e1a4 --- test/functional/swift_test_client.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/test/functional/swift_test_client.py b/test/functional/swift_test_client.py index 4c1dcd8cd3..585ab0903d 100644 --- a/test/functional/swift_test_client.py +++ b/test/functional/swift_test_client.py @@ -543,7 +543,7 @@ class Container(Base): def delete_files(self): for f in listing_items(self.files): file_item = self.file(f) - if not file_item.delete(): + if not file_item.delete(tolerate_missing=True): return False return listing_empty(self.files) @@ -764,14 +764,19 @@ class File(Base): self.conn.make_path(self.path)) return True - def delete(self, hdrs=None, parms=None, cfg=None): + def delete(self, hdrs=None, parms=None, cfg=None, tolerate_missing=False): if hdrs is None: hdrs = {} if parms is None: parms = {} - if self.conn.make_request('DELETE', self.path, hdrs=hdrs, - cfg=cfg, parms=parms) != 204: + if tolerate_missing: + allowed_statuses = (204, 404) + else: + allowed_statuses = (204,) + if self.conn.make_request( + 'DELETE', self.path, hdrs=hdrs, cfg=cfg, + parms=parms) not in allowed_statuses: raise ResponseError(self.conn.response, 'DELETE', self.conn.make_path(self.path))