Add code for sanity coverage

Change-Id: I112e92f982882e8f2a8b5f1cbd262f21270424c1
This commit is contained in:
Wen Shi 2018-04-26 19:57:37 -04:00 committed by Jack Ding
parent 22eb3d3f5b
commit 06e2aa8e3d
4 changed files with 56 additions and 0 deletions

View File

@ -30,11 +30,14 @@ from sysinv.openstack.common import service
from sysinv.common import service as sysinv_service
from sysinv.agent import manager
from sysinv import sanity_coverage
CONF = cfg.CONF
def main():
if sanity_coverage.flag_file_exists():
sanity_coverage.start()
# Parse config file and command line options, then start logging
sysinv_service.prepare_service(sys.argv)

View File

@ -26,6 +26,7 @@ from oslo_config import cfg
from oslo_log import log
from sysinv.common import service as sysinv_service
from sysinv.common import wsgi_service
from sysinv import sanity_coverage
LOG = log.getLogger(__name__)
CONF = cfg.CONF
@ -62,6 +63,8 @@ def sysinv_pxe():
def main():
if sanity_coverage.flag_file_exists():
sanity_coverage.start()
# Parse config file and command line options
sysinv_service.prepare_service(sys.argv)

View File

@ -30,11 +30,14 @@ from sysinv.openstack.common import service
from sysinv.common import service as sysinv_service
from sysinv.conductor import manager
from sysinv import sanity_coverage
CONF = cfg.CONF
def main():
if sanity_coverage.flag_file_exists():
sanity_coverage.start()
# Pase config file and command line options, then start logging
sysinv_service.prepare_service(sys.argv)

View File

@ -0,0 +1,47 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Copyright (c) 2018 Wind River Systems, Inc.
#
# The right to copy, distribute, modify, or otherwise make use
# of this software may be licensed only pursuant to the terms
# of an applicable Wind River license agreement.
#
from coverage import Coverage
import os
import signal
flag_file = "/etc/coverage/sysinv/flag"
cov = None
def signal_handler(signum, frame):
cov.stop()
cov.save()
def register_handler(signum=signal.SIGUSR1):
signal.signal(signum, signal_handler)
def flag_file_exists():
return os.path.isfile(flag_file)
def start():
global cov
cov = Coverage(config_file=flag_file)
register_handler()
cov.erase()
cov.start()