Merge "Fix metric names in the object_store"

This commit is contained in:
Zuul 2020-05-08 10:04:42 +00:00 committed by Gerrit Code Review
commit 8bd107bb9b
2 changed files with 22 additions and 8 deletions

View File

@ -69,14 +69,21 @@ class Proxy(proxy.Proxy):
and url_parts[0][0] == 'v'
and url_parts[0][1] and url_parts[0][1].isdigit()):
url_parts = url_parts[1:]
name_parts = self._extract_name_consume_url_parts(url_parts)
# Getting the root of an endpoint is doing version discovery
if not name_parts:
name_parts = ['account']
# Strip out anything that's empty or None
return [part for part in name_parts if part]
parts = [part for part in url_parts if part]
# Getting the root of an endpoint is doing version discovery
if not parts:
return ['account']
if len(parts) == 1:
if 'endpoints' in parts:
return ['endpoints']
else:
return ['container']
else:
return ['object']
def get_account_metadata(self):
"""Get metadata for this account.

View File

@ -247,12 +247,19 @@ class TestDownloadObject(base_test_object.BaseTestObject):
class TestExtractName(TestObjectStoreProxy):
scenarios = [
('discovery', dict(url='/', parts=['account']))
('discovery', dict(url='/', parts=['account'])),
('endpoints', dict(url='/endpoints', parts=['endpoints'])),
('container', dict(url='/AUTH_123/container_name',
parts=['container'])),
('object', dict(url='/container_name/object_name',
parts=['object'])),
('object_long', dict(url='/v1/AUTH_123/cnt/path/deep/object_name',
parts=['object']))
]
def test_extract_name(self):
results = self.proxy._extract_name(self.url)
results = self.proxy._extract_name(self.url, project_id='123')
self.assertEqual(self.parts, results)