Remove accelerator in microversion header

Closes-Bug: 2049489
Change-Id: I0e392e63da354682da0ce7f347ab6e24d3d2432d
This commit is contained in:
songwenping 2024-01-16 15:35:01 +08:00
parent 751bc6ae55
commit 279a260bb2
5 changed files with 10 additions and 20 deletions

View File

@ -17,7 +17,6 @@ import datetime
import functools
import inspect
import microversion_parse
import pecan
from pecan import rest
@ -108,10 +107,7 @@ class Version(object):
:raises: webob.HTTPNotAcceptable
"""
version_str = microversion_parse.get_version(
headers,
service_type='accelerator')
version_str = headers.get(Version.current_api_version, default_version)
minimal_version = (2, 0)
if version_str is None:

View File

@ -35,15 +35,13 @@ from cyborg.api.controllers.v2 import versions
def min_version():
return base.Version(
{base.Version.current_api_version: ' '.join(
[versions.service_type_string(), versions.min_version_string()])},
{base.Version.current_api_version: versions.min_version_string()},
versions.min_version_string(), versions.max_version_string())
def max_version():
return base.Version(
{base.Version.current_api_version: ' '.join(
[versions.service_type_string(), versions.max_version_string()])},
{base.Version.current_api_version: versions.max_version_string()},
versions.min_version_string(), versions.max_version_string())

View File

@ -315,7 +315,7 @@ class TestARQsController(v2_test.APITestV2):
self.patch_json(self.ARQ_URL, params=patch_list,
headers={base.Version.current_api_version:
'accelerator 2.1'})
'2.1'})
mock_apply_patch.assert_called_once_with(mock.ANY, patch_list,
valid_fields)
mock_check_if_bound.assert_called_once_with(mock.ANY, valid_fields)

View File

@ -68,7 +68,7 @@ class TestDeviceProfileController(v2_test.APITestV2):
mock_dp_name.return_value = dp
url = self.DP_URL + '/%s'
headers = self.headers
headers[base.Version.current_api_version] = 'accelerator 2.1'
headers[base.Version.current_api_version] = '2.1'
self.assertRaisesRegex(
webtest.app.AppError,
"Request not acceptable.*",
@ -82,7 +82,7 @@ class TestDeviceProfileController(v2_test.APITestV2):
mock_dp_name.return_value = dp
url = self.DP_URL + '/%s'
headers = self.headers
headers[base.Version.current_api_version] = 'accelerator 2.2'
headers[base.Version.current_api_version] = '2.2'
data = self.get_json(url % dp['name'],
headers=headers)
mock_dp_name.assert_called_once()

View File

@ -33,8 +33,7 @@ class TestMicroversions(api_base.BaseApiTest):
def test_wrong_major_version(self):
response = self.get_json(
'/v2',
headers={'OpenStack-API-Version': ' '.join([SERVICE_TYPE,
'10'])},
headers={'OpenStack-API-Version': '10'},
expect_errors=True, return_json=False)
self.assertEqual('application/json', response.content_type)
self.assertEqual(406, response.status_int)
@ -57,8 +56,7 @@ class TestMicroversions(api_base.BaseApiTest):
def test_new_client_new_api(self):
response = self.get_json(
'/v2',
headers={'OpenStack-API-Version': ' '.join([SERVICE_TYPE,
'2.0'])},
headers={'OpenStack-API-Version': '2.0'},
return_json=False)
self.assertEqual(response.headers[H_MIN_VER], MIN_VER)
self.assertEqual(response.headers[H_MAX_VER], MAX_VER)
@ -69,8 +67,7 @@ class TestMicroversions(api_base.BaseApiTest):
def test_latest_microversion(self):
response = self.get_json(
'/v2',
headers={'OpenStack-API-Version': ' '.join([SERVICE_TYPE,
'latest'])},
headers={'OpenStack-API-Version': 'latest'},
return_json=False)
self.assertEqual(response.headers[H_MIN_VER], MIN_VER)
self.assertEqual(response.headers[H_MAX_VER], MAX_VER)
@ -82,8 +79,7 @@ class TestMicroversions(api_base.BaseApiTest):
unsupported_version = str(float(MAX_VER) + 0.1)
response = self.get_json(
'/v2',
headers={'OpenStack-API-Version': ' '.join(
[SERVICE_TYPE, unsupported_version])},
headers={'OpenStack-API-Version': unsupported_version},
expect_errors=True)
self.assertEqual(406, response.status_int)
self.assertEqual(response.headers[H_MIN_VER], MIN_VER)