Merge "Change logging in stress test"

This commit is contained in:
Jenkins 2013-08-08 18:15:06 +00:00 committed by Gerrit Code Review
commit a1604b90e3
7 changed files with 43 additions and 57 deletions

View File

@ -1,5 +1,5 @@
[loggers]
keys=root,tempest
keys=root,tempest,tempest_stress
[handlers]
keys=file,syslog,devel
@ -16,6 +16,11 @@ level=DEBUG
handlers=file
qualname=tempest
[logger_tempest_stress]
level=INFO
handlers=file,devel
qualname=tempest.stress
[handler_file]
class=FileHandler
level=DEBUG

View File

@ -10,6 +10,8 @@ log_file = tempest.log
# lock/semaphore base directory
lock_path=/tmp
default_log_levels=tempest.stress=INFO,amqplib=WARN,sqlalchemy=WARN,boto=WARN,suds=INFO,keystone=INFO,eventlet.wsgi.server=WARN
[identity]
# This section contains configuration options that a variety of Tempest
# test clients use when authenticating with different user/tenant

View File

@ -23,7 +23,8 @@ location of the log files:
target_controller = "hostname or ip of controller node (for nova-manage)
log_check_interval = "time between checking logs for errors (default 60s)"
To activate logging on your console please make sure that you activate `use_stderr`
in tempest.conf or use the default `logging.conf.sample` file.
Running the sample test
-----------------------

View File

@ -17,13 +17,16 @@
# limitations under the License.
from tempest import clients
from tempest.openstack.common import log as logging
LOG = logging.getLogger(__name__)
def cleanup(logger):
def cleanup():
admin_manager = clients.AdminManager()
_, body = admin_manager.servers_client.list_servers({"all_tenants": True})
logger.debug("Cleanup::remove %s servers" % len(body['servers']))
LOG.info("Cleanup::remove %s servers" % len(body['servers']))
for s in body['servers']:
try:
admin_manager.servers_client.delete_server(s['id'])
@ -37,7 +40,7 @@ def cleanup(logger):
pass
_, keypairs = admin_manager.keypairs_client.list_keypairs()
logger.debug("Cleanup::remove %s keypairs" % len(keypairs))
LOG.info("Cleanup::remove %s keypairs" % len(keypairs))
for k in keypairs:
try:
admin_manager.keypairs_client.delete_keypair(k['name'])
@ -45,7 +48,7 @@ def cleanup(logger):
pass
_, floating_ips = admin_manager.floating_ips_client.list_floating_ips()
logger.debug("Cleanup::remove %s floating ips" % len(floating_ips))
LOG.info("Cleanup::remove %s floating ips" % len(floating_ips))
for f in floating_ips:
try:
admin_manager.floating_ips_client.delete_floating_ip(f['id'])
@ -53,13 +56,13 @@ def cleanup(logger):
pass
_, users = admin_manager.identity_client.get_users()
logger.debug("Cleanup::remove %s users" % len(users))
LOG.info("Cleanup::remove %s users" % len(users))
for user in users:
if user['name'].startswith("stress_user"):
admin_manager.identity_client.delete_user(user['id'])
_, tenants = admin_manager.identity_client.list_tenants()
logger.debug("Cleanup::remove %s tenants" % len(tenants))
LOG.info("Cleanup::remove %s tenants" % len(tenants))
for tenant in tenants:
if tenant['name'].startswith("stress_tenant"):
admin_manager.identity_client.delete_tenant(tenant['id'])
@ -69,7 +72,7 @@ def cleanup(logger):
_, snaps = admin_manager.snapshots_client.\
list_snapshots({"all_tenants": True})
logger.debug("Cleanup::remove %s snapshots" % len(snaps))
LOG.info("Cleanup::remove %s snapshots" % len(snaps))
for v in snaps:
try:
admin_manager.snapshots_client.\
@ -85,7 +88,7 @@ def cleanup(logger):
pass
_, vols = admin_manager.volumes_client.list_volumes({"all_tenants": True})
logger.debug("Cleanup::remove %s volumes" % len(vols))
LOG.info("Cleanup::remove %s volumes" % len(vols))
for v in vols:
try:
admin_manager.volumes_client.\

