Merge "Add tempest logging to bay_client and test_bay helper methods"
This commit is contained in:
commit
70ed1700d3
@ -10,6 +10,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from oslo_log import log as logging
|
||||||
from tempest_lib import exceptions
|
from tempest_lib import exceptions
|
||||||
|
|
||||||
from magnum.tests.functional.api.v1.models import bay_model
|
from magnum.tests.functional.api.v1.models import bay_model
|
||||||
@ -20,6 +21,8 @@ from magnum.tests.functional.common import utils
|
|||||||
class BayClient(client.MagnumClient):
|
class BayClient(client.MagnumClient):
|
||||||
"""Encapsulates REST calls and maps JSON to/from models"""
|
"""Encapsulates REST calls and maps JSON to/from models"""
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def bays_uri(cls, filters=None):
|
def bays_uri(cls, filters=None):
|
||||||
"""Construct bays uri with optional filters
|
"""Construct bays uri with optional filters
|
||||||
@ -117,7 +120,9 @@ class BayClient(client.MagnumClient):
|
|||||||
lambda: self.does_bay_exist(bay_id), 10, 3600)
|
lambda: self.does_bay_exist(bay_id), 10, 3600)
|
||||||
except Exception:
|
except Exception:
|
||||||
# In error state. Clean up the bay id if desired
|
# In error state. Clean up the bay id if desired
|
||||||
|
self.LOG.error('Bay %s entered an exception state.' % bay_id)
|
||||||
if delete_on_error:
|
if delete_on_error:
|
||||||
|
self.LOG.error('We will attempt to delete bays now.')
|
||||||
self.delete_bay(bay_id)
|
self.delete_bay(bay_id)
|
||||||
self.wait_for_bay_to_delete(bay_id)
|
self.wait_for_bay_to_delete(bay_id)
|
||||||
raise
|
raise
|
||||||
@ -131,29 +136,35 @@ class BayClient(client.MagnumClient):
|
|||||||
resp, model = self.get_bay(bay_id)
|
resp, model = self.get_bay(bay_id)
|
||||||
if model.status in ['CREATED', 'CREATE_COMPLETE',
|
if model.status in ['CREATED', 'CREATE_COMPLETE',
|
||||||
'ERROR', 'CREATE_FAILED']:
|
'ERROR', 'CREATE_FAILED']:
|
||||||
|
self.LOG.info('Bay %s succeeded.' % bay_id)
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
except exceptions.NotFound:
|
except exceptions.NotFound:
|
||||||
|
self.LOG.warn('Bay %s is not found.' % bay_id)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def does_bay_exist(self, bay_id):
|
def does_bay_exist(self, bay_id):
|
||||||
try:
|
try:
|
||||||
resp, model = self.get_bay(bay_id)
|
resp, model = self.get_bay(bay_id)
|
||||||
if model.status in ['CREATED', 'CREATE_COMPLETE']:
|
if model.status in ['CREATED', 'CREATE_COMPLETE']:
|
||||||
|
self.LOG.info('Bay %s is created.' % bay_id)
|
||||||
return True
|
return True
|
||||||
elif model.status in ['ERROR', 'CREATE_FAILED']:
|
elif model.status in ['ERROR', 'CREATE_FAILED']:
|
||||||
|
self.LOG.error('Bay %s is in fail state.' % bay_id)
|
||||||
raise exceptions.ServerFault(
|
raise exceptions.ServerFault(
|
||||||
"Got into an error condition: %s for %s" %
|
"Got into an error condition: %s for %s" %
|
||||||
(model.status, bay_id))
|
(model.status, bay_id))
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
except exceptions.NotFound:
|
except exceptions.NotFound:
|
||||||
|
self.LOG.warn('Bay %s is not found.' % bay_id)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def does_bay_not_exist(self, bay_id):
|
def does_bay_not_exist(self, bay_id):
|
||||||
try:
|
try:
|
||||||
self.get_bay(bay_id)
|
self.get_bay(bay_id)
|
||||||
except exceptions.NotFound:
|
except exceptions.NotFound:
|
||||||
|
self.LOG.warn('Bay %s is not found.' % bay_id)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -76,17 +76,19 @@ class BayTest(base.BaseMagnumTest):
|
|||||||
super(BayTest, self).tearDown()
|
super(BayTest, self).tearDown()
|
||||||
|
|
||||||
def _create_baymodel(self, baymodel_model):
|
def _create_baymodel(self, baymodel_model):
|
||||||
|
self.LOG.debug('We will create a baymodel for %s' % baymodel_model)
|
||||||
resp, model = self.baymodel_client.post_baymodel(baymodel_model)
|
resp, model = self.baymodel_client.post_baymodel(baymodel_model)
|
||||||
return resp, model
|
return resp, model
|
||||||
|
|
||||||
def _delete_baymodel(self, baymodel_id):
|
def _delete_baymodel(self, baymodel_id):
|
||||||
|
self.LOG.debug('We will delete a baymodel for %s' % baymodel_id)
|
||||||
resp, model = self.baymodel_client.delete_baymodel(baymodel_id)
|
resp, model = self.baymodel_client.delete_baymodel(baymodel_id)
|
||||||
return resp, model
|
return resp, model
|
||||||
|
|
||||||
def _create_bay(self, bay_model):
|
def _create_bay(self, bay_model):
|
||||||
|
self.LOG.debug('We will create bay for %s' % bay_model)
|
||||||
resp, model = self.bay_client.post_bay(bay_model)
|
resp, model = self.bay_client.post_bay(bay_model)
|
||||||
self.LOG.info('Response: %s' % resp)
|
self.LOG.debug('Response: %s' % resp)
|
||||||
self.LOG.info('Model: %s ' % model)
|
|
||||||
self.assertEqual(resp.status, 201)
|
self.assertEqual(resp.status, 201)
|
||||||
self.assertIsNotNone(model.uuid)
|
self.assertIsNotNone(model.uuid)
|
||||||
self.assertIsNone(model.status)
|
self.assertIsNone(model.status)
|
||||||
@ -97,16 +99,12 @@ class BayTest(base.BaseMagnumTest):
|
|||||||
return resp, model
|
return resp, model
|
||||||
|
|
||||||
def _delete_bay(self, bay_id):
|
def _delete_bay(self, bay_id):
|
||||||
|
self.LOG.debug('We will delete a bay for %s' % bay_id)
|
||||||
resp, model = self.bay_client.delete_bay(bay_id)
|
resp, model = self.bay_client.delete_bay(bay_id)
|
||||||
self.assertEqual(resp.status, 204)
|
self.assertEqual(resp.status, 204)
|
||||||
self.bay_client.wait_for_bay_to_delete(bay_id)
|
self.bay_client.wait_for_bay_to_delete(bay_id)
|
||||||
return resp, model
|
return resp, model
|
||||||
|
|
||||||
def _get_bay_by_id(self, bay_id):
|
|
||||||
resp, model = self.bay_client.get_bay(bay_id)
|
|
||||||
self.assertEqual(resp.status, 404)
|
|
||||||
return resp, model
|
|
||||||
|
|
||||||
# (dimtruck) Combining all these tests in one because
|
# (dimtruck) Combining all these tests in one because
|
||||||
# they time out on the gate (2 hours not enough)
|
# they time out on the gate (2 hours not enough)
|
||||||
@testtools.testcase.attr('positive')
|
@testtools.testcase.attr('positive')
|
||||||
@ -181,8 +179,7 @@ class BayTest(base.BaseMagnumTest):
|
|||||||
# test ca show
|
# test ca show
|
||||||
resp, model = self.cert_client.get_cert(
|
resp, model = self.cert_client.get_cert(
|
||||||
bay_model.uuid)
|
bay_model.uuid)
|
||||||
self.LOG.info("cert resp: %s" % resp)
|
self.LOG.debug("cert resp: %s" % resp)
|
||||||
self.LOG.info("cert model: %s" % model)
|
|
||||||
self.assertEqual(resp.status, 200)
|
self.assertEqual(resp.status, 200)
|
||||||
self.assertEqual(model.bay_uuid, bay_model.uuid)
|
self.assertEqual(model.bay_uuid, bay_model.uuid)
|
||||||
self.assertIsNotNone(model.pem)
|
self.assertIsNotNone(model.pem)
|
||||||
@ -192,8 +189,7 @@ class BayTest(base.BaseMagnumTest):
|
|||||||
# test ca sign
|
# test ca sign
|
||||||
model = datagen.cert_data(bay_uuid=bay_model.uuid)
|
model = datagen.cert_data(bay_uuid=bay_model.uuid)
|
||||||
resp, model = self.cert_client.post_cert(model)
|
resp, model = self.cert_client.post_cert(model)
|
||||||
self.LOG.info("cert resp: %s" % resp)
|
self.LOG.debug("cert resp: %s" % resp)
|
||||||
self.LOG.info("cert model: %s" % model)
|
|
||||||
self.assertEqual(resp.status, 201)
|
self.assertEqual(resp.status, 201)
|
||||||
self.assertEqual(model.bay_uuid, bay_model.uuid)
|
self.assertEqual(model.bay_uuid, bay_model.uuid)
|
||||||
self.assertIsNotNone(model.pem)
|
self.assertIsNotNone(model.pem)
|
||||||
|
Loading…
Reference in New Issue
Block a user