Skip to content

Commit 8643684

Browse files
committed
catch OperationTimedOut in consistency tests
1 parent 037cfce commit 8643684

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

tests/integration/long/test_consistency.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import struct, logging, sys, traceback
15+
import struct, logging, sys, traceback, time
1616

1717
from cassandra import ConsistencyLevel, OperationTimedOut, ReadTimeout, WriteTimeout, Unavailable
1818
from cassandra.cluster import Cluster
@@ -65,7 +65,15 @@ def _insert(self, session, keyspace, count, consistency_level=ConsistencyLevel.O
6565
for i in range(count):
6666
ss = SimpleStatement('INSERT INTO cf(k, i) VALUES (0, 0)',
6767
consistency_level=consistency_level)
68-
session.execute(ss)
68+
while True:
69+
try:
70+
session.execute(ss)
71+
break
72+
except (OperationTimedOut, WriteTimeout):
73+
ex_type, ex, tb = sys.exc_info()
74+
log.warn("{0}: {1} Backtrace: {2}".format(ex_type.__name__, ex, traceback.extract_tb(tb)))
75+
del tb
76+
time.sleep(1)
6977

7078
def _query(self, session, keyspace, count, consistency_level=ConsistencyLevel.ONE):
7179
routing_key = struct.pack('>i', 0)
@@ -81,6 +89,7 @@ def _query(self, session, keyspace, count, consistency_level=ConsistencyLevel.ON
8189
ex_type, ex, tb = sys.exc_info()
8290
log.warn("{0}: {1} Backtrace: {2}".format(ex_type.__name__, ex, traceback.extract_tb(tb)))
8391
del tb
92+
time.sleep(1)
8493

8594
def _assert_writes_succeed(self, session, keyspace, consistency_levels):
8695
for cl in consistency_levels:

tests/integration/long/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,21 +133,21 @@ def ring(node):
133133
def wait_for_up(cluster, node, wait=True):
134134
while True:
135135
host = cluster.metadata.get_host(IP_FORMAT % node)
136-
time.sleep(0.1)
137136
if host and host.is_up:
138137
log.debug("Done waiting for node %s to be up", node)
139138
return
140139
else:
141140
log.debug("Host is still marked down, waiting")
141+
time.sleep(1)
142142

143143

144144
def wait_for_down(cluster, node, wait=True):
145145
log.debug("Waiting for node %s to be down", node)
146146
while True:
147147
host = cluster.metadata.get_host(IP_FORMAT % node)
148-
time.sleep(0.1)
149148
if not host or not host.is_up:
150149
log.debug("Done waiting for node %s to be down", node)
151150
return
152151
else:
153152
log.debug("Host is still marked up, waiting")
153+
time.sleep(1)

0 commit comments

Comments
 (0)