View File

@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
import multiprocessing
import signal
import time
@ -22,30 +21,12 @@ from tempest.common import ssh
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest.openstack.common import importutils
from tempest.openstack.common import log as logging
from tempest.stress import cleanup
admin_manager = clients.AdminManager()
# setup logging to file
logging.basicConfig(
format='%(asctime)s %(process)d %(name)-20s %(levelname)-8s %(message)s',
datefmt='%m-%d %H:%M:%S',
filename="stress.debug.log",
filemode="w",
level=logging.DEBUG,
)
# define a Handler which writes INFO messages or higher to the sys.stdout
_console = logging.StreamHandler()
_console.setLevel(logging.INFO)
# set a format which is simpler for console use
format_str = '%(asctime)s %(process)d %(name)-20s: %(levelname)-8s %(message)s'
_formatter = logging.Formatter(format_str)
# tell the handler to use this format
_console.setFormatter(_formatter)
# add the handler to the root logger
logger = logging.getLogger('tempest.stress')
logger.addHandler(_console)
LOG = logging.getLogger(__name__)
processes = []
@ -90,7 +71,7 @@ def _error_in_logs(logfiles, nodes):
if not errors:
return None
if len(errors) > 0:
logger.error('%s: %s' % (node, errors))
LOG.error('%s: %s' % (node, errors))
return errors
return None
@ -147,13 +128,13 @@ def stress_openstack(tests, duration, max_runs=None, stop_on_error=False):
tenant_name=tenant_name)
test_obj = importutils.import_class(test['action'])
test_run = test_obj(manager, logger, max_runs, stop_on_error)
test_run = test_obj(manager, max_runs, stop_on_error)
kwargs = test.get('kwargs', {})
test_run.setUp(**dict(kwargs.iteritems()))
logger.debug("calling Target Object %s" %
test_run.__class__.__name__)
LOG.debug("calling Target Object %s" %
test_run.__class__.__name__)
mp_manager = multiprocessing.Manager()
shared_statistic = mp_manager.dict()
@ -208,24 +189,24 @@ def stress_openstack(tests, duration, max_runs=None, stop_on_error=False):
sum_fails = 0
sum_runs = 0
logger.info("Statistics (per process):")
LOG.info("Statistics (per process):")
for process in processes:
if process['statistic']['fails'] > 0:
had_errors = True
sum_runs += process['statistic']['runs']
sum_fails += process['statistic']['fails']
logger.info(" Process %d (%s): Run %d actions (%d failed)" %
(process['p_number'],
process['action'],
process['statistic']['runs'],
LOG.info(" Process %d (%s): Run %d actions (%d failed)" %
(process['p_number'],
process['action'],
process['statistic']['runs'],
process['statistic']['fails']))
logger.info("Summary:")
logger.info("Run %d actions (%d failed)" %
(sum_runs, sum_fails))
LOG.info("Summary:")
LOG.info("Run %d actions (%d failed)" %
(sum_runs, sum_fails))
if not had_errors:
logger.info("cleaning up")
cleanup.cleanup(logger)
LOG.info("cleaning up")
cleanup.cleanup()
if had_errors:
return 1
else:

View File

@ -17,12 +17,15 @@
import signal
import sys
from tempest.openstack.common import log as logging
class StressAction(object):
def __init__(self, manager, logger, max_runs=None, stop_on_error=False):
def __init__(self, manager, max_runs=None, stop_on_error=False):
full_cname = self.__module__ + "." + self.__class__.__name__
self.logger = logging.getLogger(full_cname)
self.manager = manager
self.logger = logger
self.max_runs = max_runs
self.stop_on_error = stop_on_error

View File

@ -14,15 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
from tempest.stress import cleanup
_console = logging.StreamHandler()
_console.setLevel(logging.DEBUG)
# add the handler to the root logger
logger = logging.getLogger('tempest.stress.cleanup')
logger.addHandler(logging.StreamHandler())
logger.setLevel(logging.DEBUG)
cleanup.cleanup(logger)
cleanup.cleanup()