Skip to content
Snippets Groups Projects
Commit 6f0cee63 authored by Kurdakov Alexander's avatar Kurdakov Alexander Committed by Alexander Kurdakov
Browse files

feat: always persist default tier

parent 07d2cb8f
No related branches found
No related tags found
1 merge request!1047feat: always persist default tier
Pipeline #41732 failed
This commit is part of merge request !1047. Comments created here will be created in the context of that merge request.
......@@ -772,18 +772,20 @@ pub struct ClusterConfig {
impl ClusterConfig {
pub fn tiers(&self) -> HashMap<String, Tier> {
if self.tiers.is_empty() {
return HashMap::from([(
DEFAULT_TIER.to_string(),
let mut tier_defs = HashMap::with_capacity(self.tiers.len());
let contains_default_tier_definition = self.tiers.get(DEFAULT_TIER).is_some();
if !contains_default_tier_definition {
tier_defs.insert(
DEFAULT_TIER.into(),
Tier {
name: DEFAULT_TIER.into(),
replication_factor: self.default_replication_factor(),
can_vote: true,
},
)]);
);
}
let mut tier_defs = HashMap::with_capacity(self.tiers.len());
for (name, info) in &self.tiers {
let replication_factor = info
.replication_factor
......
......@@ -401,3 +401,42 @@ def test_picodata_default_config(cluster: Cluster):
i.start()
i.wait_online()
def test_default_tier_without_default_replication_factor(cluster: Cluster):
# default tier wasn't created only in case of explicit configuration file
cluster.set_config_file(
yaml="""
cluster:
cluster_id: test
tiers:
not_default:
"""
)
instance = cluster.add_instance()
dql = instance.sudo_sql(
'select "replication_factor" from "_pico_tier" where "name" = \'default\''
)
assert dql["rows"][0][0] == 1
def test_default_tier_with_default_replication_factor(cluster: Cluster):
# default tier wasn't created only in case of explicit configuration file
cluster.set_config_file(
yaml="""
cluster:
default_replication_factor: 3
cluster_id: test
tiers:
not_default:
"""
)
instance = cluster.add_instance()
dql = instance.sudo_sql(
'select "replication_factor" from "_pico_tier" where "name" = \'default\''
)
assert dql["rows"][0][0] == 3
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment