Created
July 12, 2017 14:40
-
-
Save beltran/a2d1cbc27912cb2df486d7a1a10b89b5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import logging | |
from cassandra.cluster import Cluster | |
from cassandra.policies import RoundRobinPolicy | |
from tests.integration.simulacron.utils import SimulacronClient, PrimeOptions | |
from tests.integration.simulacron.utils import SimulacronServer, prime_cluster, NO_THEN | |
KEYSPACE = "testkeyspace" | |
start_server = True | |
jar_path = "/home/jaume/workspace/simulacron/standalone/target/standalone-0.1-SNAPSHOT.jar" | |
log = logging.getLogger() | |
log.setLevel('ERROR') | |
handler = logging.StreamHandler() | |
handler.setFormatter(logging.Formatter("%(asctime)s [%(levelname)s] %(name)s: %(message)s")) | |
handler.setLevel("ERROR") | |
log.addHandler(handler) | |
query_to_prime = "SELECT * FROM system.local" | |
idle_heartbeat_timeout = 10 | |
idle_heartbeat_interval = 0.5 | |
cluster = Cluster(['127.0.0.1'], | |
load_balancing_policy=RoundRobinPolicy(), | |
idle_heartbeat_timeout=idle_heartbeat_timeout, | |
idle_heartbeat_interval=idle_heartbeat_interval) | |
def this_context(): | |
session = cluster.connect(wait_for_all_pools=True) | |
print(cluster.metadata.all_hosts()) | |
print("len(cluster.sessions): {}".format(len(cluster.sessions))) | |
client = SimulacronClient() | |
client.submit_request(PrimeOptions(then=NO_THEN)) | |
time.sleep(1.2) | |
try: | |
if start_server: | |
server = SimulacronServer(jar_path) | |
server.start() | |
time.sleep(4) | |
prime_cluster("test", data_centers=3, version="3.11") | |
this_context() | |
while 1: | |
print("len(cluster.sessions): {}".format(len(cluster.sessions))) | |
time.sleep(idle_heartbeat_timeout + idle_heartbeat_interval + 2) | |
finally: | |
if start_server: | |
server.stop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment