Skip to content

Commit

Permalink
Lint python code
Browse files Browse the repository at this point in the history
Signed-off-by: Ye Cao <[email protected]>
  • Loading branch information
dashanji committed Jul 2, 2024
1 parent 015255e commit c90d553
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions test/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ def make_metadata_settings(meta, endpoint, prefix):
]
raise ValueError("invalid argument: unknown metadata backend: '%s'" % meta)


def check_vineyard_for_ready(rpc_socket_port, timeout=60):
"""Check if vineyardd and internal etcd is ready."""
ready = False
Expand All @@ -210,15 +211,19 @@ def check_vineyard_for_ready(rpc_socket_port, timeout=60):
cmd = f"lsof -i :{rpc_socket_port}"

Check failure on line 211 in test/runner.py

View check run for this annotation

codefactor.io / CodeFactor

test/runner.py#L211

subprocess call with shell=True identified, security issue. (B602)
result = subprocess.run(cmd, shell=True, capture_output=True, text=True)

Check warning on line 212 in test/runner.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

test/runner.py#L212

'subprocess.run' used without explicitly defining the value for 'check'.
lines = result.stdout.strip().split('\n')
process_count = len(lines) - 1 if lines[0].startswith('COMMAND') else len(lines)
# If there are two processes listening on the rpc socket port, it means vineyardd and internal etcd are ready.
process_count = (
len(lines) - 1 if lines[0].startswith('COMMAND') else len(lines)
)
# If there are two processes listening on the rpc socket port,
# it means vineyardd and internal etcd are ready.
if process_count == 2:
ready = True
except Exception as e:
print(f"Error checking port {rpc_socket_port}: {e}", flush=True)
time.sleep(1)
return ready


@contextlib.contextmanager
def start_vineyardd(
metadata_settings,
Expand Down Expand Up @@ -270,6 +275,7 @@ def start_vineyardd(
time.sleep(1)
yield proc_context, rpc_socket_port


@contextlib.contextmanager
def start_multiple_vineyardd(
metadata_settings,
Expand Down Expand Up @@ -502,8 +508,8 @@ def run_vineyard_cpp_tests(meta, allocator, endpoints, tests):

def run_vineyard_spill_tests(meta, allocator, endpoints, tests):
meta_prefix = 'vineyard_test_%s' % time.time()
#client_port = find_port()
#endpoints = 'http://127.0.0.1:%d' % client_port
# client_port = find_port()
# endpoints = 'http://127.0.0.1:%d' % client_port
metadata_settings = make_metadata_settings(meta, endpoints, meta_prefix)
with start_vineyardd(
metadata_settings,
Expand Down

0 comments on commit c90d553

Please sign in to comment.