You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2020/06/12 03:13:00 UTC

[GitHub] [cassandra] stillalex commented on a change in pull request #629: CASSANDRA-14888 Several mbeans are not unregistered when dropping a keyspace and table

stillalex commented on a change in pull request #629:
URL: https://github.com/apache/cassandra/pull/629#discussion_r439183924



##########
File path: test/unit/org/apache/cassandra/metrics/ViewWriteMetricsTest.java
##########
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.metrics;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.function.LongSupplier;
+
+import org.apache.cassandra.SchemaLoader;
+import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.cassandra.exceptions.ConfigurationException;
+import org.apache.cassandra.schema.Schema;
+import org.apache.cassandra.service.EmbeddedCassandraService;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.Session;
+
+public class ViewWriteMetricsTest extends SchemaLoader
+{
+    private static Session session;
+
+    @BeforeClass()
+    public static void setup() throws ConfigurationException, IOException
+    {
+        Schema.instance.clear();
+
+        EmbeddedCassandraService cassandra = new EmbeddedCassandraService();
+        cassandra.start();
+
+        Cluster cluster = Cluster.builder().addContactPoint("127.0.0.1").withPort(DatabaseDescriptor.getNativeTransportPort()).build();
+        session = cluster.connect();
+    }
+
+    @Test
+    public void testMetricsCleanupOnDrop()
+    {
+        String keyspace = "junit";
+        String table = "viewwritemetrics";
+        String view = "viewwritemetrics_materialized_view";
+
+        CassandraMetricsRegistry registry = CassandraMetricsRegistry.Metrics;
+        LongSupplier count = () -> registry.getNames().stream().filter(n -> n.contains(view)).count();
+
+        // no metrics before create
+        assertEquals(0, count.getAsLong());
+
+        // TODO the ViewWriteMetrics metrics are never created
+        session.execute(String.format("CREATE KEYSPACE IF NOT EXISTS %s WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };", keyspace));
+        session.execute(String.format("CREATE TABLE IF NOT EXISTS %s.%s (id int, val text, PRIMARY KEY(id, val));", keyspace, table));
+        session.execute(String.format("CREATE MATERIALIZED VIEW %s.%s AS SELECT id,val FROM %s.%s WHERE id IS NOT NULL AND val IS NOT NULL PRIMARY KEY (id,val);", keyspace, view, keyspace, table));
+
+        // TODO needed?
+        //session.execute(String.format("INSERT INTO %s.%s (id, val) VALUES (1, 'Apache Cassandra');", keyspace, table));
+
+        // some metrics
+        assertTrue(count.getAsLong() > 0);
+
+        session.execute(String.format("DROP MATERIALIZED VIEW %s.%s;", keyspace, view));
+        session.execute(String.format("DROP TABLE %s.%s;", keyspace, table));

Review comment:
       this was not part of the test, it was the cleanup




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org