7a06040a76
Summary: `JailService` exposes jail API and knows how to start and stop binaries. Every test should be defined as python module with exposed `run` method. Script `master.py` is used for running tests and takes test module name as argument. Machine IP addresses are defined in environment variables. To run test locally use `local_runner` script. Reviewers: mislav.bradac, mferencevic, mtomic Reviewed By: mferencevic Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1065
66 lines
1.8 KiB
Python
Executable File
66 lines
1.8 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import importlib
|
|
import logging
|
|
import os
|
|
import signal
|
|
import subprocess
|
|
import time
|
|
import xmlrpc.client
|
|
from argparse import ArgumentParser
|
|
from jail_service import JailService
|
|
|
|
|
|
def parse_args():
|
|
"""
|
|
Parse command line arguments
|
|
"""
|
|
argp = ArgumentParser(description=__doc__)
|
|
argp.add_argument("--test-suite", default="raft",
|
|
help="Tests suite")
|
|
argp.add_argument("--test", default="example_test",
|
|
help="Test specification in python module")
|
|
argp.add_argument("--machines-num", default="4",
|
|
help="Number of machines in cluster")
|
|
return argp.parse_args()
|
|
|
|
|
|
def wait_for_server(interface, port, delay=0.1):
|
|
cmd = ["nc", "-z", "-w", "1", interface, port]
|
|
while subprocess.call(cmd) != 0:
|
|
time.sleep(0.01)
|
|
time.sleep(delay)
|
|
|
|
|
|
def main(args):
|
|
workers = {}
|
|
machine_ids = []
|
|
machines_num = int(args.machines_num)
|
|
# initialize workers
|
|
for i in range(machines_num):
|
|
id = i + 1
|
|
machine_id = "MACHINE{id}".format(id=id)
|
|
machine_ids.append(machine_id)
|
|
machine_interface = os.environ[machine_id]
|
|
machine_port = 8000 + id * 100
|
|
|
|
if (id == 1):
|
|
worker = JailService()
|
|
else:
|
|
host = "http://{interface}:{port}".format(
|
|
interface=machine_interface,
|
|
port=str(machine_port))
|
|
worker = xmlrpc.client.ServerProxy(host)
|
|
wait_for_server(machine_interface, str(machine_port))
|
|
|
|
workers[machine_id] = worker
|
|
|
|
# run test
|
|
test = importlib.import_module(
|
|
"{suite}.{test}".format(suite=args.test_suite, test=args.test))
|
|
test.run(machine_ids, workers)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
args = parse_args()
|
|
main(args)
|