vstart_runner: name booleans for options differently

This achieves 2 things: makes it more understandable for the reader that
the boolean variable is an option and reads less like a method name.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
This commit is contained in:
Rishabh Dave 2019-09-25 12:05:55 +05:30
parent 254f705e27
commit dc21d04172

View File

@ -400,7 +400,7 @@ class LocalDaemon(object):
if line.find("ceph-{0} -i {1}".format(self.daemon_type, self.daemon_id)) != -1:
log.info("Found ps line for daemon: {0}".format(line))
return int(line.split()[0])
if log_ps_output:
if opt_log_ps_output:
log.info("No match for {0} {1}: {2}".format(
self.daemon_type, self.daemon_id, ps_txt))
else:
@ -1000,12 +1000,12 @@ class LocalContext(object):
def __del__(self):
shutil.rmtree(self.teuthology_config['test_path'])
def _teardown_cluster():
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():
def clear_old_log():
from os import stat
try:
@ -1023,34 +1023,34 @@ def _clear_old_log():
def exec_test():
# Parse arguments
interactive_on_error = False
create_cluster = False
create_cluster_only = False
ignore_missing_binaries = False
teardown_cluster = False
global log_ps_output
log_ps_output = False
clear_old_log = False
opt_interactive_on_error = False
opt_create_cluster = False
opt_create_cluster_only = False
opt_ignore_missing_binaries = False
opt_teardown_cluster = False
global opt_log_ps_output
opt_log_ps_output = False
opt_clear_old_log = False
args = sys.argv[1:]
flags = [a for a in args if a.startswith("-")]
modules = [a for a in args if not a.startswith("-")]
for f in flags:
if f == "--interactive":
interactive_on_error = True
opt_interactive_on_error = True
elif f == "--create":
create_cluster = True
opt_create_cluster = True
elif f == "--create-cluster-only":
create_cluster_only = True
opt_create_cluster_only = True
elif f == "--ignore-missing-binaries":
ignore_missing_binaries = True
opt_ignore_missing_binaries = True
elif f == '--teardown':
teardown_cluster = True
opt_teardown_cluster = True
elif f == '--log-ps-output':
log_ps_output = True
opt_log_ps_output = True
elif f == '--clear-old-log':
clear_old_log = True
_clear_old_log()
opt_clear_old_log = True
clear_old_log()
else:
log.error("Unknown option '{0}'".format(f))
sys.exit(-1)
@ -1060,7 +1060,7 @@ def exec_test():
require_binaries = ["ceph-dencoder", "cephfs-journal-tool", "cephfs-data-scan",
"cephfs-table-tool", "ceph-fuse", "rados"]
missing_binaries = [b for b in require_binaries if not os.path.exists(os.path.join(BIN_PREFIX, b))]
if missing_binaries and not ignore_missing_binaries:
if missing_binaries and not opt_ignore_missing_binaries:
log.error("Some ceph binaries missing, please build them: {0}".format(" ".join(missing_binaries)))
sys.exit(-1)
@ -1082,10 +1082,10 @@ def exec_test():
os.kill(pid, signal.SIGKILL)
# Fire up the Ceph cluster if the user requested it
if create_cluster or create_cluster_only:
if opt_create_cluster or opt_create_cluster_only:
log.info("Creating cluster with {0} MDS daemons".format(
max_required_mds))
_teardown_cluster()
teardown_cluster()
vstart_env = os.environ.copy()
vstart_env["FS"] = "0"
vstart_env["MDS"] = max_required_mds.__str__()
@ -1105,7 +1105,7 @@ def exec_test():
# definitely succeed
LocalCephCluster(LocalContext()).mon_manager.wait_for_all_osds_up(timeout=30)
if create_cluster_only:
if opt_create_cluster_only:
return
# List of client mounts, sufficient to run the selected tests
@ -1225,7 +1225,7 @@ def exec_test():
for s, method in victims:
s._tests.remove(method)
if interactive_on_error:
if opt_interactive_on_error:
result_class = InteractiveFailureResult
else:
result_class = unittest.TextTestResult
@ -1257,8 +1257,8 @@ def exec_test():
verbosity=2,
failfast=True).run(overall_suite)
if teardown_cluster:
_teardown_cluster()
if opt_teardown_cluster:
teardown_cluster()
if not result.wasSuccessful():
result.printErrors() # duplicate output at end for convenience