Skip to content
Snippets Groups Projects
Commit b9eb684c authored by Yaroslav Dynnikov's avatar Yaroslav Dynnikov
Browse files

test: align Cluster.add_instance args types

parent 589c7bbb
No related branches found
No related tags found
1 merge request!276test: align Cluster.add_instance args types
Pipeline #12582 passed
......@@ -480,7 +480,7 @@ class Cluster:
self,
wait_ready=True,
peers=None,
instance_id: str | bool | None = True,
instance_id: str | bool = True,
failure_domain=dict(),
init_replication_factor=1,
) -> Instance:
......@@ -489,30 +489,35 @@ class Cluster:
`instance_id` specifies how the instance's id is generated in the
following way:
- if `instance_id` is a string, it will be used as value for the
`--instance-id` command line option.
- If `instance_id` is `True` (default), this function will generate a
value for the `--instance-id` command line option.
- If `instance_id` is `False` or `None`, the instance will be started
without the `--instance-id` option, and the cluster will have to choose
the id.
- if `instance_id` is a string, it will be used as a value for the
`--instance-id` command-line option.
- If `instance_id` is `True` (default), the `--instance-id` command-line
option will be generated by the pytest according to the instances
sequence number in cluster.
- If `instance_id` is `False`, the instance will be started
without the `--instance-id` command-line option and the particular value
will be generated by the cluster.
"""
i = 1 + len(self.instances)
generated_instance_id: str | None
match instance_id:
case True:
instance_id = f"i{i}"
case False | None:
instance_id = None
case str() as iid:
instance_id = iid
generated_instance_id = iid
case True:
generated_instance_id = f"i{i}"
case False:
generated_instance_id = None
case _:
raise Exception("unreachable")
instance = Instance(
binary_path=self.binary_path,
cluster_id=self.id,
instance_id=instance_id,
instance_id=generated_instance_id,
data_dir=f"{self.data_dir}/i{i}",
host=self.base_host,
port=self.base_port + i,
......@@ -534,7 +539,7 @@ class Cluster:
def fail_to_add_instance(
self,
peers=None,
instance_id=None,
instance_id: str | bool = True,
failure_domain=dict(),
init_replication_factor=1,
):
......
......@@ -348,6 +348,7 @@ def test_fail_to_join(cluster: Cluster):
# An instance with the given instance_id is already present in the cluster
# so this instance cannot join
# and therefore exits with failure
assert i1.instance_id is not None
cluster.fail_to_add_instance(
instance_id=i1.instance_id, failure_domain=dict(owner="Jim")
)
......
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