summaryrefslogtreecommitdiff
path: root/test/end-to-end/with_remote_test_runner.py
diff options
context:
space:
mode:
authorAlberto Sartori <alberto.sartori@huawei.com>2023-04-20 13:01:38 +0200
committerAlberto Sartori <alberto.sartori@huawei.com>2023-04-21 09:42:15 +0200
commit70dffcedcbe6c399038adafd7c8b8555a6bfda26 (patch)
tree28f0f77b57f7ea84afe09be1d6911cfa980c8916 /test/end-to-end/with_remote_test_runner.py
parentf65776770fbd83a91095db2d346ae0ad3e0bbcef (diff)
downloadjustbuild-70dffcedcbe6c399038adafd7c8b8555a6bfda26.tar.gz
["test/end-to-end", "with remote"]: allow for the usage of a given remote endpoint
This can be useful, for example, to test if justbuild can successfully communicate with the specified remote execution service.
Diffstat (limited to 'test/end-to-end/with_remote_test_runner.py')
-rwxr-xr-xtest/end-to-end/with_remote_test_runner.py79
1 files changed, 50 insertions, 29 deletions
diff --git a/test/end-to-end/with_remote_test_runner.py b/test/end-to-end/with_remote_test_runner.py
index b5f71c5f..c685b2c5 100755
--- a/test/end-to-end/with_remote_test_runner.py
+++ b/test/end-to-end/with_remote_test_runner.py
@@ -38,6 +38,9 @@ def dump_results():
with open("stderr", "w") as f:
f.write("%s\n" % (stderr, ))
+def get_remote_execution_address(d):
+ return "%s:%d" % (d["interface"], int(d["port"]))
+
dump_results()
@@ -49,40 +52,57 @@ os.makedirs(WORK_DIR, exist_ok=True)
REMOTE_DIR = os.path.realpath("remote")
os.makedirs(REMOTE_DIR, exist_ok=True)
-REMOTE_INFO = os.path.join(REMOTE_DIR, "info.json")
REMOTE_LBR = os.path.join(REMOTE_DIR, "build-root")
-if os.path.exists(REMOTE_INFO):
- print(f"Warning: removing unexpected info file {REMOTE_INFO}")
- os.remove(REMOTE_INFO)
-
-remote_cmd = [
- "./just", "execute",
- "--info-file", REMOTE_INFO,
- "--local-build-root", REMOTE_LBR,
- "--log-limit", "6", "--plain-log",
-]
+REMOTE_EXECUTION_ADDRESS = ""
compatible = json.loads(sys.argv[1])
-if compatible:
- remote_cmd.append("--compatible")
+
+custom_remote = json.loads(sys.argv[2])
+
+if not custom_remote:
+ # start just execute as remote service
+ REMOTE_INFO = os.path.join(REMOTE_DIR, "info.json")
+
+ if os.path.exists(REMOTE_INFO):
+ print(f"Warning: removing unexpected info file {REMOTE_INFO}")
+ os.remove(REMOTE_INFO)
-remotestdout = open("remotestdout", "w")
-remotestderr = open("remotestderr", "w")
-remote_proc = subprocess.Popen(
- remote_cmd,
- stdout=remotestdout,
- stderr=remotestderr,
-)
+ remote_cmd = [
+ "./just", "execute",
+ "--info-file", REMOTE_INFO,
+ "--local-build-root", REMOTE_LBR,
+ "--log-limit", "6", "--plain-log",
+ ]
-while not os.path.exists(REMOTE_INFO):
- time.sleep(1)
+ if compatible:
+ remote_cmd.append("--compatible")
-with open(REMOTE_INFO) as f:
- info = json.load(f)
+ remotestdout = open("remotestdout", "w")
+ remotestderr = open("remotestderr", "w")
+ remote_proc = subprocess.Popen(
+ remote_cmd,
+ stdout=remotestdout,
+ stderr=remotestderr,
+ )
-REMOTE_EXECUTION_ADDRESS = "%s:%d" % (info["interface"], info["port"])
+ while not os.path.exists(REMOTE_INFO):
+ time.sleep(1)
+
+ with open(REMOTE_INFO) as f:
+ info = json.load(f)
+
+ REMOTE_EXECUTION_ADDRESS = get_remote_execution_address(info)
+else:
+ msg = "\nA custom remote service is used, please look at logs there.\n"
+ with open("remotestdout", "w") as f:
+ print(msg, file=f)
+ with open("remotestderr", "w") as f:
+ print(msg, file=f)
+
+ args = custom_remote.get("args",[])
+ REMOTE_EXECUTION_ADDRESS = " ".join((get_remote_execution_address(custom_remote), *args))
ENV = dict(os.environ,
TEST_TMPDIR=TEMP_DIR, TMPDIR=TEMP_DIR,
@@ -97,7 +117,6 @@ for k in ["TLS_CA_CERT", "TLS_CLIENT_CERT", "TLS_CLIENT_KEY"]:
if k in ENV:
del ENV[k]
-
time_start = time.time()
ret = subprocess.run(["sh", "../test.sh"],
cwd=WORK_DIR,
@@ -108,13 +127,15 @@ time_stop = time.time()
result = "PASS" if ret.returncode == 0 else "FAIL"
stdout = ret.stdout.decode("utf-8")
stderr = ret.stderr.decode("utf-8")
-remote_proc.terminate()
-rout, rerr = remote_proc.communicate()
+
+if not custom_remote:
+ remote_proc.terminate()
+ rout, rerr = remote_proc.communicate()
dump_results()
for f in sys.argv[2:]:
- keep_file = os.path.join(WORKDIR, f)
+ keep_file = os.path.join(WORK_DIR, f)
if not os.path.exists(keep_file):
open(keep_file, "a").close()