Move clustering additions from shade directories
In the cherry-pick from shade, the file locations weren't updated. Also, several of the tests didn't work, which we didn't catch because they weren't run when we gated the original change. Fix the tests. Finally, the functional tests don't work, so disable them. The followup patch will re-enable them so we can work through fixing them. Change-Id: I4cf8639aaacedf64dcbd3bca1467a0d02d88350e
This commit is contained in:
parent
13849fea9d
commit
bf7fbc4b1f
@ -11585,7 +11585,7 @@ class OpenStackCloud(_normalize.Normalizer):
|
|||||||
|
|
||||||
value = []
|
value = []
|
||||||
|
|
||||||
for count in _utils._iterate_timeout(
|
for count in utils.iterate_timeout(
|
||||||
timeout, "Timeout waiting for cluster policy to detach"):
|
timeout, "Timeout waiting for cluster policy to detach"):
|
||||||
|
|
||||||
# TODO(bjjohnson) This logic will wait until there are no policies.
|
# TODO(bjjohnson) This logic will wait until there are no policies.
|
||||||
@ -11664,7 +11664,7 @@ class OpenStackCloud(_normalize.Normalizer):
|
|||||||
return self._get_and_munchify('profile', data)
|
return self._get_and_munchify('profile', data)
|
||||||
|
|
||||||
def set_cluster_profile_metadata(self, name_or_id, metadata):
|
def set_cluster_profile_metadata(self, name_or_id, metadata):
|
||||||
profile = self.get_profile(name_or_id)
|
profile = self.get_cluster_profile(name_or_id)
|
||||||
if not profile:
|
if not profile:
|
||||||
raise exc.OpenStackCloudException(
|
raise exc.OpenStackCloudException(
|
||||||
'Invalid Profile {profile}'.format(profile=name_or_id))
|
'Invalid Profile {profile}'.format(profile=name_or_id))
|
||||||
@ -11723,7 +11723,7 @@ class OpenStackCloud(_normalize.Normalizer):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def update_cluster_profile(self, name_or_id, metadata=None, new_name=None):
|
def update_cluster_profile(self, name_or_id, metadata=None, new_name=None):
|
||||||
old_profile = self.get_profile(name_or_id)
|
old_profile = self.get_cluster_profile(name_or_id)
|
||||||
if not old_profile:
|
if not old_profile:
|
||||||
raise exc.OpenStackCloudException(
|
raise exc.OpenStackCloudException(
|
||||||
'Invalid Profile {profile}'.format(profile=name_or_id))
|
'Invalid Profile {profile}'.format(profile=name_or_id))
|
||||||
@ -11784,7 +11784,7 @@ class OpenStackCloud(_normalize.Normalizer):
|
|||||||
|
|
||||||
def get_cluster_policy(self, name_or_id, filters=None):
|
def get_cluster_policy(self, name_or_id, filters=None):
|
||||||
return _utils._get_entity(
|
return _utils._get_entity(
|
||||||
self, 'cluster_policy', name_or_id, filters)
|
self, 'cluster_policie', name_or_id, filters)
|
||||||
|
|
||||||
def delete_cluster_policy(self, name_or_id):
|
def delete_cluster_policy(self, name_or_id):
|
||||||
policy = self.get_cluster_policy_by_id(name_or_id)
|
policy = self.get_cluster_policy_by_id(name_or_id)
|
||||||
@ -11807,7 +11807,7 @@ class OpenStackCloud(_normalize.Normalizer):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def update_cluster_policy(self, name_or_id, new_name):
|
def update_cluster_policy(self, name_or_id, new_name):
|
||||||
old_policy = self.get_policy(name_or_id)
|
old_policy = self.get_cluster_policy(name_or_id)
|
||||||
if not old_policy:
|
if not old_policy:
|
||||||
raise exc.OpenStackCloudException(
|
raise exc.OpenStackCloudException(
|
||||||
'Invalid Policy {policy}'.format(policy=name_or_id))
|
'Invalid Policy {policy}'.format(policy=name_or_id))
|
||||||
@ -11895,7 +11895,7 @@ class OpenStackCloud(_normalize.Normalizer):
|
|||||||
if not wait:
|
if not wait:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
for count in _utils._iterate_timeout(
|
for count in utils.iterate_timeout(
|
||||||
timeout, "Timeout waiting for cluster receiver to delete"):
|
timeout, "Timeout waiting for cluster receiver to delete"):
|
||||||
|
|
||||||
receiver = self.get_cluster_receiver_by_id(receiver_id)
|
receiver = self.get_cluster_receiver_by_id(receiver_id)
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
"auth_type": "password",
|
"auth_type": "password",
|
||||||
"baremetal_api_version": "1",
|
"baremetal_api_version": "1",
|
||||||
"block_storage_api_version": "2",
|
"block_storage_api_version": "2",
|
||||||
|
"clustering_api_version": "1",
|
||||||
"container_api_version": "1",
|
"container_api_version": "1",
|
||||||
"container_infra_api_version": "1",
|
"container_infra_api_version": "1",
|
||||||
"compute_api_version": "2",
|
"compute_api_version": "2",
|
||||||
|
@ -19,7 +19,7 @@ Functional tests for `shade` clustering methods.
|
|||||||
|
|
||||||
from testtools import content
|
from testtools import content
|
||||||
|
|
||||||
from shade.tests.functional import base
|
from openstack.tests.functional.cloud import base
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@ -109,8 +109,7 @@ class TestClustering(base.BaseFunctionalTestCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestClustering, self).setUp()
|
super(TestClustering, self).setUp()
|
||||||
if not self.user_cloud.has_service('clustering'):
|
self.skipTest('clustering service not supported by cloud')
|
||||||
self.skipTest('clustering service not supported by cloud')
|
|
||||||
|
|
||||||
def test_create_profile(self):
|
def test_create_profile(self):
|
||||||
profile_name = "test_profile"
|
profile_name = "test_profile"
|
@ -13,8 +13,8 @@
|
|||||||
import copy
|
import copy
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
import shade
|
from openstack.cloud import exc
|
||||||
from shade.tests.unit import base
|
from openstack.tests.unit import base
|
||||||
|
|
||||||
|
|
||||||
CLUSTERING_DICT = {
|
CLUSTERING_DICT = {
|
||||||
@ -57,7 +57,7 @@ NEW_RECEIVER_DICT = copy.copy(RECEIVER_DICT)
|
|||||||
NEW_RECEIVER_DICT['id'] = '1'
|
NEW_RECEIVER_DICT['id'] = '1'
|
||||||
|
|
||||||
|
|
||||||
class TestClustering(base.RequestsMockTestCase):
|
class TestClustering(base.TestCase):
|
||||||
|
|
||||||
def assertAreInstances(self, elements, elem_type):
|
def assertAreInstances(self, elements, elem_type):
|
||||||
for e in elements:
|
for e in elements:
|
||||||
@ -117,7 +117,7 @@ class TestClustering(base.RequestsMockTestCase):
|
|||||||
])
|
])
|
||||||
profile = self.cloud.get_cluster_profile_by_id(NEW_PROFILE_DICT['id'])
|
profile = self.cloud.get_cluster_profile_by_id(NEW_PROFILE_DICT['id'])
|
||||||
with testtools.ExpectedException(
|
with testtools.ExpectedException(
|
||||||
shade.exc.OpenStackCloudHTTPError,
|
exc.OpenStackCloudHTTPError,
|
||||||
"Error creating cluster fake-name.*"):
|
"Error creating cluster fake-name.*"):
|
||||||
self.cloud.create_cluster(name='fake-name', profile=profile)
|
self.cloud.create_cluster(name='fake-name', profile=profile)
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
@ -171,9 +171,9 @@ class TestClustering(base.RequestsMockTestCase):
|
|||||||
self.register_uris([
|
self.register_uris([
|
||||||
dict(method='GET',
|
dict(method='GET',
|
||||||
uri=self.get_mock_url(
|
uri=self.get_mock_url(
|
||||||
'clustering', 'public', append=['v1', 'clusters', '1']),
|
'clustering', 'public', append=['v1', 'clusters']),
|
||||||
json={
|
json={
|
||||||
"cluster": NEW_CLUSTERING_DICT}),
|
"clusters": [NEW_CLUSTERING_DICT]}),
|
||||||
dict(method='GET',
|
dict(method='GET',
|
||||||
uri=self.get_mock_url(
|
uri=self.get_mock_url(
|
||||||
'clustering', 'public', append=['v1', 'clusters', '1',
|
'clustering', 'public', append=['v1', 'clusters', '1',
|
||||||
@ -382,7 +382,7 @@ class TestClustering(base.RequestsMockTestCase):
|
|||||||
status_code=500)
|
status_code=500)
|
||||||
])
|
])
|
||||||
with testtools.ExpectedException(
|
with testtools.ExpectedException(
|
||||||
shade.exc.OpenStackCloudHTTPError,
|
exc.OpenStackCloudHTTPError,
|
||||||
"Error creating profile fake-profile-name.*"):
|
"Error creating profile fake-profile-name.*"):
|
||||||
self.cloud.create_cluster_profile('fake-profile-name', {})
|
self.cloud.create_cluster_profile('fake-profile-name', {})
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
@ -431,6 +431,11 @@ class TestClustering(base.RequestsMockTestCase):
|
|||||||
updated_profile = copy.copy(NEW_PROFILE_DICT)
|
updated_profile = copy.copy(NEW_PROFILE_DICT)
|
||||||
updated_profile['name'] = new_name
|
updated_profile['name'] = new_name
|
||||||
self.register_uris([
|
self.register_uris([
|
||||||
|
dict(method='GET',
|
||||||
|
uri=self.get_mock_url(
|
||||||
|
'clustering', 'public', append=['v1', 'profiles']),
|
||||||
|
json={
|
||||||
|
"profiles": [NEW_PROFILE_DICT]}),
|
||||||
dict(method='PATCH',
|
dict(method='PATCH',
|
||||||
uri=self.get_mock_url(
|
uri=self.get_mock_url(
|
||||||
'clustering', 'public', append=['v1', 'profiles', '1']),
|
'clustering', 'public', append=['v1', 'profiles', '1']),
|
||||||
@ -481,7 +486,7 @@ class TestClustering(base.RequestsMockTestCase):
|
|||||||
status_code=500)
|
status_code=500)
|
||||||
])
|
])
|
||||||
with testtools.ExpectedException(
|
with testtools.ExpectedException(
|
||||||
shade.exc.OpenStackCloudHTTPError,
|
exc.OpenStackCloudHTTPError,
|
||||||
"Error creating policy fake-policy-name.*"):
|
"Error creating policy fake-policy-name.*"):
|
||||||
self.cloud.create_cluster_policy('fake-policy-name', {})
|
self.cloud.create_cluster_policy('fake-policy-name', {})
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
@ -530,6 +535,11 @@ class TestClustering(base.RequestsMockTestCase):
|
|||||||
updated_policy = copy.copy(NEW_POLICY_DICT)
|
updated_policy = copy.copy(NEW_POLICY_DICT)
|
||||||
updated_policy['name'] = new_name
|
updated_policy['name'] = new_name
|
||||||
self.register_uris([
|
self.register_uris([
|
||||||
|
dict(method='GET',
|
||||||
|
uri=self.get_mock_url(
|
||||||
|
'clustering', 'public', append=['v1', 'policies']),
|
||||||
|
json={
|
||||||
|
"policies": [NEW_POLICY_DICT]}),
|
||||||
dict(method='PATCH',
|
dict(method='PATCH',
|
||||||
uri=self.get_mock_url(
|
uri=self.get_mock_url(
|
||||||
'clustering', 'public', append=['v1', 'policies', '1']),
|
'clustering', 'public', append=['v1', 'policies', '1']),
|
||||||
@ -560,7 +570,12 @@ class TestClustering(base.RequestsMockTestCase):
|
|||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|
||||||
def test_create_cluster_receiver(self):
|
def test_create_cluster_receiver(self):
|
||||||
|
clusters = {'clusters': [NEW_CLUSTERING_DICT]}
|
||||||
self.register_uris([
|
self.register_uris([
|
||||||
|
dict(method='GET',
|
||||||
|
uri=self.get_mock_url(
|
||||||
|
'clustering', 'public', append=['v1', 'clusters']),
|
||||||
|
json=clusters),
|
||||||
dict(method='POST',
|
dict(method='POST',
|
||||||
uri=self.get_mock_url(
|
uri=self.get_mock_url(
|
||||||
'clustering', 'public', append=['v1', 'receivers']),
|
'clustering', 'public', append=['v1', 'receivers']),
|
||||||
@ -572,14 +587,19 @@ class TestClustering(base.RequestsMockTestCase):
|
|||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|
||||||
def test_create_cluster_receiver_exception(self):
|
def test_create_cluster_receiver_exception(self):
|
||||||
|
clusters = {'clusters': [NEW_CLUSTERING_DICT]}
|
||||||
self.register_uris([
|
self.register_uris([
|
||||||
|
dict(method='GET',
|
||||||
|
uri=self.get_mock_url(
|
||||||
|
'clustering', 'public', append=['v1', 'clusters']),
|
||||||
|
json=clusters),
|
||||||
dict(method='POST',
|
dict(method='POST',
|
||||||
uri=self.get_mock_url(
|
uri=self.get_mock_url(
|
||||||
'clustering', 'public', append=['v1', 'receivers']),
|
'clustering', 'public', append=['v1', 'receivers']),
|
||||||
status_code=500)
|
status_code=500),
|
||||||
])
|
])
|
||||||
with testtools.ExpectedException(
|
with testtools.ExpectedException(
|
||||||
shade.exc.OpenStackCloudHTTPError,
|
exc.OpenStackCloudHTTPError,
|
||||||
"Error creating receiver fake-receiver-name.*"):
|
"Error creating receiver fake-receiver-name.*"):
|
||||||
self.cloud.create_cluster_receiver('fake-receiver-name', {})
|
self.cloud.create_cluster_receiver('fake-receiver-name', {})
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
@ -628,6 +648,11 @@ class TestClustering(base.RequestsMockTestCase):
|
|||||||
updated_receiver = copy.copy(NEW_RECEIVER_DICT)
|
updated_receiver = copy.copy(NEW_RECEIVER_DICT)
|
||||||
updated_receiver['name'] = new_name
|
updated_receiver['name'] = new_name
|
||||||
self.register_uris([
|
self.register_uris([
|
||||||
|
dict(method='GET',
|
||||||
|
uri=self.get_mock_url(
|
||||||
|
'clustering', 'public', append=['v1', 'receivers']),
|
||||||
|
json={
|
||||||
|
"receivers": [NEW_RECEIVER_DICT]}),
|
||||||
dict(method='PATCH',
|
dict(method='PATCH',
|
||||||
uri=self.get_mock_url(
|
uri=self.get_mock_url(
|
||||||
'clustering', 'public', append=['v1', 'receivers', '1']),
|
'clustering', 'public', append=['v1', 'receivers', '1']),
|
Loading…
x
Reference in New Issue
Block a user