Add tempest logging to bay_client and test_bay helper methods

This patch will add tempest logs to bay_client and
test_bay helper methods to provide ability in debugging
gate issues as well as ability to run analysis on logs

Closes-Bug: 1545124
Change-Id: Id5bda1a8776c29ec7cbe2366b3139358811b57c7
This commit is contained in:
dimtruck 2016-02-19 10:50:56 -06:00
parent f48946fb95
commit 8f5952fa6b
2 changed files with 18 additions and 11 deletions

View File

@ -10,6 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_log import log as logging
from tempest_lib import exceptions
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):
"""Encapsulates REST calls and maps JSON to/from models"""
LOG = logging.getLogger(__name__)
@classmethod
def bays_uri(cls, filters=None):
"""Construct bays uri with optional filters
@ -117,7 +120,9 @@ class BayClient(client.MagnumClient):
lambda: self.does_bay_exist(bay_id), 10, 3600)
except Exception:
# 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:
self.LOG.error('We will attempt to delete bays now.')
self.delete_bay(bay_id)
self.wait_for_bay_to_delete(bay_id)
raise
@ -131,29 +136,35 @@ class BayClient(client.MagnumClient):
resp, model = self.get_bay(bay_id)
if model.status in ['CREATED', 'CREATE_COMPLETE',
'ERROR', 'CREATE_FAILED']:
self.LOG.info('Bay %s succeeded.' % bay_id)
return True
else:
return False
except exceptions.NotFound:
self.LOG.warn('Bay %s is not found.' % bay_id)
return False
def does_bay_exist(self, bay_id):
try:
resp, model = self.get_bay(bay_id)
if model.status in ['CREATED', 'CREATE_COMPLETE']:
self.LOG.info('Bay %s is created.' % bay_id)
return True
elif model.status in ['ERROR', 'CREATE_FAILED']:
self.LOG.error('Bay %s is in fail state.' % bay_id)
raise exceptions.ServerFault(
"Got into an error condition: %s for %s" %
(model.status, bay_id))
else:
return False
except exceptions.NotFound:
self.LOG.warn('Bay %s is not found.' % bay_id)
return False
def does_bay_not_exist(self, bay_id):
try:
self.get_bay(bay_id)
except exceptions.NotFound:
self.LOG.warn('Bay %s is not found.' % bay_id)
return True
return False

View File

@ -76,17 +76,19 @@ class BayTest(base.BaseMagnumTest):
super(BayTest, self).tearDown()
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)
return resp, model
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)
return resp, 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)
self.LOG.info('Response: %s' % resp)
self.LOG.info('Model: %s ' % model)
self.LOG.debug('Response: %s' % resp)
self.assertEqual(resp.status, 201)
self.assertIsNotNone(model.uuid)
self.assertIsNone(model.status)
@ -97,16 +99,12 @@ class BayTest(base.BaseMagnumTest):
return resp, model
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)
self.assertEqual(resp.status, 204)
self.bay_client.wait_for_bay_to_delete(bay_id)
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
# they time out on the gate (2 hours not enough)
@testtools.testcase.attr('positive')
@ -181,8 +179,7 @@ class BayTest(base.BaseMagnumTest):
# test ca show
resp, model = self.cert_client.get_cert(
bay_model.uuid)
self.LOG.info("cert resp: %s" % resp)
self.LOG.info("cert model: %s" % model)
self.LOG.debug("cert resp: %s" % resp)
self.assertEqual(resp.status, 200)
self.assertEqual(model.bay_uuid, bay_model.uuid)
self.assertIsNotNone(model.pem)
@ -192,8 +189,7 @@ class BayTest(base.BaseMagnumTest):
# test ca sign
model = datagen.cert_data(bay_uuid=bay_model.uuid)
resp, model = self.cert_client.post_cert(model)
self.LOG.info("cert resp: %s" % resp)
self.LOG.info("cert model: %s" % model)
self.LOG.debug("cert resp: %s" % resp)
self.assertEqual(resp.status, 201)
self.assertEqual(model.bay_uuid, bay_model.uuid)
self.assertIsNotNone(model.pem)