Skip to content

Commit 297622f

Browse files
authored
Reimplement get_cluster_info using driver instead of cqlsh (#402)
On python 3.12.x cqlsh fails with: ``` libexec/python3.12.bin: symbol lookup error: /lib/x86_64-linux-gnu/libpthread.so.0: undefined symbol: __libc_pthread_init, version GLIBC_PRIVATE ``` So we need to work it around by not using cqlsh
1 parent 41e86cb commit 297622f

File tree

1 file changed

+39
-4
lines changed

1 file changed

+39
-4
lines changed

tests/integration/standard/test_scylla_cloud.py

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
1+
import json
12
import logging
23
import os.path
34
from unittest import TestCase
45
from ccmlib.utils.ssl_utils import generate_ssl_stores
5-
from ccmlib.utils.sni_proxy import refresh_certs, get_cluster_info, start_sni_proxy, create_cloud_config
6+
from ccmlib.utils.sni_proxy import refresh_certs, start_sni_proxy, create_cloud_config, NodeInfo
67

7-
from tests.integration import use_cluster
8+
from cassandra.policies import TokenAwarePolicy, RoundRobinPolicy, ConstantReconnectionPolicy
9+
from tests.integration import use_cluster, PROTOCOL_VERSION
810
from cassandra.cluster import Cluster, TwistedConnection
911

1012

11-
from cassandra.io.libevreactor import LibevConnection
12-
supported_connection_classes = [LibevConnection, TwistedConnection]
13+
supported_connection_classes = [TwistedConnection]
14+
15+
try:
16+
from cassandra.io.libevreactor import LibevConnection
17+
supported_connection_classes += [LibevConnection]
18+
except ImportError:
19+
pass
20+
21+
1322
try:
1423
from cassandra.io.asyncorereactor import AsyncoreConnection
1524
supported_connection_classes += [AsyncoreConnection]
@@ -22,6 +31,32 @@
2231

2332
# need to run them with specific configuration like `gevent.monkey.patch_all()` or under async functions
2433
# unsupported_connection_classes = [GeventConnection, AsyncioConnection, EventletConnection]
34+
LOGGER = logging.getLogger(__name__)
35+
36+
37+
def get_cluster_info(cluster, port=9142):
38+
session = Cluster(
39+
contact_points=list(map(lambda node: node.address(), cluster.nodelist())), protocol_version=PROTOCOL_VERSION,
40+
load_balancing_policy=TokenAwarePolicy(RoundRobinPolicy()),
41+
reconnection_policy=ConstantReconnectionPolicy(5)
42+
).connect()
43+
44+
nodes_info = []
45+
46+
for row in session.execute('select host_id, broadcast_address, data_center from system.local'):
47+
if row[0] and row[1]:
48+
nodes_info.append(NodeInfo(address=row[1],
49+
port=port,
50+
host_id=row[0],
51+
data_center=row[2]))
52+
53+
for row in session.execute('select host_id, broadcast_address, data_center from system.local'):
54+
nodes_info.append(NodeInfo(address=row[1],
55+
port=port,
56+
host_id=row[0],
57+
data_center=row[2]))
58+
59+
return nodes_info
2560

2661

2762
class ScyllaCloudConfigTests(TestCase):

0 commit comments

Comments
 (0)