]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
Revert "vstart_runner: rotate logs between testcases"
authorErnesto Puerta <37327689+epuertat@users.noreply.github.com>
Wed, 19 Aug 2020 08:36:05 +0000 (10:36 +0200)
committerErnesto Puerta <epuertat@redhat.com>
Wed, 19 Aug 2020 17:25:22 +0000 (19:25 +0200)
Fixes: https://tracker.ceph.com/issues/47032
Signed-off-by: Ernesto Puerta <epuertat@redhat.com>
qa/tasks/vstart_runner.py
src/vstart.sh

index 0e6262f50cfabc981c0105c34e6b8836457bc33f..7c59491f4a4f032b15dacd5f07192d21c908d4a5 100644 (file)
@@ -1200,22 +1200,11 @@ class LocalContext(object):
         if test_path:
             shutil.rmtree(test_path)
 
-
-class LogRotate():
-    def __init__(self):
-        self.conf_file_path = os.path.join(os.getcwd(), 'logrotate.conf')
-        self.state_file_path = os.path.join(os.getcwd(), 'logrotate.state')
-
-    def run_logrotate(self):
-        remote.run(args=['logrotate', '-f', self.conf_file_path, '-s',
-                         self.state_file_path, '--verbose'])
-
 def teardown_cluster():
     log.info('\ntearing down the cluster...')
     remote.run(args=[os.path.join(SRC_PREFIX, "stop.sh")], timeout=60)
     remote.run(args=['rm', '-rf', './dev', './out'])
 
-
 def clear_old_log():
     from os import stat
 
@@ -1232,7 +1221,6 @@ def clear_old_log():
         init_log()
         log.info('logging in a fresh file now...')
 
-
 def exec_test():
     # Parse arguments
     opt_interactive_on_error = False
@@ -1247,7 +1235,6 @@ def exec_test():
     opt_use_ns = False
     opt_brxnet= None
     opt_verbose = True
-    opt_rotate_log = True
 
     args = sys.argv[1:]
     flags = [a for a in args if a.startswith("-")]
@@ -1285,8 +1272,6 @@ def exec_test():
                 sys.exit(-1)
         elif '--no-verbose' == f:
             opt_verbose = False
-        elif f == '--dont-rotate':
-            opt_rotate_log = False
         else:
             log.error("Unknown option '{0}'".format(f))
             sys.exit(-1)
@@ -1396,39 +1381,19 @@ def exec_test():
         def __init__(self):
             self.buffer = ""
 
-        def _del_result_lines(self):
-            """
-            Don't let unittest.TextTestRunner print "Ran X tests in Ys",
-            vstart_runner.py will do it for itself since it runs tests in a
-            testsuite one by one.
-            """
-            self.buffer = re.sub('\n\n'+'-'*70+'\nran [0-9]* test in [0-9.]*s\n\n',
-                                 '', self.buffer, flags=re.I)
-
-            self.buffer = self.buffer.replace('OK\n', '')
-
         def write(self, data):
             self.buffer += data
-            if self.buffer.count("\n") > 5:
-                self._write()
-
-        def _write(self):
-            self._del_result_lines()
-            if self.buffer == '':
-                return
-
-            lines = self.buffer.split("\n")
-            for line in lines:
-                # sys.stderr.write(line + "\n")
-                log.info(line)
-            self.buffer = ''
+            if "\n" in self.buffer:
+                lines = self.buffer.split("\n")
+                for line in lines[:-1]:
+                    pass
+                    # sys.stderr.write(line + "\n")
+                    log.info(line)
+                self.buffer = lines[-1]
 
         def flush(self):
             pass
 
