Skip to content

Commit 2ace932

Browse files
authored
Merge pull request datastax#985 from datastax/long-python_test-dse-failures
Long python test dse failures
2 parents 12b59b8 + 91b91d8 commit 2ace932

File tree

4 files changed

+62
-6
lines changed

4 files changed

+62
-6
lines changed

CHANGELOG.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
3.15.2
2+
======
3+
4+
Other
5+
-----
6+
* Fix tests when RF is not maintained if we decomission a node (PYTHON-1017)
7+
18
3.15.1
29
======
310
September 6, 2018

build.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ schedules:
2020
exclude:
2121
- python: [3.4, 3.6]
2222

23+
commit_long_test:
24+
schedule: per_commit
25+
branches:
26+
include: [/long-python.*/]
27+
env_vars: |
28+
EVENT_LOOP_MANAGER='libev'
29+
matrix:
30+
exclude:
31+
- python: [3.4, 3.6]
32+
- cassandra: ['2.0', '2.1', '3.0']
33+
2334
commit_branches:
2435
schedule: per_commit
2536
branches:

tests/integration/long/test_loadbalancingpolicies.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,20 @@ def _connect_probe_cluster(self):
6565
self.probe_session = self.probe_cluster.connect()
6666

6767
def _wait_for_nodes_up(self, nodes, cluster=None):
68+
log.debug('entered: _wait_for_nodes_up(nodes={ns}, '
69+
'cluster={cs})'.format(ns=nodes,
70+
cs=cluster))
6871
if not cluster:
72+
log.debug('connecting to cluster')
6973
self._connect_probe_cluster()
7074
cluster = self.probe_cluster
7175
for n in nodes:
7276
wait_for_up(cluster, n)
7377

7478
def _wait_for_nodes_down(self, nodes, cluster=None):
79+
log.debug('entered: _wait_for_nodes_down(nodes={ns}, '
80+
'cluster={cs})'.format(ns=nodes,
81+
cs=cluster))
7582
if not cluster:
7683
self._connect_probe_cluster()
7784
cluster = self.probe_cluster
@@ -87,13 +94,19 @@ def _cluster_session_with_lbp(self, lbp):
8794

8895
def _insert(self, session, keyspace, count=12,
8996
consistency_level=ConsistencyLevel.ONE):
97+
log.debug('entered _insert('
98+
'session={session}, keyspace={keyspace}, '
99+
'count={count}, consistency_level={consistency_level}'
100+
')'.format(session=session, keyspace=keyspace, count=count,
101+
consistency_level=consistency_level))
90102
session.execute('USE %s' % keyspace)
91103
ss = SimpleStatement('INSERT INTO cf(k, i) VALUES (0, 0)', consistency_level=consistency_level)
92104

93105
tries = 0
94106
while tries < 100:
95107
try:
96108
execute_concurrent_with_args(session, ss, [None] * count)
109+
log.debug('Completed _insert on try #{}'.format(tries + 1))
97110
return
98111
except (OperationTimedOut, WriteTimeout, WriteFailure):
99112
ex_type, ex, tb = sys.exc_info()
@@ -105,6 +118,13 @@ def _insert(self, session, keyspace, count=12,
105118

106119
def _query(self, session, keyspace, count=12,
107120
consistency_level=ConsistencyLevel.ONE, use_prepared=False):
121+
log.debug('entered _query('
122+
'session={session}, keyspace={keyspace}, '
123+
'count={count}, consistency_level={consistency_level}, '
124+
'use_prepared={use_prepared}'
125+
')'.format(session=session, keyspace=keyspace, count=count,
126+
consistency_level=consistency_level,
127+
use_prepared=use_prepared))
108128
if use_prepared:
109129
query_string = 'SELECT * FROM %s.cf WHERE k = ?' % keyspace
110130
if not self.prepared or self.prepared.query_string != query_string:
@@ -549,7 +569,7 @@ def test_token_aware_with_shuffle_rf2(self):
549569

550570
self._check_query_order_changes(session=session, keyspace=keyspace)
551571

552-
#check TokenAwarePolicy still return the remaining replicas when one goes down
572+
# check TokenAwarePolicy still return the remaining replicas when one goes down
553573
self.coordinator_stats.reset_counts()
554574
stop(2)
555575
self._wait_for_nodes_down([2], cluster)

tests/integration/long/utils.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
import time
1818

1919
from collections import defaultdict
20-
from ccmlib.node import Node
20+
from ccmlib.node import Node, ToolError
2121

22+
from nose.tools import assert_in
2223
from cassandra.query import named_tuple_factory
2324
from cassandra.cluster import ConsistencyLevel
2425

@@ -35,6 +36,7 @@ def __init__(self):
3536
self.coordinator_counts = defaultdict(int)
3637

3738
def add_coordinator(self, future):
39+
log.debug('adding coordinator from {}'.format(future))
3840
future.result()
3941
coordinator = future._current_host.address
4042
self.coordinator_counts[coordinator] += 1
@@ -100,11 +102,24 @@ def force_stop(node):
100102

101103

102104
def decommission(node):
103-
get_node(node).decommission()
105+
try:
106+
get_node(node).decommission()
107+
except ToolError as e:
108+
expected_errs = (('Not enough live nodes to maintain replication '
109+
'factor in keyspace system_distributed'),
110+
'Perform a forceful decommission to ignore.')
111+
for err in expected_errs:
112+
assert_in(err, e.stdout)
113+
# in this case, we're running against a C* version with CASSANDRA-12510
114+
# applied and need to decommission with `--force`
115+
get_node(node).decommission(force=True)
104116
get_node(node).stop()
105117

106118

107119
def bootstrap(node, data_center=None, token=None):
120+
log.debug('called bootstrap('
121+
'node={node}, data_center={data_center}, '
122+
'token={token})')
108123
node_instance = Node('node%s' % node,
109124
get_cluster(),
110125
auto_bootstrap=False,
@@ -118,12 +133,15 @@ def bootstrap(node, data_center=None, token=None):
118133

119134
try:
120135
start(node)
121-
except:
136+
except Exception as e0:
137+
log.debug('failed 1st bootstrap attempt with: \n{}'.format(e0))
122138
# Try only twice
123139
try:
124140
start(node)
125-
except:
141+
except Exception as e1:
142+
log.debug('failed 2nd bootstrap attempt with: \n{}'.format(e1))
126143
log.error('Added node failed to start twice.')
144+
raise e1
127145

128146

129147
def ring(node):
@@ -140,7 +158,7 @@ def wait_for_up(cluster, node):
140158
log.debug("Done waiting for node %s to be up", node)
141159
return
142160
else:
143-
log.debug("Host is still marked down, waiting")
161+
log.debug("Host {} is still marked down, waiting".format(addr))
144162
tries += 1
145163
time.sleep(1)
146164

0 commit comments

Comments
 (0)