|
| 1 | +import json |
1 | 2 | import logging
|
2 | 3 | import os.path
|
3 | 4 | from unittest import TestCase
|
4 | 5 | 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 |
6 | 7 |
|
7 |
| -from tests.integration import use_cluster |
| 8 | +from cassandra.policies import TokenAwarePolicy, RoundRobinPolicy, ConstantReconnectionPolicy |
| 9 | +from tests.integration import use_cluster, PROTOCOL_VERSION |
8 | 10 | from cassandra.cluster import Cluster, TwistedConnection
|
9 | 11 |
|
10 | 12 |
|
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 | + |
13 | 22 | try:
|
14 | 23 | from cassandra.io.asyncorereactor import AsyncoreConnection
|
15 | 24 | supported_connection_classes += [AsyncoreConnection]
|
|
22 | 31 |
|
23 | 32 | # need to run them with specific configuration like `gevent.monkey.patch_all()` or under async functions
|
24 | 33 | # 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 |
25 | 60 |
|
26 | 61 |
|
27 | 62 | class ScyllaCloudConfigTests(TestCase):
|
|
0 commit comments