Skip to content

Commit ab241e7

Browse files
committed
Merge branch 'master' into 4.x
2 parents c21c5e4 + defd9eb commit ab241e7

7 files changed

Lines changed: 31 additions & 24 deletions

File tree

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@ Other
2121
* cqlengine: Remove Model.__default_ttl__ (PYTHON-889)
2222
* Remove Cluster.set_meta_refresh_enabled (PYTHON-890)
2323

24+
3.15.0
25+
======
26+
Bug Fixes
27+
---------
28+
* Tokenmap.get_replicas returns the wrong value if token coincides with the end of the range (PYTHON-978)
2429

2530
3.14.0
2631
======
32+
April 17, 2018
2733

2834
Features
2935
--------

build.yaml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,6 @@ build:
146146
echo "Installing simulacron"
147147
pushd ~
148148
149-
if [ ! -d "simulacron" ] ; then
150-
git clone git@github.com:datastax/simulacron.git
151-
cd simulacron
152-
git clone git@github.com:datastax/native-protocol.git
153-
cd native-protocol
154-
mvn clean install
155-
cd ../..
156-
fi
157-
cd simulacron
158-
mvn clean install -DskipTests=true
159-
ls standalone/target
160149
SIMULACRON_JAR=`find \`pwd\` -name "simulacron-standalone-*.jar"`
161150
echo "SIMULACRON_JAR: $SIMULACRON_JAR"
162151

cassandra/metadata.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
from binascii import unhexlify
16-
from bisect import bisect_right
16+
from bisect import bisect_left
1717
from collections import defaultdict, Mapping
1818
from functools import total_ordering
1919
from hashlib import md5
@@ -1481,10 +1481,9 @@ def get_replicas(self, keyspace, token):
14811481
tokens_to_hosts = self.tokens_to_hosts_by_ks.get(keyspace, None)
14821482

14831483
if tokens_to_hosts:
1484-
# token range ownership is exclusive on the LHS (the start token), so
1485-
# we use bisect_right, which, in the case of a tie/exact match,
1486-
# picks an insertion point to the right of the existing match
1487-
point = bisect_right(self.ring, token)
1484+
# The values in self.ring correspond to the end of the
1485+
# token range up to and including the value listed.
1486+
point = bisect_left(self.ring, token)
14881487
if point == len(self.ring):
14891488
return tokens_to_hosts[self.ring[0]]
14901489
else:

tests/integration/standard/test_authentication.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def test_auth_connect(self):
8686
session = cluster.connect()
8787
try:
8888
self.assertTrue(session.execute('SELECT release_version FROM system.local'))
89-
assert_quiescent_pool_state(self, cluster)
89+
assert_quiescent_pool_state(self, cluster, wait=1)
9090
for pool in session.get_pools():
9191
connection, _ = pool.borrow_connection(timeout=0)
9292
self.assertEqual(connection.authenticator.server_authenticator_class, 'org.apache.cassandra.auth.PasswordAuthenticator')
@@ -95,7 +95,7 @@ def test_auth_connect(self):
9595
cluster.shutdown()
9696
finally:
9797
root_session.execute('DROP USER %s', user)
98-
assert_quiescent_pool_state(self, root_session.cluster)
98+
assert_quiescent_pool_state(self, root_session.cluster, wait=1)
9999
root_session.cluster.shutdown()
100100

101101
def test_connect_wrong_pwd(self):

tests/integration/standard/test_metadata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,8 +1007,8 @@ def test_token_map(self):
10071007

10081008
for i, token in enumerate(ring):
10091009
self.assertEqual(set(get_replicas('test3rf', token)), set(owners))
1010-
self.assertEqual(set(get_replicas('test2rf', token)), set([owners[(i + 1) % 3], owners[(i + 2) % 3]]))
1011-
self.assertEqual(set(get_replicas('test1rf', token)), set([owners[(i + 1) % 3]]))
1010+
self.assertEqual(set(get_replicas('test2rf', token)), set([owners[i], owners[(i + 1) % 3]]))
1011+
self.assertEqual(set(get_replicas('test1rf', token)), set([owners[i]]))
10121012
cluster.shutdown()
10131013

10141014

tests/integration/util.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,23 @@
1313
# limitations under the License.
1414

1515
from tests.integration import PROTOCOL_VERSION
16+
import time
1617

17-
def assert_quiescent_pool_state(test_case, cluster):
18+
19+
def assert_quiescent_pool_state(test_case, cluster, wait=None):
20+
"""
21+
Checking the quiescent pool state checks that none of the requests ids have
22+
been lost. However, the callback corresponding to a request_id is called
23+
before the request_id is returned back to the pool, therefore
24+
25+
session.execute("SELECT * from system.local")
26+
assert_quiescent_pool_state(self, session.cluster)
27+
28+
(with no wait) might fail because when execute comes back the request_id
29+
hasn't yet been returned to the pool, therefore the wait.
30+
"""
31+
if wait is not None:
32+
time.sleep(wait)
1833

1934
for session in cluster.sessions:
2035
pool_states = session.get_pool_state().values()
@@ -32,4 +47,3 @@ def assert_quiescent_pool_state(test_case, cluster):
3247
test_case.assertEqual(len(req_ids), len(set(req_ids)))
3348
test_case.assertEqual(connection.highest_request_id, len(req_ids) - 1)
3449
test_case.assertEqual(connection.highest_request_id, max(req_ids))
35-

tests/unit/test_metadata.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,7 @@ def _get_replicas(self, token_klass):
312312
token_map = TokenMap(token_klass, token_to_primary_replica, tokens, metadata)
313313

314314
# tokens match node tokens exactly
315-
for i, token in enumerate(tokens):
316-
expected_host = hosts[(i + 1) % len(hosts)]
315+
for token, expected_host in zip(tokens, hosts):
317316
replicas = token_map.get_replicas("ks", token)
318317
self.assertEqual(set(replicas), {expected_host})
319318

0 commit comments

Comments
 (0)