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
init_log()
log.info('logging in a fresh file now...')
-
def exec_test():
# Parse arguments
opt_interactive_on_error = False
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("-")]
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)
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,
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)
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"
-d | --debug )
debug=1
;;
- --dont-rotate)
- rotate_logs=0
- ;;
-s | --standby_mds)
standby=1
;;
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
echo "NOTE:"
echo " Remember to restart cluster after removing $STRAY_CONF_PATH"
fi
-
-if [ $rotate_logs -ne 0 ]; then
- init_logrotate
-fi