Skip to main content

mz_clusterd_test_driver/
target.rs

1// Copyright Materialize, Inc. and contributors. All rights reserved.
2//
3// Use of this software is governed by the Business Source License
4// included in the LICENSE file.
5//
6// As of the Change Date specified in that file, in accordance with
7// the Business Source License, use of this software will be governed
8// by the Apache License, Version 2.0.
9
10//! Resolves the clusterd compute controller address. The driver connects to an
11//! externally-managed clusterd (mzcompose or a manually-launched process); it
12//! never spawns one.
13//!
14//! Local iteration without mzcompose:
15//!   1. Start CockroachDB (see CLAUDE.md).
16//!   2. Launch the driver first so it hosts PubSub on a fixed port (e.g. 0.0.0.0:6879).
17//!   3. Launch clusterd manually (run `cargo run -p mz-clusterd -- --help` to
18//!      confirm required flags and the exact `TimelyConfig` JSON shape from
19//!      `src/cluster-client/src/client.rs`):
20//!
21//! ```text
22//! PERSIST_PUBSUB_URL=http://127.0.0.1:6879 \
23//!   cargo run -p mz-clusterd -- \
24//!     --compute-controller-listen-addr 127.0.0.1:2101 \
25//!     --storage-controller-listen-addr 127.0.0.1:2100 \
26//!     --compute-timely-config 'TIMELY_CONFIG_JSON' \
27//!     --storage-timely-config 'TIMELY_CONFIG_JSON' \
28//!     --process 0 --scratch-directory /tmp/clusterd-scratch
29//! ```
30//!
31//!   4. Run the e2e test with CLUSTERD_COMPUTE_ADDR=127.0.0.1:2101 and the same
32//!      PersistHost bind/port the clusterd PubSub URL points at.
33
34/// The clusterd compute controller address, from `CLUSTERD_COMPUTE_ADDR`
35/// (default `127.0.0.1:2101`).
36pub fn compute_addr() -> String {
37    std::env::var("CLUSTERD_COMPUTE_ADDR").unwrap_or_else(|_| "127.0.0.1:2101".to_string())
38}
39
40/// Whether an end-to-end test should run: true only when a target address was
41/// explicitly provided. Integration tests skip when unset to keep `cargo test`
42/// green without a running clusterd.
43pub fn e2e_enabled() -> bool {
44    std::env::var("CLUSTERD_COMPUTE_ADDR").is_ok()
45}