]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Drop teuthology-coverage command 1419/head
authorThomas Bechtold <tbechtold@suse.com>
Tue, 10 Mar 2020 18:56:11 +0000 (19:56 +0100)
committerThomas Bechtold <tbechtold@suse.com>
Tue, 10 Mar 2020 18:57:05 +0000 (19:57 +0100)
It seems to be unused and there was no change in the last 6 years. I
guess it's not used and not needed so drop it to remove the dead
code.

Signed-off-by: Thomas Bechtold <tbechtold@suse.com>
coverage/cov-analyze.sh [deleted file]
coverage/cov-init.sh [deleted file]
scripts/coverage.py [deleted file]
scripts/test/test_coverage.py [deleted file]
setup.py
teuthology/coverage.py [deleted file]
teuthology/test/test_coverage.py [deleted file]

diff --git a/coverage/cov-analyze.sh b/coverage/cov-analyze.sh
deleted file mode 100755 (executable)
index 9b309e2..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/bin/bash
-set -e
-
-usage () {
-       printf '%s: usage: %s -d WORKING_DIR -o OUT_BASENAME -t TEST_DIR\n' "$(basename "$0")" "$(basename "$0")" 1>&2
-       echo <<EOF
-WORKING_DIR should contain the source, .gcno, and initial lcov files (as created by cov-init.sh)
-TEST_DIR should contain the data archived from a teuthology test.
-
-Example:
-    mkdir coverage
-    ./cov-init.sh ~/teuthology_output/foo coverage
-    $0 -t ~/teuthology_output/foo -d coverage -o foo
-EOF
-       exit 1
-}
-
-OUTPUT_BASENAME=
-TEST_DIR=
-COV_DIR=
-
-while getopts  "d:o:t:" flag
-do
-       case $flag in
-               d) COV_DIR=$OPTARG;;
-               o) OUTPUT_BASENAME=$OPTARG;;
-               t) TEST_DIR=$OPTARG;;
-               *) usage;;
-       esac
-done
-
-shift $(($OPTIND - 1))
-
-echo $OUTPUT_BASENAME
-if [ -z "$OUTPUT_BASENAME" ] || [ -z "$TEST_DIR" ] || [ -z "$COV_DIR" ]; then
-       usage
-fi
-
-cp $COV_DIR/base.lcov "$COV_DIR/${OUTPUT_BASENAME}.lcov"
-
-for remote in `ls $TEST_DIR/remote`; do
-       echo "processing coverage for $remote..."
-       cp $TEST_DIR/remote/$remote/coverage/*.gcda $COV_DIR/ceph/src
-       cp $TEST_DIR/remote/$remote/coverage/_libs/*.gcda $COV_DIR/ceph/src/.libs
-       lcov -d $COV_DIR/ceph/src -c -o "$COV_DIR/${remote}_full.lcov"
-       lcov -r "$COV_DIR/${remote}_full.lcov" /usr/include\* -o "$COV_DIR/${remote}.lcov"
-       lcov -a "$COV_DIR/${remote}.lcov" -a "$COV_DIR/${OUTPUT_BASENAME}.lcov" -o "$COV_DIR/${OUTPUT_BASENAME}_tmp.lcov"
-       mv "$COV_DIR/${OUTPUT_BASENAME}_tmp.lcov" "$COV_DIR/${OUTPUT_BASENAME}.lcov"
-       rm "$COV_DIR/${remote}_full.lcov"
-       find $COV_DIR/ceph/src -name '*.gcda' -type f -delete
-done
diff --git a/coverage/cov-init.sh b/coverage/cov-init.sh
deleted file mode 100755 (executable)
index 2cb1ebd..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/bash
-set -e
-
-usage () {
-       printf '%s: usage: %s TEST_DIR OUTPUT_DIR CEPH_BUILD_TARBALL\n' "$(basename "$0")" "$(basename "$0")" 1>&2
-       exit 1
-}
-
-TEST_DIR=$1
-OUTPUT_DIR=$2
-CEPH_TARBALL=$3
-
-if [ -z "$TEST_DIR" ] || [ -z "$OUTPUT_DIR" ] || [ -z "$CEPH_TARBALL" ]; then
-       usage
-fi
-
-SHA1=`cat $TEST_DIR/ceph-sha1`
-
-mkdir -p $OUTPUT_DIR/ceph
-
-echo "Retrieving source and .gcno files..."
-wget -q -O- "https://github.com/ceph/ceph/tarball/$SHA1" | tar xzf - --strip-components=1 -C $OUTPUT_DIR/ceph
-tar zxf $CEPH_TARBALL -C $OUTPUT_DIR
-cp $OUTPUT_DIR/usr/local/lib/ceph/coverage/*.gcno $OUTPUT_DIR/ceph/src
-mkdir $OUTPUT_DIR/ceph/src/.libs
-cp $OUTPUT_DIR/usr/local/lib/ceph/coverage/.libs/*.gcno $OUTPUT_DIR/ceph/src/.libs
-rm -rf $OUTPUT_DIR/usr
-# leave ceph tarball around in case we need to inspect core files
-
-echo "Initializing lcov files..."
-lcov -d $OUTPUT_DIR/ceph/src -z
-lcov -d $OUTPUT_DIR/ceph/src -c -i -o $OUTPUT_DIR/base_full.lcov
-lcov -r $OUTPUT_DIR/base_full.lcov /usr/include\* -o $OUTPUT_DIR/base.lcov
-rm $OUTPUT_DIR/base_full.lcov
-echo "Done."
diff --git a/scripts/coverage.py b/scripts/coverage.py
deleted file mode 100644 (file)
index 5c61058..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-"""
-usage: teuthology-coverage [options] -o LCOV_OUTPUT <test_dir>
-
-Analyze the coverage of a suite of test runs, generating html output with
-lcov.
-
-options:
-  -h, --help            show this help message and exit
-  -o LCOV_OUTPUT, --lcov-output LCOV_OUTPUT
-                        the directory in which to store results
-  --html-output HTML_OUTPUT
-                        the directory in which to store html output
-  --cov-tools-dir COV_TOOLS_DIR
-                        the location of coverage scripts (cov-init and cov-
-                        analyze) [default: ../../coverage]
-  --skip-init           skip initialization (useful if a run stopped partway
-                        through)
-  -v, --verbose         be more verbose
-"""
-import docopt
-
-import teuthology.coverage
-
-
-def main():
-    args = docopt.docopt(__doc__)
-    teuthology.coverage.main(args)
diff --git a/scripts/test/test_coverage.py b/scripts/test/test_coverage.py
deleted file mode 100644 (file)
index c9ea2bb..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-from docopt import docopt
-
-from script import Script
-from scripts import coverage
-
-
-doc = coverage.__doc__
-
-
-class TestCoverage(Script):
-    script_name = 'teuthology-coverage'
-
-    def test_all_args(self):
-        args = docopt(doc, [
-            "--skip-init",
-            "--lcov-output=some/other/dir",
-            "--html-output=html/output/dir",
-            "--cov-tools-dir=cov/tools/dir",
-            "--verbose",
-            "some/test/dir"]
-        )
-        assert args["--skip-init"]
-        assert args["--lcov-output"] == "some/other/dir"
-        assert args["<test_dir>"] == "some/test/dir"
-        assert args["--html-output"] == "html/output/dir"
-        assert args["--cov-tools-dir"] == "cov/tools/dir"
-        assert args["--verbose"]
-
-    def test_missing_optional_args(self):
-        args = docopt(doc, [
-            "--lcov-output=some/other/dir",
-            "some/test/dir"]
-        )
-        assert not args['--html-output']
-        assert not args['--skip-init']
-        assert not args['--verbose']
-        assert args['--cov-tools-dir'] == "../../coverage"
index 86753f8a8093f9d3ce44dd43d5963948391dda51..c037da83c4f9b9d0af25004445e4dcba0fdf0825 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -120,7 +120,6 @@ setup(
             'teuthology-schedule = scripts.schedule:main',
             'teuthology-updatekeys = scripts.updatekeys:main',
             'teuthology-update-inventory = scripts.update_inventory:main',
-            'teuthology-coverage = scripts.coverage:main',
             'teuthology-results = scripts.results:main',
             'teuthology-report = scripts.report:main',
             'teuthology-kill = scripts.kill:main',
diff --git a/teuthology/coverage.py b/teuthology/coverage.py
deleted file mode 100644 (file)
index 63d33e3..0000000
+++ /dev/null
@@ -1,208 +0,0 @@
-from contextlib import closing
-import logging
-import os
-import shutil
-import subprocess
-import MySQLdb
-import yaml
-
-import teuthology
-from teuthology.config import config
-
-log = logging.getLogger(__name__)
-
-"""
-The coverage database can be created in mysql with:
-
-CREATE TABLE `coverage` (
-  `run_id` bigint(20) NOT NULL AUTO_INCREMENT,
-  `rev` char(40) NOT NULL,
-  `test` varchar(255) NOT NULL,
-  `suite` varchar(255) NOT NULL,
-  `lines` int(10) unsigned NOT NULL,
-  `line_cov` float unsigned NOT NULL,
-  `functions` int(10) unsigned NOT NULL,
-  `function_cov` float unsigned NOT NULL,
-  `branches` int(10) unsigned NOT NULL,
-  `branch_cov` float unsigned NOT NULL,
-  `run_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
-  PRIMARY KEY (`run_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8
-
-"""
-
-
-def connect_to_db():
-    db = MySQLdb.connect(
-        host=config.coverage_db_host,
-        user=config.coverage_db_user,
-        db=config.coverage_db_name,
-        passwd=config.coverage_db_password,
-    )
-    db.autocommit(False)
-    return db
-
-
-def store_coverage(test_coverage, rev, suite):
-    with closing(connect_to_db()) as db:
-        rows = []
-        for test, coverage in test_coverage.items():
-            flattened_cov = [item for sublist in coverage for item in sublist]
-            rows.append([rev, test, suite] + flattened_cov)
-        log.debug('inserting rows into db: %s', str(rows))
-        try:
-            cursor = db.cursor()
-            cursor.executemany(
-                'INSERT INTO `coverage`'
-                ' (`rev`, `test`, `suite`, `lines`, `line_cov`, `functions`,'
-                ' `function_cov`, `branches`, `branch_cov`)'
-                ' VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)',
-                rows)
-        except Exception:
-            log.exception('error updating database')
-            db.rollback()
-            raise
-        else:
-            db.commit()
-            log.info('added coverage to database')
-        finally:
-            cursor.close()
-
-
-def read_coverage(output):
-    log.debug('reading coverage from output: %s', output)
-    coverage = [None, None, None]
-    prefixes = ['  lines......: ', '  functions..: ', '  branches...: ']
-    for line in reversed(output.splitlines()):
-        for i, prefix in enumerate(prefixes):
-            if line.startswith(prefix):
-                if '%' in line:
-                    cov_num = int(line[line.find('(') + 1:line.find(' of')])
-                    cov_percent = float(line[len(prefix):line.find('%')])
-                    coverage[i] = (cov_num, cov_percent)
-                else:
-                    # may have no data for e.g. branches on the initial run
-                    coverage[i] = (None, None)
-                break
-        if None not in coverage:
-            break
-    return coverage
-
-
-def main(args):
-    if args["--verbose"]:
-        teuthology.log.setLevel(logging.DEBUG)
-
-    log = logging.getLogger(__name__)
-
-    log_path = os.path.join(args['<test_dir>'], 'coverage.log')
-    teuthology.setup_log_file(log_path)
-
-    try:
-        analyze(
-            args['<test_dir>'],
-            args['--cov-tools-dir'],
-            args['--lcov-output'],
-            args['--html-output'],
-            args['--skip-init']
-        )
-    except Exception:
-        log.exception('error generating coverage')
-        raise
-
-
-def analyze(test_dir, cov_tools_dir, lcov_output, html_output, skip_init):
-    tests = [
-        f for f in sorted(os.listdir(test_dir))
-        if not f.startswith('.')
-        and os.path.isdir(os.path.join(test_dir, f))
-        and os.path.exists(os.path.join(test_dir, f, 'summary.yaml'))
-        and os.path.exists(os.path.join(test_dir, f, 'ceph-sha1'))]
-
-    test_summaries = {}
-    for test in tests:
-        summary = {}
-        with open(os.path.join(test_dir, test, 'summary.yaml')) as f:
-            g = yaml.safe_load_all(f)
-            for new in g:
-                summary.update(new)
-
-        if summary['flavor'] != 'gcov':
-            log.debug('Skipping %s, since it does not include coverage', test)
-            continue
-        test_summaries[test] = summary
-
-    assert len(test_summaries) > 0
-
-    suite = os.path.basename(test_dir)
-
-    # only run cov-init once.
-    # this only works if all tests were run against the same version.
-    if not skip_init:
-        log.info('initializing coverage data...')
-        subprocess.check_call(
-            args=[
-                os.path.join(cov_tools_dir, 'cov-init.sh'),
-                os.path.join(test_dir, tests[0]),
-                lcov_output,
-                os.path.join(
-                    config.ceph_build_output_dir,
-                    '{suite}.tgz'.format(suite=suite),
-                ),
-            ])
-        shutil.copy(
-            os.path.join(lcov_output, 'base.lcov'),
-            os.path.join(lcov_output, 'total.lcov')
-        )
-
-    test_coverage = {}
-    for test, summary in test_summaries.items():
-        lcov_file = '{name}.lcov'.format(name=test)
-
-        log.info('analyzing coverage for %s', test)
-        proc = subprocess.Popen(
-            args=[
-                os.path.join(cov_tools_dir, 'cov-analyze.sh'),
-                '-t', os.path.join(test_dir, test),
-                '-d', lcov_output,
-                '-o', test,
-            ],
-            stdout=subprocess.PIPE,
-        )
-        output, _ = proc.communicate()
-        desc = summary.get('description', test)
-        test_coverage[desc] = read_coverage(output)
-
-        log.info('adding %s data to total', test)
-        proc = subprocess.Popen(
-            args=[
-                'lcov',
-                '-a', os.path.join(lcov_output, lcov_file),
-                '-a', os.path.join(lcov_output, 'total.lcov'),
-                '-o', os.path.join(lcov_output, 'total_tmp.lcov'),
-            ],
-            stdout=subprocess.PIPE,
-        )
-        output, _ = proc.communicate()
-
-        os.rename(
-            os.path.join(lcov_output, 'total_tmp.lcov'),
-            os.path.join(lcov_output, 'total.lcov')
-        )
-
-    coverage = read_coverage(output)
-    test_coverage['total for {suite}'.format(suite=suite)] = coverage
-    log.debug('total coverage is %s', str(coverage))
-
-    if html_output:
-        subprocess.check_call(
-            args=[
-                'genhtml',
-                '-s',
-                '-o', os.path.join(html_output, 'total'),
-                '-t', 'Total for {suite}'.format(suite=suite),
-                '--',
-                os.path.join(lcov_output, 'total.lcov'),
-            ])
-
-    store_coverage(test_coverage, summary['ceph-sha1'], suite)
diff --git a/teuthology/test/test_coverage.py b/teuthology/test/test_coverage.py
deleted file mode 100644 (file)
index 0da7268..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-from mock import patch
-
-from teuthology import coverage
-
-
-class TestCoverage(object):
-
-    @patch('teuthology.log.setLevel')
-    @patch('teuthology.setup_log_file')
-    @patch('teuthology.coverage.analyze')
-    def test_main(self, m_analyze, m_setup_log_file, m_setLevel):
-        args = {
-            "--skip-init": False,
-            "--lcov-output": "some/other/dir",
-            "--html-output": "html/output/dir",
-            "--cov-tools-dir": "cov/tools/dir",
-            "--verbose": True,
-            "<test_dir>": "some/test/dir",
-        }
-        coverage.main(args)
-        assert m_setLevel.called
-        m_setup_log_file.assert_called_with("some/test/dir/coverage.log")
-        m_analyze.assert_called_with(
-            "some/test/dir",
-            "cov/tools/dir",
-            "some/other/dir",
-            "html/output/dir",
-            False
-        )