Improve card fraud test startup
Reviewers: msantl Reviewed By: msantl Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1900
This commit is contained in:
parent
6cc8d8f5b1
commit
03feffc8cf
@ -1,6 +1,7 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
import subprocess
|
||||||
|
|
||||||
# to change the size of the cluster, just change this parameter
|
# to change the size of the cluster, just change this parameter
|
||||||
NUM_MACHINES = 3
|
NUM_MACHINES = 3
|
||||||
@ -16,6 +17,18 @@ MEMGRAPH_BINARY = "memgraph_distributed"
|
|||||||
CLIENT_BINARY = "tests/macro_benchmark/card_fraud_client"
|
CLIENT_BINARY = "tests/macro_benchmark/card_fraud_client"
|
||||||
BINARIES = [MEMGRAPH_BINARY, CLIENT_BINARY]
|
BINARIES = [MEMGRAPH_BINARY, CLIENT_BINARY]
|
||||||
|
|
||||||
|
# helpers
|
||||||
|
def wait_for_server(address, port, delay=0.2):
|
||||||
|
cmd = ["nc", "-z", "-w", "1", address, str(port)]
|
||||||
|
count = 0
|
||||||
|
while subprocess.call(cmd) != 0:
|
||||||
|
time.sleep(0.01)
|
||||||
|
if count > 20 / 0.01:
|
||||||
|
raise Exception("Could not wait for server {}:{} to "
|
||||||
|
"startup!".format(address, port))
|
||||||
|
count += 1
|
||||||
|
time.sleep(delay)
|
||||||
|
|
||||||
# wrappers
|
# wrappers
|
||||||
class WorkerWrapper:
|
class WorkerWrapper:
|
||||||
def __init__(self, address, worker):
|
def __init__(self, address, worker):
|
||||||
@ -60,8 +73,8 @@ class MgCluster:
|
|||||||
"--recovering-cluster-size", str(len(self._workers) + 1)
|
"--recovering-cluster-size", str(len(self._workers) + 1)
|
||||||
])
|
])
|
||||||
|
|
||||||
# sleep to allow the master to startup
|
# wait for the master to finish startup
|
||||||
time.sleep(5)
|
wait_for_server(self._master.get_address(), 10000)
|
||||||
|
|
||||||
# start memgraph workers
|
# start memgraph workers
|
||||||
for i, worker in enumerate(self._workers, start=1):
|
for i, worker in enumerate(self._workers, start=1):
|
||||||
@ -79,8 +92,12 @@ class MgCluster:
|
|||||||
"--rpc-num-server-workers", str(WORKERS),
|
"--rpc-num-server-workers", str(WORKERS),
|
||||||
])
|
])
|
||||||
|
|
||||||
# sleep to allow the workers to startup
|
# wait for the workers to finish startup
|
||||||
time.sleep(15)
|
for i, worker in enumerate(self._workers, start=1):
|
||||||
|
wait_for_server(worker.get_address(), 10000 + i)
|
||||||
|
|
||||||
|
# wait for the Bolt server to startup
|
||||||
|
wait_for_server(self._master.get_address(), 7687)
|
||||||
|
|
||||||
# store initial usage
|
# store initial usage
|
||||||
self._usage_start = [self._master.get_usage()]
|
self._usage_start = [self._master.get_usage()]
|
||||||
|
@ -41,7 +41,7 @@ quit()
|
|||||||
sleep 1
|
sleep 1
|
||||||
for i in `seq 2 $NUM_MACHINES`;
|
for i in `seq 2 $NUM_MACHINES`;
|
||||||
do
|
do
|
||||||
kill ${pids[$i]}
|
kill ${pids[$i]} || true
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user