Skip to content

Commit c2bf5b3

Browse files
committed
Add integration test for new config variables
1 parent 34d901c commit c2bf5b3

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

src/environmentd/src/test_util.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,16 @@ impl TestHarness {
279279
self.builtin_system_cluster_config.size = builtin_system_cluster_replica_size;
280280
self
281281
}
282+
283+
pub fn with_builtin_system_cluster_replication_factor(
284+
mut self,
285+
builtin_system_cluster_replication_factor: u32,
286+
) -> Self {
287+
self.builtin_system_cluster_config.replication_factor =
288+
builtin_system_cluster_replication_factor;
289+
self
290+
}
291+
282292
pub fn with_builtin_catalog_server_cluster_replica_size(
283293
mut self,
284294
builtin_catalog_server_cluster_replica_size: String,
@@ -287,7 +297,6 @@ impl TestHarness {
287297
builtin_catalog_server_cluster_replica_size;
288298
self
289299
}
290-
// TODO: Add with_builtin_probe_cluster_replica_size
291300

292301
pub fn with_propagate_crashes(mut self, propagate_crashes: bool) -> Self {
293302
self.propagate_crashes = propagate_crashes;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright Materialize, Inc. and contributors. All rights reserved.
2+
//G
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+
//! Integration tests for builtin clusters on bootstrap.
11+
12+
use mz_environmentd::test_util::{self};
13+
14+
// Test that a cluster with a replication factor of 0 should not create any replicas.
15+
#[mz_ore::test]
16+
fn test_zero_replication_factor_no_replicas() {
17+
let server = test_util::TestHarness::default()
18+
.with_builtin_system_cluster_replication_factor(0)
19+
.start_blocking();
20+
21+
let mut client = server.connect(postgres::NoTls).unwrap();
22+
let system_cluster = client
23+
.query_one(
24+
r#"
25+
SELECT c.id, c.name, c.replication_factor::integer, COUNT(cr.id)::integer as replica_count
26+
FROM mz_clusters c
27+
LEFT JOIN mz_cluster_replicas cr ON c.id = cr.cluster_id
28+
WHERE c.name = 'mz_system'
29+
GROUP BY c.id, c.name, c.replication_factor
30+
"#,
31+
&[],
32+
)
33+
.unwrap();
34+
35+
let replication_factor: i32 = system_cluster.get(2);
36+
let replica_count: i32 = system_cluster.get(3);
37+
assert_eq!(replication_factor, 0);
38+
assert_eq!(replica_count, 0);
39+
}

0 commit comments

Comments
 (0)