Skip to content

Commit 430a1e7

Browse files
committed
Log cqlsh output in get_cluster_info
ScyllaCloudConfigTests are failing due to the get_cluster_info returned empty list. To investigate it furthere we need to dump cqlsh output to debug log.
1 parent d62eb38 commit 430a1e7

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

tests/integration/standard/test_scylla_cloud.py

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
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

78
from tests.integration import use_cluster
89
from cassandra.cluster import Cluster, TwistedConnection
@@ -22,6 +23,49 @@
2223

2324
# need to run them with specific configuration like `gevent.monkey.patch_all()` or under async functions
2425
# unsupported_connection_classes = [GeventConnection, AsyncioConnection, EventletConnection]
26+
LOGGER = logging.getLogger(__name__)
27+
28+
def get_cluster_info(cluster, port=9142):
29+
30+
node1 = cluster.nodelist()[0]
31+
stdout, stderr = node1.run_cqlsh(cmds='select JSON host_id,broadcast_address,data_center from system.local ;',
32+
return_output=True, show_output=True)
33+
34+
if stdout:
35+
LOGGER.debug("cqlsh 'select JSON host_id,broadcast_address,data_center from system.local' returned stdout: %s", stdout)
36+
if stderr:
37+
LOGGER.debug("cqlsh 'select JSON host_id,broadcast_address,data_center from system.local' returned stderr: %s", stderr)
38+
39+
nodes_info = []
40+
for line in stdout.splitlines():
41+
try:
42+
host = json.loads(line)
43+
except json.decoder.JSONDecodeError:
44+
continue
45+
if 'broadcast_address' in host and 'host_id' in host:
46+
nodes_info.append(NodeInfo(address=host['broadcast_address'],
47+
port=port,
48+
host_id=host['host_id'],
49+
data_center=host['data_center']))
50+
51+
stdout, stderr = node1.run_cqlsh(cmds='select JSON peer,host_id,data_center from system.peers ;',
52+
return_output=True, show_output=True)
53+
if stdout:
54+
LOGGER.debug("cqlsh 'select JSON peer,host_id,data_center from system.peers' returned stdout: %s", stdout)
55+
if stderr:
56+
LOGGER.debug("cqlsh 'select JSON peer,host_id,data_center from system.peers' returned stderr: %s", stderr)
57+
for line in stdout.splitlines():
58+
try:
59+
host = json.loads(line)
60+
except json.decoder.JSONDecodeError:
61+
continue
62+
if 'peer' in host and 'host_id' in host:
63+
nodes_info.append(NodeInfo(address=host['peer'],
64+
port=port,
65+
host_id=host['host_id'],
66+
data_center=host['data_center']))
67+
68+
return nodes_info
2569

2670

2771
class ScyllaCloudConfigTests(TestCase):

0 commit comments

Comments
 (0)