diff --git a/asap-tools/experiments/constants.py b/asap-tools/experiments/constants.py index ded60da9..1cd434c6 100644 --- a/asap-tools/experiments/constants.py +++ b/asap-tools/experiments/constants.py @@ -56,6 +56,8 @@ PROMETHEUS_REMOTE_WRITE_RECEIVER_FLAG = "--web.enable-remote-write-receiver" HTTP_READINESS_CURL_TIMEOUT_SECONDS = 5 QUERY_ENGINE_RUNTIME_INFO_ENDPOINT = "/api/v1/status/runtimeinfo" +# The ClickHouse adapter's runtime-info endpoint; it serves no Prometheus API. +QUERY_ENGINE_CLICKHOUSE_RUNTIME_INFO_ENDPOINT = "/clickhouse/ping" # Query engine spill files live in this subdirectory of its output dir, which # the container mounts, so host and container paths agree. Results syncs skip it. QUERY_ENGINE_SPILL_SUBDIR = "spill" diff --git a/asap-tools/experiments/experiment_utils/services/query_engine.py b/asap-tools/experiments/experiment_utils/services/query_engine.py index 29db40a8..46b79564 100644 --- a/asap-tools/experiments/experiment_utils/services/query_engine.py +++ b/asap-tools/experiments/experiment_utils/services/query_engine.py @@ -77,6 +77,14 @@ def get_http_port(self) -> int: return 8088 +def runtime_info_endpoint(backend_type: str) -> str: + """The readiness endpoint of the engine's query adapter for `backend_type`: + the ClickHouse adapter serves no Prometheus API.""" + if backend_type == "clickhouse": + return constants.QUERY_ENGINE_CLICKHOUSE_RUNTIME_INFO_ENDPOINT + return constants.QUERY_ENGINE_RUNTIME_INFO_ENDPOINT + + class QueryEngineRustService(BaseQueryEngineService): """Service for managing the Rust query engine process.""" @@ -100,6 +108,8 @@ def __init__( self.remote_spill_dir: Optional[str] = None self.local_spill_report: Optional[str] = None self.http_port: Optional[int] = None + # The started backend's adapter's; set by start(). + self.runtime_info_endpoint = constants.QUERY_ENGINE_RUNTIME_INFO_ENDPOINT # ------------------------------------------------------------------ # Config-file helpers (used by both bare-metal and containerized paths) @@ -272,6 +282,7 @@ def start( remote_write_port: Port the precompute engine listens on for Prometheus remote write; should match streaming.remote_write.base_port (default 8080) """ + self.runtime_info_endpoint = runtime_info_endpoint(backend_config["type"]) if spill: self.remote_spill_dir = os.path.join( experiment_output_dir, "query_engine_output", SPILL_SUBDIR @@ -652,7 +663,7 @@ def _is_runtime_info_ready(self) -> bool: cmd = ( f"curl -fsS --max-time {constants.HTTP_READINESS_CURL_TIMEOUT_SECONDS} " f"http://127.0.0.1:{self.get_http_port()}" - f"{constants.QUERY_ENGINE_RUNTIME_INFO_ENDPOINT} >/dev/null" + f"{self.runtime_info_endpoint} >/dev/null" ) result = self.provider.execute_command( node_idx=self.node_offset, diff --git a/asap-tools/experiments/tests/test_victoriametrics_readiness.py b/asap-tools/experiments/tests/test_victoriametrics_readiness.py index 0a43fb2b..8ca17141 100644 --- a/asap-tools/experiments/tests/test_victoriametrics_readiness.py +++ b/asap-tools/experiments/tests/test_victoriametrics_readiness.py @@ -7,7 +7,10 @@ from constants import BASELINE_EXPERIMENT_NAME, SKETCHDB_EXPERIMENT_NAME from experiment_utils.services.base import DockerServiceBase from experiment_utils.services.docker_victoriametrics import get_remote_write_urls -from experiment_utils.services.query_engine import QueryEngineRustService +from experiment_utils.services.query_engine import ( + QueryEngineRustService, + runtime_info_endpoint, +) class RemoteWriteConfigurationTest(unittest.TestCase): @@ -84,6 +87,24 @@ def test_query_engine_requires_runtime_info_endpoint(self): provider.execute_command.call_args_list[1].kwargs["cmd"], ) + def test_clickhouse_backed_query_engine_probes_its_adapters_endpoint(self): + # It serves /clickhouse/ping and 404s on the Prometheus runtime-info + # path, so probing that one never saw it ready. + provider = Mock() + provider.execute_command.return_value = subprocess.CompletedProcess( + args="curl", returncode=0, stdout="", stderr="" + ) + service = QueryEngineRustService(provider, use_container=False, node_offset=0) + service.runtime_info_endpoint = runtime_info_endpoint("clickhouse") + + self.assertTrue(service._is_runtime_info_ready()) + self.assertIn( + "/clickhouse/ping", provider.execute_command.call_args.kwargs["cmd"] + ) + self.assertEqual( + runtime_info_endpoint("prometheus"), "/api/v1/status/runtimeinfo" + ) + if __name__ == "__main__": unittest.main()