Skip to content

Commit 9fc9148

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Bump Images API version to 2.11"
2 parents b49c042 + 0e3d274 commit 9fc9148

File tree

4 files changed

+218
-120
lines changed

4 files changed

+218
-120
lines changed

glance/api/middleware/version_negotiation.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ def _get_allowed_versions(self):
8484
allowed_versions['v2.9'] = 2
8585
if CONF.enabled_backends:
8686
allowed_versions['v2.8'] = 2
87+
allowed_versions['v2.10'] = 2
88+
allowed_versions['v2.11'] = 2
8789
return allowed_versions
8890

8991
def _match_version_string(self, subject):

glance/api/versions.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,10 @@ def build_version_object(version, path, status):
7878
version_objs = []
7979
if CONF.enabled_backends:
8080
version_objs.extend([
81-
build_version_object(2.10, 'v2', 'CURRENT'),
81+
build_version_object(2.11, 'v2', 'CURRENT'),
82+
build_version_object('2.10', 'v2', 'SUPPORTED'),
8283
build_version_object(2.9, 'v2', 'SUPPORTED'),
83-
build_version_object(2.8, 'v2', 'SUPPORTED')
84+
build_version_object(2.8, 'v2', 'SUPPORTED'),
8485
])
8586
else:
8687
version_objs.extend([

glance/tests/functional/test_api.py

Lines changed: 38 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -15,81 +15,53 @@
1515

1616
"""Version-independent api tests"""
1717

18-
1918
import httplib2
2019
from oslo_serialization import jsonutils
2120
from six.moves import http_client
2221

2322
from glance.tests import functional
23+
from glance.tests.unit import test_versions as tv
2424

2525

26-
def _generate_v2_versions(url):
27-
version_list = []
28-
version_list.extend([
29-
{
30-
'id': 'v2.9',
31-
'status': 'CURRENT',
32-
'links': [{'rel': 'self', 'href': url % '2'}],
33-
},
34-
{
35-
'id': 'v2.7',
36-
'status': 'SUPPORTED',
37-
'links': [{'rel': 'self', 'href': url % '2'}],
38-
},
39-
{
40-
'id': 'v2.6',
41-
'status': 'SUPPORTED',
42-
'links': [{'rel': 'self', 'href': url % '2'}],
43-
},
44-
{
45-
'id': 'v2.5',
46-
'status': 'SUPPORTED',
47-
'links': [{'rel': 'self', 'href': url % '2'}],
48-
},
49-
{
50-
'id': 'v2.4',
51-
'status': 'SUPPORTED',
52-
'links': [{'rel': 'self', 'href': url % '2'}],
53-
},
54-
{
55-
'id': 'v2.3',
56-
'status': 'SUPPORTED',
57-
'links': [{'rel': 'self', 'href': url % '2'}],
58-
},
59-
{
60-
'id': 'v2.2',
61-
'status': 'SUPPORTED',
62-
'links': [{'rel': 'self', 'href': url % '2'}],
63-
},
64-
{
65-
'id': 'v2.1',
66-
'status': 'SUPPORTED',
67-
'links': [{'rel': 'self', 'href': url % '2'}],
68-
},
69-
{
70-
'id': 'v2.0',
71-
'status': 'SUPPORTED',
72-
'links': [{'rel': 'self', 'href': url % '2'}],
73-
}
74-
])
75-
v2_versions = {'versions': version_list}
76-
return v2_versions
77-
78-
79-
def _generate_all_versions(url):
80-
v2 = _generate_v2_versions(url)
81-
all_versions = {'versions': v2['versions']}
82-
return all_versions
26+
class TestApiVersions(functional.FunctionalTest):
27+
def test_version_configurations(self):
28+
"""Test that versioning is handled properly through all channels"""
29+
self.start_servers(**self.__dict__.copy())
8330

31+
url = 'http://127.0.0.1:%d' % self.api_port
32+
versions = {'versions': tv.get_versions_list(url)}
33+
34+
# Verify version choices returned.
35+
path = 'http://%s:%d' % ('127.0.0.1', self.api_port)
36+
http = httplib2.Http()
37+
response, content_json = http.request(path, 'GET')
38+
self.assertEqual(http_client.MULTIPLE_CHOICES, response.status)
39+
content = jsonutils.loads(content_json.decode())
40+
self.assertEqual(versions, content)
41+
42+
def test_v2_api_configuration(self):
43+
self.start_servers(**self.__dict__.copy())
44+
45+
url = 'http://127.0.0.1:%d' % self.api_port
46+
versions = {'versions': tv.get_versions_list(url)}
47+
48+
# Verify version choices returned.
49+
path = 'http://%s:%d' % ('127.0.0.1', self.api_port)
50+
http = httplib2.Http()
51+
response, content_json = http.request(path, 'GET')
52+
self.assertEqual(http_client.MULTIPLE_CHOICES, response.status)
53+
content = jsonutils.loads(content_json.decode())
54+
self.assertEqual(versions, content)
8455

85-
class TestApiVersions(functional.FunctionalTest):
8656

57+
class TestApiVersionsMultistore(functional.MultipleBackendFunctionalTest):
8758
def test_version_configurations(self):
8859
"""Test that versioning is handled properly through all channels"""
8960
self.start_servers(**self.__dict__.copy())
9061

91-
url = 'http://127.0.0.1:%d/v%%s/' % self.api_port
92-
versions = _generate_all_versions(url)
62+
url = 'http://127.0.0.1:%d' % self.api_port
63+
versions = {'versions': tv.get_versions_list(url,
64+
enabled_backends=True)}
9365

9466
# Verify version choices returned.
9567
path = 'http://%s:%d' % ('127.0.0.1', self.api_port)
@@ -102,8 +74,9 @@ def test_version_configurations(self):
10274
def test_v2_api_configuration(self):
10375
self.start_servers(**self.__dict__.copy())
10476

105-
url = 'http://127.0.0.1:%d/v%%s/' % self.api_port
106-
versions = _generate_v2_versions(url)
77+
url = 'http://127.0.0.1:%d' % self.api_port
78+
versions = {'versions': tv.get_versions_list(url,
79+
enabled_backends=True)}
10780

10881
# Verify version choices returned.
10982
path = 'http://%s:%d' % ('127.0.0.1', self.api_port)
@@ -119,8 +92,8 @@ def setUp(self):
11992
super(TestApiPaths, self).setUp()
12093
self.start_servers(**self.__dict__.copy())
12194

122-
url = 'http://127.0.0.1:%d/v%%s/' % self.api_port
123-
self.versions = _generate_all_versions(url)
95+
url = 'http://127.0.0.1:%d' % self.api_port
96+
self.versions = {'versions': tv.get_versions_list(url)}
12497
images = {'images': []}
12598
self.images_json = jsonutils.dumps(images)
12699

0 commit comments

Comments
 (0)