diff --git a/test/functional/swift_test_client.py b/test/functional/swift_test_client.py index 0232dbabb0..6103449a11 100644 --- a/test/functional/swift_test_client.py +++ b/test/functional/swift_test_client.py @@ -208,7 +208,11 @@ class Connection(object): def make_request(self, method, path=[], data='', hdrs={}, parms={}, cfg={}): - path = self.make_path(path, cfg=cfg) + if not cfg.get('verbatim_path'): + # Set verbatim_path=True to make a request to exactly the given + # path, not storage path + given path. Useful for + # non-account/container/object requests. + path = self.make_path(path, cfg=cfg) headers = self.make_headers(hdrs, cfg=cfg) if isinstance(parms, dict) and parms: quote = urllib.quote diff --git a/test/functional/tests.py b/test/functional/tests.py index 8d82d73edd..d1c626e12d 100644 --- a/test/functional/tests.py +++ b/test/functional/tests.py @@ -1744,6 +1744,24 @@ class TestSloEnv(object): def setUp(cls): cls.conn = Connection(config) cls.conn.authenticate() + + if cls.slo_enabled is None: + status = cls.conn.make_request('GET', '/info', + cfg={'verbatim_path': True}) + if not (200 <= status <= 299): + # Can't tell if SLO is enabled or not since we're running + # against an old cluster, so let's skip the tests instead of + # possibly having spurious failures. + cls.slo_enabled = False + else: + # Don't bother looking for ValueError here. If something is + # responding to a GET /info request with invalid JSON, then + # the cluster is broken and a test failure will let us know. + cluster_info = json.loads(cls.conn.response.read()) + cls.slo_enabled = 'slo' in cluster_info + if not cls.slo_enabled: + return + cls.account = Account(cls.conn, config.get('account', config['username'])) cls.account.delete_containers() @@ -1753,28 +1771,6 @@ class TestSloEnv(object): if not cls.container.create(): raise ResponseError(cls.conn.response) - # TODO(seriously, anyone can do this): make this use the /info API once - # it lands, both for detection of SLO and for minimum segment size - if cls.slo_enabled is None: - test_file = cls.container.file(".test-slo") - try: - # If SLO is enabled, this'll raise an error since - # X-Static-Large-Object is a reserved header. - # - # If SLO is not enabled, then this will get the usual 2xx - # response. - test_file.write( - "some contents", - hdrs={'X-Static-Large-Object': 'true'}) - except ResponseError as err: - if err.status == 400: - cls.slo_enabled = True - else: - raise - else: - cls.slo_enabled = False - return - seg_info = {} for letter, size in (('a', 1024 * 1024), ('b', 1024 * 1024),