made merge Pythonic + fixed func and var identical name

This commit is contained in:
LukasMol 2022-04-26 15:16:50 +02:00
parent e44a906c4b
commit 1771869167
2 changed files with 15 additions and 14 deletions

View File

@ -83,7 +83,8 @@ logdir = {logdir}
"""
def __init__(self, basedir: str, fdbserver_binary: str, fdbmonitor_binary: str, fdbcli_binary: str,
process_number: int, create_config=True, port=None, ip_address=None, blob_granules_enabled: bool=False):
process_number: int, create_config=True, port=None, ip_address=None,
blob_granules_enabled: bool = False):
self.basedir = Path(basedir)
self.etc = self.basedir.joinpath('etc')
self.log = self.basedir.joinpath('log')
@ -102,12 +103,12 @@ logdir = {logdir}
self.ip_address = '127.0.0.1' if ip_address is None else ip_address
self.first_port = port
self.blob_granules_enabled = blob_granules_enabled
if (blob_granules_enabled):
if blob_granules_enabled:
# add extra process for blob_worker
self.process_number += 1
if self.first_port is not None:
self.last_used_port = int(self.first_port)-1
self.last_used_port = int(self.first_port) - 1
self.server_ports = [self.__next_port()
for _ in range(self.process_number)]
self.cluster_desc = random_secret_string(8)
@ -117,7 +118,7 @@ logdir = {logdir}
self.process = None
self.fdbmonitor_logfile = None
self.use_legacy_conf_syntax = False
if create_config:
self.create_cluster_file()
self.save_config()
@ -154,7 +155,7 @@ logdir = {logdir}
for port in self.server_ports:
f.write('[fdbserver.{server_port}]\n'.format(
server_port=port))
if (self.blob_granules_enabled):
if self.blob_granules_enabled:
# make last process a blob_worker class
f.write('class = blob_worker')
f.flush()
@ -216,7 +217,7 @@ logdir = {logdir}
db_config = 'configure new single {}'.format(storage)
if enable_tenants:
db_config += " tenant_mode=optional_experimental"
if (self.blob_granules_enabled):
if self.blob_granules_enabled:
db_config += " blob_granules_enabled:=1"
args = [self.fdbcli_binary, '-C',
self.cluster_file, '--exec', db_config]
@ -225,9 +226,9 @@ logdir = {logdir}
assert res.returncode == 0, "Create database failed with {}".format(
res.returncode)
if (self.blob_granules_enabled):
if self.blob_granules_enabled:
bg_args = [self.fdbcli_binary, '-C',
self.cluster_file, '--exec', 'blobrange start \\x00 \\xff']
self.cluster_file, '--exec', 'blobrange start \\x00 \\xff']
bg_res = subprocess.run(bg_args, env=self.process_env())
assert bg_res.returncode == 0, "Start blob granules failed with {}".format(bg_res.returncode)

View File

@ -34,7 +34,7 @@ MAX_DOWNLOAD_ATTEMPTS = 5
RUN_WITH_GDB = False
def make_executable(path):
def make_executable_path(path):
st = os.stat(path)
os.chmod(path, st.st_mode | stat.S_IEXEC)
@ -68,15 +68,15 @@ def random_sleep(min_sec, max_sec):
def compute_sha256(filename):
hash = hashlib.sha256()
hash_function = hashlib.sha256()
with open(filename, 'rb') as f:
while True:
data = f.read(128*1024)
if not data:
break
hash.update(data)
hash_function.update(data)
return hash.hexdigest()
return hash_function.hexdigest()
def read_to_str(filename):
@ -179,7 +179,7 @@ class UpgradeTest:
assert local_sha256.exists(), "{} does not exist".format(local_sha256)
expected_checksum = read_to_str(local_sha256)
actual_checkum = compute_sha256(local_file_tmp)
if (expected_checksum == actual_checkum):
if expected_checksum == actual_checkum:
print("Checksum OK")
break
print("Checksum mismatch. Expected: {} Actual: {}".format(
@ -192,7 +192,7 @@ class UpgradeTest:
os.remove(local_sha256)
if make_executable:
make_executable(local_file)
make_executable_path(local_file)
# Download all old binaries required for testing the specified upgrade path
def download_old_binaries(self):