Merge "Move wait_for_qos_operations method to common.waiters"
commit
4db514cc01
|
@ -14,6 +14,7 @@
|
|||
|
||||
from tempest.api.volume import base
|
||||
from tempest.common.utils import data_utils as utils
|
||||
from tempest.common import waiters
|
||||
from tempest import test
|
||||
|
||||
|
||||
|
@ -119,7 +120,9 @@ class QosSpecsV2TestJSON(base.BaseVolumeAdminTest):
|
|||
self.admin_volume_qos_client.unset_qos_key(self.created_qos['id'],
|
||||
keys)
|
||||
operation = 'qos-key-unset'
|
||||
self.wait_for_qos_operations(self.created_qos['id'], operation, keys)
|
||||
waiters.wait_for_qos_operations(self.admin_volume_qos_client,
|
||||
self.created_qos['id'],
|
||||
operation, keys)
|
||||
body = self.admin_volume_qos_client.show_qos(
|
||||
self.created_qos['id'])['qos_specs']
|
||||
self.assertNotIn(keys[0], body['specs'])
|
||||
|
@ -153,8 +156,9 @@ class QosSpecsV2TestJSON(base.BaseVolumeAdminTest):
|
|||
self.admin_volume_qos_client.disassociate_qos(
|
||||
self.created_qos['id'], vol_type[0]['id'])
|
||||
operation = 'disassociate'
|
||||
self.wait_for_qos_operations(self.created_qos['id'],
|
||||
operation, vol_type[0]['id'])
|
||||
waiters.wait_for_qos_operations(self.admin_volume_qos_client,
|
||||
self.created_qos['id'], operation,
|
||||
vol_type[0]['id'])
|
||||
associations = self._test_get_association_qos()
|
||||
self.assertNotIn(vol_type[0]['id'], associations)
|
||||
|
||||
|
@ -162,7 +166,8 @@ class QosSpecsV2TestJSON(base.BaseVolumeAdminTest):
|
|||
self.admin_volume_qos_client.disassociate_all_qos(
|
||||
self.created_qos['id'])
|
||||
operation = 'disassociate-all'
|
||||
self.wait_for_qos_operations(self.created_qos['id'], operation)
|
||||
waiters.wait_for_qos_operations(self.admin_volume_qos_client,
|
||||
self.created_qos['id'], operation)
|
||||
associations = self._test_get_association_qos()
|
||||
self.assertEmpty(associations)
|
||||
|
||||
|
|
|
@ -13,15 +13,12 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import time
|
||||
|
||||
from tempest.common import compute
|
||||
from tempest.common.utils import data_utils
|
||||
from tempest.common import waiters
|
||||
from tempest import config
|
||||
from tempest import exceptions
|
||||
from tempest.lib.common.utils import test_utils
|
||||
from tempest.lib import exceptions as lib_exc
|
||||
import tempest.test
|
||||
|
||||
CONF = config.CONF
|
||||
|
@ -277,35 +274,3 @@ class BaseVolumeAdminTest(BaseVolumeTest):
|
|||
test_utils.call_and_ignore_notfound_exc(
|
||||
cls.admin_volume_types_client.wait_for_resource_deletion,
|
||||
vol_type)
|
||||
|
||||
def wait_for_qos_operations(self, qos_id, operation, args=None):
|
||||
"""Waits for a qos operations to be completed.
|
||||
|
||||
NOTE : operation value is required for wait_for_qos_operations()
|
||||
operation = 'qos-key' / 'disassociate' / 'disassociate-all'
|
||||
args = keys[] when operation = 'qos-key'
|
||||
args = volume-type-id disassociated when operation = 'disassociate'
|
||||
args = None when operation = 'disassociate-all'
|
||||
"""
|
||||
start_time = int(time.time())
|
||||
client = self.admin_volume_qos_client
|
||||
while True:
|
||||
if operation == 'qos-key-unset':
|
||||
body = client.show_qos(qos_id)['qos_specs']
|
||||
if not any(key in body['specs'] for key in args):
|
||||
return
|
||||
elif operation == 'disassociate':
|
||||
body = client.show_association_qos(qos_id)['qos_associations']
|
||||
if not any(args in body[i]['id'] for i in range(0, len(body))):
|
||||
return
|
||||
elif operation == 'disassociate-all':
|
||||
body = client.show_association_qos(qos_id)['qos_associations']
|
||||
if not body:
|
||||
return
|
||||
else:
|
||||
msg = (" operation value is either not defined or incorrect.")
|
||||
raise lib_exc.UnprocessableEntity(msg)
|
||||
|
||||
if int(time.time()) - start_time >= self.build_timeout:
|
||||
raise exceptions.TimeoutException
|
||||
time.sleep(self.build_interval)
|
||||
|
|
|
@ -258,3 +258,35 @@ def wait_for_bm_node_status(client, node_id, attr, status):
|
|||
if caller:
|
||||
message = '(%s) %s' % (caller, message)
|
||||
raise exceptions.TimeoutException(message)
|
||||
|
||||
|
||||
def wait_for_qos_operations(client, qos_id, operation, args=None):
|
||||
"""Waits for a qos operations to be completed.
|
||||
|
||||
NOTE : operation value is required for wait_for_qos_operations()
|
||||
operation = 'qos-key' / 'disassociate' / 'disassociate-all'
|
||||
args = keys[] when operation = 'qos-key'
|
||||
args = volume-type-id disassociated when operation = 'disassociate'
|
||||
args = None when operation = 'disassociate-all'
|
||||
"""
|
||||
start_time = int(time.time())
|
||||
while True:
|
||||
if operation == 'qos-key-unset':
|
||||
body = client.show_qos(qos_id)['qos_specs']
|
||||
if not any(key in body['specs'] for key in args):
|
||||
return
|
||||
elif operation == 'disassociate':
|
||||
body = client.show_association_qos(qos_id)['qos_associations']
|
||||
if not any(args in body[i]['id'] for i in range(0, len(body))):
|
||||
return
|
||||
elif operation == 'disassociate-all':
|
||||
body = client.show_association_qos(qos_id)['qos_associations']
|
||||
if not body:
|
||||
return
|
||||
else:
|
||||
msg = (" operation value is either not defined or incorrect.")
|
||||
raise lib_exc.UnprocessableEntity(msg)
|
||||
|
||||
if int(time.time()) - start_time >= client.build_timeout:
|
||||
raise exceptions.TimeoutException
|
||||
time.sleep(client.build_interval)
|
||||
|
|
Loading…
Reference in New Issue