Add tests to verify behavior on '' in self link

placement is adding a self link of '' to satisfy version discovery. Put
in a test to verify that we work properly with this. While we're in
there, add a quick test to show microversion discovery too.

Change-Id: I28e1b0ce6d372fc1e5aef335597b6db6e3b49660
This commit is contained in:
Monty Taylor 2018-06-13 11:16:11 -05:00
parent 07d3828860
commit 90396f4d35
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594
5 changed files with 90 additions and 0 deletions

View File

@ -468,6 +468,12 @@ class TestCase(base.TestCase):
uri=compute_discovery_url,
text=open(discovery_fixture, 'r').read())
def get_placement_discovery_mock_dict(self):
discovery_fixture = os.path.join(
self.fixtures_directory, "placement.json")
return dict(method='GET', uri="https://placement.example.com/",
text=open(discovery_fixture, 'r').read())
def get_designate_discovery_mock_dict(self):
discovery_fixture = os.path.join(
self.fixtures_directory, "dns.json")
@ -500,6 +506,10 @@ class TestCase(base.TestCase):
self.get_glance_discovery_mock_dict(
image_version_json, image_discovery_url)])
def use_placement(self):
self.__do_register_uris([
self.get_placement_discovery_mock_dict()])
def use_designate(self):
# NOTE(slaweq): This method is only meant to be used in "setUp"
# where the ordering of the url being registered is tightly controlled

View File

@ -113,6 +113,20 @@
"type": "object-store",
"name": "swift"
},
{
"endpoints_links": [],
"endpoints": [
{
"adminURL": "https://placement.example.com",
"region": "RegionOne",
"publicURL": "https://placement.example.com",
"internalURL": "https://placement.example.com",
"id": "652f0612744042bfbb8a8bb2c777a16e"
}
],
"type": "placement",
"name": "placement"
},
{
"endpoints_links": [],
"endpoints": [

View File

@ -136,6 +136,19 @@
"name": "heat",
"type": "orchestration"
},
{
"endpoints": [
{
"id": "10c76ffd2b744a67950ed1365190d353",
"interface": "public",
"region": "RegionOne",
"url": "https://placement.example.com"
}
],
"endpoints_links": [],
"name": "placement",
"type": "placement"
},
{
"endpoints": [
{

View File

@ -0,0 +1,11 @@
{
"versions": [
{
"id": "v1.0",
"links": [{"href": "", "rel": "self"}],
"max_version": "1.17",
"min_version": "1.0",
"status": "CURRENT"
}
]
}

View File

@ -0,0 +1,42 @@
# Copyright (c) 2018 Red Hat, Inc.
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from openstack.tests.unit import base
class TestPlacementRest(base.TestCase):
def setUp(self):
super(TestPlacementRest, self).setUp()
self.use_placement()
def test_discovery(self):
self.register_uris([
dict(method='GET',
uri=self.get_mock_url(
'placement', 'public', append=['allocation_candidates']),
json={})
])
rs = self.cloud.placement.get('/allocation_candidates')
self.assertEqual(200, rs.status_code)
self.assertEqual(
'https://placement.example.com/allocation_candidates',
rs.url)
self.assert_calls()
def test_microversion_discovery(self):
self.assertEqual(
(1, 17),
self.cloud.placement.get_endpoint_data().max_microversion)
self.assert_calls()