Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 7218E200D3A for ; Wed, 15 Nov 2017 22:46:40 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 706A6160C0C; Wed, 15 Nov 2017 21:46:40 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id B80A5160C0A for ; Wed, 15 Nov 2017 22:46:39 +0100 (CET) Received: (qmail 4105 invoked by uid 500); 15 Nov 2017 21:46:32 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 3712 invoked by uid 99); 15 Nov 2017 21:46:32 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Nov 2017 21:46:32 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 5F8E4F5E97; Wed, 15 Nov 2017 21:46:30 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aweisberg@apache.org To: commits@cassandra.apache.org Date: Wed, 15 Nov 2017 21:47:16 -0000 Message-Id: In-Reply-To: <7b6f5caba1744195b9d4ab4d41a9d308@git.apache.org> References: <7b6f5caba1744195b9d4ab4d41a9d308@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [48/50] cassandra git commit: Add test for digest requests with RandomPartitioner and tracing enabled archived-at: Wed, 15 Nov 2017 21:46:40 -0000 Add test for digest requests with RandomPartitioner and tracing enabled Patch by Sam Tunnicliffe; reviewed by Jason Brown and Philip Thompson for CASSANDRA-13964 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/01df7c49 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/01df7c49 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/01df7c49 Branch: refs/heads/master Commit: 01df7c49864ed5fa66db2181599a463a33b1f877 Parents: 7cc06a0 Author: Sam Tunnicliffe Authored: Tue Oct 17 14:50:25 2017 +0100 Committer: Sam Tunnicliffe Committed: Tue Nov 7 16:20:55 2017 +0000 ---------------------------------------------------------------------- cql_tracing_test.py | 39 +++++++++++++++++++++++++++++++++++++-- tools/jmxutils.py | 12 ++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/01df7c49/cql_tracing_test.py ---------------------------------------------------------------------- diff --git a/cql_tracing_test.py b/cql_tracing_test.py index aaf55aa..549e4d0 100644 --- a/cql_tracing_test.py +++ b/cql_tracing_test.py @@ -3,6 +3,7 @@ from distutils.version import LooseVersion from dtest import Tester, debug, create_ks from tools.decorators import since +from tools.jmxutils import make_mbean, JolokiaAgent, remove_perf_disable_shared_mem class TestCqlTracing(Tester): @@ -15,16 +16,23 @@ class TestCqlTracing(Tester): # instantiated when specified as a custom tracing implementation. """ - def prepare(self, create_keyspace=True, nodes=3, rf=3, protocol_version=3, jvm_args=None, **kwargs): + def prepare(self, create_keyspace=True, nodes=3, rf=3, protocol_version=3, jvm_args=None, random_partitioner=False, **kwargs): if jvm_args is None: jvm_args = [] jvm_args.append('-Dcassandra.wait_for_tracing_events_timeout_secs=15') cluster = self.cluster - cluster.populate(nodes).start(wait_for_binary_proto=True, jvm_args=jvm_args) + if random_partitioner: + cluster.set_partitioner("org.apache.cassandra.dht.RandomPartitioner") + else: + cluster.set_partitioner("org.apache.cassandra.dht.Murmur3Partitioner") + + cluster.populate(nodes) node1 = cluster.nodelist()[0] + remove_perf_disable_shared_mem(node1) # necessary for jmx + cluster.start(wait_for_binary_proto=True, jvm_args=jvm_args) session = self.patient_cql_connection(node1, protocol_version=protocol_version) if create_keyspace: @@ -176,3 +184,30 @@ class TestCqlTracing(Tester): self.assertIn("Default constructor for Tracing class " "'org.apache.cassandra.tracing.TracingImpl' is inaccessible.", check_for_errs_in) + + @since('3.0') + def test_tracing_does_not_interfere_with_digest_calculation(self): + """ + Test that enabling tracing doesn't interfere with digest responses when using RandomPartitioner. + The use of a threadlocal MessageDigest for generating both DigestResponse messages and for + calculating tokens meant that the DigestResponse was always incorrect when both RP and tracing + were enabled, leading to unnecessary data reads. + + @jira_ticket CASSANDRA-13964 + """ + + session = self.prepare(random_partitioner=True) + self.trace(session) + + node1 = self.cluster.nodelist()[0] + + rr_count = make_mbean('metrics', type='ReadRepair', name='RepairedBlocking') + with JolokiaAgent(node1) as jmx: + # the MBean may not have been initialized, in which case Jolokia agent will return + # a HTTP 404 response. If we receive such, we know that no digest mismatch was reported + # If we are able to read the MBean attribute, assert that the count is 0 + if jmx.has_mbean(rr_count): + # expect 0 digest mismatches + self.assertEqual(0, jmx.read_attribute(rr_count, 'Count')) + else: + pass http://git-wip-us.apache.org/repos/asf/cassandra/blob/01df7c49/tools/jmxutils.py ---------------------------------------------------------------------- diff --git a/tools/jmxutils.py b/tools/jmxutils.py index 8c20eb8..7468226 100644 --- a/tools/jmxutils.py +++ b/tools/jmxutils.py @@ -243,6 +243,18 @@ class JolokiaAgent(object): raise Exception("Jolokia agent returned non-200 status: %s" % (response,)) return response + def has_mbean(self, mbean, verbose=True): + """ + Check for the existence of an MBean + + `mbean` should be the full name of an mbean. See the mbean() utility + function for an easy way to create this. + """ + body = {'type': 'search', + 'mbean': mbean} + response = self._query(body, verbose=verbose) + return len(response['value']) > 0 + def read_attribute(self, mbean, attribute, path=None, verbose=True): """ Reads a single JMX attribute. --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org For additional commands, e-mail: commits-help@cassandra.apache.org