Gabriel39 commented on code in PR #70693: URL: https://github.com/apache/doris/pull/70693#discussion_r4624310556
########## regression-test/suites/rpc_p0/private_rpc_tls_fixture.py: ########## @@ -0,0 +1,287 @@ +#!/usr/bin/env python3 +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +"""Own two disposable loopback clusters for the default private RPC regression.""" + +import argparse +import json +import os +from pathlib import Path +import random +import resource +import shutil +import signal +import socket +import ssl +import subprocess +import sys +import tempfile +import time + + +PORTS = { + "fe": {"http_port": 8030, "rpc_port": 9020, "query_port": 9030, + "edit_log_port": 9010, "arrow_flight_sql_port": 8835}, + "be": {"be_port": 9060, "webserver_port": 8040, "heartbeat_service_port": 9050, + "brpc_port": 8060, "arrow_flight_sql_port": 8815}, +} + + +def package_root(home): + for candidate in (Path(home) / "output", Path(home)): + if all((candidate / role / "bin" / ("start_" + role + ".sh")).is_file() + and (candidate / role / "lib" / ("doris-fe.jar" if role == "fe" else "doris_be")).is_file() + for role in PORTS): + return candidate.resolve() + raise RuntimeError("Private RPC TLS regression requires local FE and BE packages; " + "build them first or set privateRpcTlsPackageHome") + + +def reserve_ports(used): + for _ in range(100): + # Stay below Linux's default ephemeral range so startup traffic cannot claim our ports. + offset = random.SystemRandom().randrange(10000, 20000) + ports = {role: {key: value + offset for key, value in values.items()} + for role, values in PORTS.items()} + values = {port for part in ports.values() for port in part.values()} + if used.intersection(values): + continue + sockets = [] + try: + for port in values: + listener = socket.socket() + sockets.append(listener) + # Doris listeners bind wildcard addresses even when priority_networks is loopback. + listener.bind(("0.0.0.0", port)) + used.update(values) + return ports + except OSError: + pass + finally: + for listener in sockets: + listener.close() + raise RuntimeError("No unused loopback port range for private RPC TLS regression") + + +def engine_environment(): + # Regression runners can carry CI/cloud credentials; the test engines must not inherit them. + keep = {"PATH", "JAVA_HOME", "JDK_17", "LD_LIBRARY_PATH", "LANG", "LC_ALL", "TZ", + "ASAN_OPTIONS", "UBSAN_OPTIONS"} + return {key: value for key, value in os.environ.items() if key in keep} + + +def disable_core_dumps(): + resource.setrlimit(resource.RLIMIT_CORE, (0, 0)) + + +class Fixture: + def __init__(self, home, logs): + self.package = package_root(home) + self.logs = Path(logs).resolve() + self.logs.mkdir(parents=True, exist_ok=True) + self.root = Path(tempfile.mkdtemp(prefix="doris-private-rpc-tls-")) + self.nodes = [] + self.clusters = {} + + def prepare(self): + certificates = self.root / "certificates" + with (self.logs / "certificates.log").open("w") as output: + subprocess.run(["bash", str(Path(__file__).parent / "tls/generate-tls-fixture.sh"), + str(certificates)], check=True, timeout=60, + env=engine_environment(), stdout=output, stderr=subprocess.STDOUT, + preexec_fn=disable_core_dumps) + # The engines need node identities, not the CA signing keys used during fixture generation. + for authority in ("ca", "untrusted-ca"): + (certificates / (authority + ".key")).unlink() + used = set() + for name, tls in (("local", True), ("remote", False)): + ports = reserve_ports(used) + self.clusters[name] = {"host": "127.0.0.1", "ports": ports} + for role in PORTS: + source = self.package / role + node = self.root / name / role + node.mkdir(parents=True) + shutil.copytree(source / "bin", node / "bin", + ignore=shutil.ignore_patterns("*.pid", "*.pid.lock", "palo_env.sh")) + for entry in ("lib", "plugins", "custom_lib", "webroot", "www", "dict"): + if (source / entry).exists(): + (node / entry).symlink_to(source / entry, target_is_directory=True) + for entry in ("conf", "log", "storage", "doris-meta"): + (node / entry).mkdir() + logging = source / "conf/log4j2-spring.xml" Review Comment: Fixed in 196ae5ca5466b21c805684127e08039ee74f77fd. Both disposable BE configurations now preserve the packaged ASAN, UBSAN and LSAN suppression files. The new layout test fails before the fix and passes afterward; all nine default helper tests and the six-block/five-refusal SQL replay pass. A real ASAN runtime startup probe also reproduces the missing-file failure and passes with the copied resource; this is not a fresh ASAN Doris BE package rebuild. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
