You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "David Capwell (Jira)" <ji...@apache.org> on 2022/11/03 20:41:00 UTC
[jira] [Commented] (CASSANDRA-17964) Some tests are never executed due to naming violation - fix it and add checkstyle where applicable
[ https://issues.apache.org/jira/browse/CASSANDRA-17964?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17628517#comment-17628517 ]
David Capwell commented on CASSANDRA-17964:
-------------------------------------------
Looking at https://github.com/instaclustr/cassandra/tree/CASSANDRA-17964-4.1-2 I have concerns that this renames things that were already running, or renames things that are just fine (such as what class all jvm-dtest extend...)
The issue with checkstyle is that we don't have the full ability to understand the context and if this is correct or not...
I wrote a quick test to find all bad named tests
{code}
/*
* 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.distributed.test;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.Test;
import org.reflections.Reflections;
import org.reflections.scanners.Scanners;
import org.reflections.util.ConfigurationBuilder;
public class DidYouNameThingsRightTest
{
private static final Reflections reflections = new Reflections(new ConfigurationBuilder().forPackage("org.apache.cassandra").setScanners(Scanners.MethodsAnnotated, Scanners.SubTypes).setExpandSuperTypes(true));
@Test
public void test2()
{
Set<Method> methodsAnnotatedWith = reflections.getMethodsAnnotatedWith(Test.class);
List<String> testFiles = methodsAnnotatedWith.stream().map(Method::getDeclaringClass).distinct()
// .filter(c -> c.getPackage().getName().contains("org.apache.cassandra.distributed.test")) // uncomment to filter to jvm-dtest
.flatMap(DidYouNameThingsRightTest::expand)
.map(DidYouNameThingsRightTest::normalize)
.map(Class::getCanonicalName)
.filter(s -> !s.endsWith("Test"))
.distinct().sorted()
.collect(Collectors.toList());
System.out.println(String.join("\n", testFiles));
}
private static Class<?> normalize(Class<?> klass)
{
for (; klass.getEnclosingClass() != null; klass = klass.getEnclosingClass())
{
}
return klass;
}
private static Stream<Class<?>> expand(Class<?> klass)
{
Set<? extends Class<?>> subTypes = reflections.getSubTypesOf(klass);
if (subTypes == null || subTypes.isEmpty())
return Stream.of(klass);
return (Stream<Class<?>>) subTypes.stream();
}
}
{code}
Which finds
{code}
org.apache.cassandra.auth.CassandraAuthorizerTruncatingTests
org.apache.cassandra.cql3.BatchTests
org.apache.cassandra.cql3.CachingBench
org.apache.cassandra.cql3.GcCompactionBench
org.apache.cassandra.cql3.KeywordTestSplit1
org.apache.cassandra.cql3.KeywordTestSplit2
org.apache.cassandra.db.guardrails.GuardrailAllowUncompressedTables
org.apache.cassandra.db.guardrails.GuardrailSecondaryIndexTester
org.apache.cassandra.db.guardrails.GuardrailSecondaryIndexesPerTable
org.apache.cassandra.distributed.test.ByteBuddyExamples
org.apache.cassandra.distributed.test.PaxosRepairTest2
org.apache.cassandra.distributed.test.ReprepareTestOldBehaviour
org.apache.cassandra.distributed.test.VirtualTableFromInternode
org.apache.cassandra.utils.UUIDTests
{code}
Can we limit the changes to just these classes? Would it make sense to leverage the above code for test discovery? maybe adding something like
{code}
$ ant find-tests-unit
$ ant find-tests-jvm-dtest
$ ant find-tests-jvm-dtest-upgrade
{code}
> Some tests are never executed due to naming violation - fix it and add checkstyle where applicable
> --------------------------------------------------------------------------------------------------
>
> Key: CASSANDRA-17964
> URL: https://issues.apache.org/jira/browse/CASSANDRA-17964
> Project: Cassandra
> Issue Type: Task
> Components: Test/unit
> Reporter: Ruslan Fomkin
> Assignee: Stefan Miklosovic
> Priority: Normal
> Fix For: 3.0.x, 3.11.x, 4.0.x, 4.1.x, 4.x
>
> Time Spent: 1h 10m
> Remaining Estimate: 0h
>
> [BatchTests|https://github.com/apache/cassandra/blob/trunk/test/unit/org/apache/cassandra/cql3/BatchTests.java] doesn't follow naming convention to be run as unit tests and, thus, is never run.
> The rule in build expects names as `*Test`.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org