Files
scylladb/test/cluster/test_initial_token.py
Patryk Jędrzejczak 193a74576a test/cluster/conftest: cluster_con: provide default values for port and use_ssl
Some cluster tests use `cluster_con` when they need a different load
balancing policy or auth provider. However, no test uses a port
other than 9042 or enables SSL, but all tests must pass `9042, False`
because these parameters don't have default values. This makes the code
more verbose. Also, it's quite obvious that 9042 stands for port, but
it's not obvious what `False` is related to, so there is a need to check
the definition of `cluster_con` while reading any test that uses it.

No reason to backport, it's only a minor refactoring.

Closes scylladb/scylladb#25516
2025-08-22 09:51:24 +03:00

30 lines
1.3 KiB
Python

#
# Copyright (C) 2024-present ScyllaDB
#
# SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
#
import pytest
import logging
from test.pylib.manager_client import ManagerClient
from cassandra.policies import WhiteListRoundRobinPolicy
from test.cluster.conftest import cluster_con
logger = logging.getLogger(__name__)
@pytest.mark.asyncio
async def test_initial_token(manager: ManagerClient) -> None:
tokens = ["-9223372036854775808", "-4611686018427387904", "0", "4611686018427387904"]
cfg1 = {'initial_token': f"{tokens[0]}, {tokens[1]}"}
cfg2 = {'initial_token': f"{tokens[2]}, {tokens[3]}"}
s1 = await manager.server_add(config=cfg1)
s2 = await manager.server_add(config=cfg2)
cql1 = cluster_con([s1.ip_addr], load_balancing_policy=WhiteListRoundRobinPolicy([s1.ip_addr])).connect()
cql2 = cluster_con([s2.ip_addr], load_balancing_policy=WhiteListRoundRobinPolicy([s2.ip_addr])).connect()
res1 = cql1.execute("SELECT tokens From system.local").one()
res2 = cql2.execute("SELECT tokens From system.local").one()
assert all([i in res1.tokens for i in tokens[:2]]) and all([i in res2.tokens for i in tokens[-2:]])
# Try to boot a node with conflicting tokens. It should fail.
s2 = await manager.server_add(config=cfg2, expected_error="Bootstrap failed. See earlier errors")