-        def __del__(self):
-            self._write()
-
     decorating_loader = DecoratingLoader({
         "ctx": ctx,
         "mounts": mounts,
@@ -1517,37 +1482,12 @@ def exec_test():
             else:
                 super(LoggingResult, self).addSkip(test, reason)
 
-
     # Execute!
-    overall_suite = load_tests(modules, loader.TestLoader())
-    no_of_tests_execed = 0
-    if opt_rotate_log:
-        logrotate = LogRotate()
-    started_at = datetime.datetime.utcnow()
-    for suite_, case in enumerate_methods(overall_suite):
-        # don't run logrotate beforehand since some ceph daemons might be
-        # down and pre/post-rotate scripts in logrotate.conf might fail.
-        if opt_rotate_log:
-            logrotate.run_logrotate()
-
-        result = unittest.TextTestRunner(stream=LogStream(),
-                                         resultclass=LoggingResult,
-                                         verbosity=2, failfast=True).run(case)
-
-        if not result.wasSuccessful():
-            break
-
-        no_of_tests_execed += 1
-
-    time_elapsed = (datetime.datetime.utcnow() - started_at).total_seconds()
-
-    if result.wasSuccessful():
-        log.info('')
-        log.info('-'*70)
-        log.info('Ran {} tests in {}s'.format(no_of_tests_execed,
-                                              time_elapsed))
-        log.info('')
-        log.info('OK')
+    result = unittest.TextTestRunner(
+        stream=LogStream(),
+        resultclass=LoggingResult,
+        verbosity=2,
+        failfast=True).run(overall_suite)
 
     CephFSMount.cleanup_stale_netnses_and_bridge(remote)
 
index b98bdd3d6eb543980c3bf64d97b5f5214e86e560..1e7b84917356d41b17d13c6dba02af231055e470 100755 (executable)
@@ -189,12 +189,9 @@ inc_osd_num=0
 
 msgr="21"
 
-rotate_logs=1
-
 usage="usage: $0 [option]... \nex: MON=3 OSD=1 MDS=1 MGR=1 RGW=1 NFS=1 $0 -n -d\n"
 usage=$usage"options:\n"
 usage=$usage"\t-d, --debug\n"
-usage=$usage"\t--dont-rotate: don't rotate the logs\n"
 usage=$usage"\t-s, --standby_mds: Generate standby-replay MDS for each active\n"
 usage=$usage"\t-l, --localhost: use localhost instead of hostname\n"
 usage=$usage"\t-i <ip>: bind to specific ip\n"
@@ -246,9 +243,6 @@ case $1 in
     -d | --debug )
         debug=1
         ;;
-    --dont-rotate)
-        rotate_logs=0
-        ;;
     -s | --standby_mds)
         standby=1
         ;;
@@ -725,40 +719,6 @@ $extra_conf
 EOF
 }
 
-write_logrotate_conf() {
-    out_dir=$(pwd)"/out/*.log"
-
-    cat << EOF
-$out_dir
-{
-    rotate 5
-    size 1G
-    copytruncate
-    compress
-    notifempty
-    missingok
-    sharedscripts
-    postrotate
-        # NOTE: assuring that the absence of one of the following processes
-        # won't abort the logrotate command.
-        killall -u $USER -q -1 ceph-mon ceph-mgr ceph-mds ceph-osd ceph-fuse radosgw rbd-mirror || echo ""
-    endscript
-}
-EOF
-}
-
-init_logrotate() {
-    logrotate_conf_path=$(pwd)"/logrotate.conf"
-    logrotate_state_path=$(pwd)"/logrotate.state"
-
-    if ! test -a $logrotate_conf_path; then
-        if test -a $logrotate_state_path; then
-            rm -f $logrotate_state_path
-        fi
-        write_logrotate_conf > $logrotate_conf_path
-    fi
-}
-
 start_mon() {
     local MONS=""
     local count=0
@@ -1597,7 +1557,3 @@ if [ -f "$STRAY_CONF_PATH" -a -n "$conf_fn" -a ! "$conf_fn" -ef "$STRAY_CONF_PAT
     echo "NOTE:"
     echo "    Remember to restart cluster after removing $STRAY_CONF_PATH"
 fi
-
-if [ $rotate_logs -ne 0 ]; then
-    init_logrotate
-fi