mirror of https://github.com/apache/cassandra
Merge branch 'cassandra-3.11' into cassandra-4.0
This commit is contained in:
commit
2a8e1972fd
|
|
@ -13,6 +13,7 @@
|
|||
Merged from 3.11:
|
||||
* Fix Splitter sometimes creating more splits than requested (CASSANDRA-18013)
|
||||
Merged from 3.0:
|
||||
* Introduce check for names of test classes (CASSANDRA-17964)
|
||||
* Suppress CVE-2021-1471, CVE-2021-3064, CVE-2021-4235 (CASSANDRA-18149)
|
||||
* Switch to snakeyaml's SafeConstructor (CASSANDRA-18150)
|
||||
* Expand build.dir property in rat targets (CASSANDRA-18183)
|
||||
|
|
|
|||
18
build.xml
18
build.xml
|
|
@ -63,6 +63,7 @@
|
|||
<property name="test.classlistfile" value="testlist.txt"/>
|
||||
<property name="test.classlistprefix" value="unit"/>
|
||||
<property name="benchmark.name" value=""/>
|
||||
<property name="test.anttasks.src" value="${test.dir}/anttasks"/>
|
||||
<property name="test.methods" value=""/>
|
||||
<property name="test.unit.src" value="${test.dir}/unit"/>
|
||||
<property name="test.long.src" value="${test.dir}/long"/>
|
||||
|
|
@ -544,7 +545,7 @@
|
|||
<exclusion groupId="com.google.guava" artifactId="guava"/>
|
||||
</dependency>
|
||||
<dependency groupId="org.apache.cassandra" artifactId="dtest-api" version="0.0.13" scope="test"/>
|
||||
<dependency groupId="org.reflections" artifactId="reflections" version="0.9.12" scope="test"/>
|
||||
<dependency groupId="org.reflections" artifactId="reflections" version="0.10.2" scope="test"/>
|
||||
<dependency groupId="org.apache.hadoop" artifactId="hadoop-core" version="1.0.3" scope="provided">
|
||||
<exclusion groupId="org.mortbay.jetty" artifactId="servlet-api"/>
|
||||
<exclusion groupId="commons-logging" artifactId="commons-logging"/>
|
||||
|
|
@ -1292,6 +1293,7 @@
|
|||
<pathelement location="${fqltool.build.classes}"/>
|
||||
</classpath>
|
||||
<compilerarg value="-XDignore.symbol.file"/>
|
||||
<src path="${test.anttasks.src}"/>
|
||||
<src path="${test.unit.src}"/>
|
||||
<src path="${test.long.src}"/>
|
||||
<src path="${test.burn.src}"/>
|
||||
|
|
@ -1300,12 +1302,26 @@
|
|||
<src path="${test.distributed.src}"/>
|
||||
</javac>
|
||||
|
||||
<checktestnameshelper/>
|
||||
|
||||
<!-- Non-java resources needed by the test suite -->
|
||||
<copy todir="${test.classes}">
|
||||
<fileset dir="${test.resources}"/>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<macrodef name="checktestnameshelper">
|
||||
<sequential>
|
||||
<taskdef name="test-name-check_" classname="org.apache.cassandra.anttasks.TestNameCheckTask" classpath="${test.classes}">
|
||||
<classpath>
|
||||
<path refid="cassandra.classpath.test"/>
|
||||
<path location="${fqltool.build.classes}"/>
|
||||
</classpath>
|
||||
</taskdef>
|
||||
<test-name-check_/>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<!-- Run tests separately and report errors after and generate a junit report -->
|
||||
<macrodef name="testhelper">
|
||||
<attribute name="testdelegate"/>
|
||||
|
|
|
|||
|
|
@ -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.anttasks;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.tools.ant.BuildException;
|
||||
import org.apache.tools.ant.Task;
|
||||
import org.reflections.Reflections;
|
||||
import org.reflections.scanners.Scanners;
|
||||
import org.reflections.util.ConfigurationBuilder;
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
public class TestNameCheckTask extends Task
|
||||
{
|
||||
private static final Reflections reflections = new Reflections(new ConfigurationBuilder()
|
||||
.forPackage("org.apache.cassandra")
|
||||
.setScanners(Scanners.MethodsAnnotated, Scanners.SubTypes)
|
||||
.setExpandSuperTypes(true)
|
||||
.setParallel(true));
|
||||
|
||||
public TestNameCheckTask()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws BuildException
|
||||
{
|
||||
Set<Method> methodsAnnotatedWith = reflections.getMethodsAnnotatedWith(Test.class);
|
||||
List<String> testFiles = methodsAnnotatedWith.stream().map(Method::getDeclaringClass).distinct()
|
||||
.flatMap(TestNameCheckTask::expand)
|
||||
.map(TestNameCheckTask::normalize)
|
||||
.map(Class::getCanonicalName)
|
||||
.filter(s -> !s.endsWith("Test"))
|
||||
.distinct().sorted()
|
||||
.collect(toList());
|
||||
|
||||
if (!testFiles.isEmpty())
|
||||
throw new BuildException("Detected tests that have a bad naming convention. All tests have to end on 'Test': \n" + 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);
|
||||
Stream<Class<?>> subs = (Stream<Class<?>>) subTypes.stream();
|
||||
// assume we include if not abstract
|
||||
if (!Modifier.isAbstract(klass.getModifiers()))
|
||||
subs = Stream.concat(Stream.of(klass), subs);
|
||||
return subs;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -41,7 +41,7 @@ import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class ByteBuddyExamples extends TestBaseImpl
|
||||
public class ByteBuddyExamplesTest extends TestBaseImpl
|
||||
{
|
||||
@Test
|
||||
public void writeFailureTest() throws Throwable
|
||||
|
|
@ -30,7 +30,7 @@ import static org.apache.cassandra.distributed.api.Feature.GOSSIP;
|
|||
import static org.apache.cassandra.distributed.api.Feature.NATIVE_PROTOCOL;
|
||||
import static org.apache.cassandra.distributed.api.Feature.NETWORK;
|
||||
|
||||
public class ReprepareTestOldBehaviour extends ReprepareTestBase
|
||||
public class ReprepareOldBehaviourTest extends ReprepareTestBase
|
||||
{
|
||||
@Test
|
||||
public void testReprepareMixedVersion() throws Throwable
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.cassandra.cql3;
|
||||
package org.apache.cassandra.test.microbench;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
|
@ -34,10 +34,13 @@ import org.junit.BeforeClass;
|
|||
import org.junit.Test;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import org.apache.cassandra.config.Config.CommitLogSync;
|
||||
import org.apache.cassandra.config.Config.DiskAccessMode;
|
||||
import org.apache.cassandra.cache.ChunkCache;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.cql3.CQLTester;
|
||||
import org.apache.cassandra.cql3.UntypedResultSet;
|
||||
import org.apache.cassandra.db.ColumnFamilyStore;
|
||||
import org.apache.cassandra.db.compaction.CompactionManager;
|
||||
import org.apache.cassandra.db.rows.Row;
|
||||
|
|
@ -50,7 +53,7 @@ import org.apache.cassandra.utils.FBUtilities;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class CachingBench extends CQLTester
|
||||
public class CachingBenchTest extends CQLTester
|
||||
{
|
||||
private static final String STRATEGY = "LeveledCompactionStrategy";
|
||||
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.cassandra.cql3;
|
||||
package org.apache.cassandra.test.microbench;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
|
@ -34,8 +34,11 @@ import org.junit.BeforeClass;
|
|||
import org.junit.Test;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import org.apache.cassandra.config.Config.CommitLogSync;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.cql3.CQLTester;
|
||||
import org.apache.cassandra.cql3.UntypedResultSet;
|
||||
import org.apache.cassandra.db.ColumnFamilyStore;
|
||||
import org.apache.cassandra.db.compaction.CompactionManager;
|
||||
import org.apache.cassandra.db.rows.Row;
|
||||
|
|
@ -46,7 +49,7 @@ import org.apache.cassandra.io.sstable.format.SSTableReader;
|
|||
import org.apache.cassandra.schema.CompactionParams.TombstoneOption;
|
||||
import org.apache.cassandra.utils.FBUtilities;
|
||||
|
||||
public class GcCompactionBench extends CQLTester
|
||||
public class GcCompactionBenchTest extends CQLTester
|
||||
{
|
||||
private static final String SIZE_TIERED_STRATEGY = "SizeTieredCompactionStrategy', 'min_sstable_size' : '0";
|
||||
private static final String LEVELED_STRATEGY = "LeveledCompactionStrategy', 'sstable_size_in_mb' : '16";
|
||||
|
|
@ -30,7 +30,7 @@ import org.junit.Test;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
public class BatchTests extends CQLTester
|
||||
public class BatchTest extends CQLTester
|
||||
{
|
||||
private static EmbeddedCassandraService cassandra;
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ import org.junit.runners.Parameterized;
|
|||
* KeywordTestSplitN to prevent CI timing out. If timeouts reappear split it further
|
||||
*/
|
||||
@RunWith(Parameterized.class)
|
||||
public class KeywordTestSplit1 extends KeywordTestBase
|
||||
public class KeywordSplit1Test extends KeywordTestBase
|
||||
{
|
||||
static int SPLIT = 1;
|
||||
static int TOTAL_SPLITS = 2;
|
||||
|
|
@ -38,7 +38,7 @@ public class KeywordTestSplit1 extends KeywordTestBase
|
|||
return KeywordTestBase.getKeywordsForSplit(SPLIT, TOTAL_SPLITS);
|
||||
}
|
||||
|
||||
public KeywordTestSplit1(String keyword, boolean isReserved)
|
||||
public KeywordSplit1Test(String keyword, boolean isReserved)
|
||||
{
|
||||
super(keyword, isReserved);
|
||||
}
|
||||
|
|
@ -28,7 +28,7 @@ import org.junit.runners.Parameterized;
|
|||
* KeywordTestSplitN to prevent CI timing out. If timeouts reappear split it further
|
||||
*/
|
||||
@RunWith(Parameterized.class)
|
||||
public class KeywordTestSplit2 extends KeywordTestBase
|
||||
public class KeywordSplit2Test extends KeywordTestBase
|
||||
{
|
||||
static int SPLIT = 2;
|
||||
static int TOTAL_SPLITS = 2;
|
||||
|
|
@ -38,7 +38,7 @@ public class KeywordTestSplit2 extends KeywordTestBase
|
|||
return KeywordTestBase.getKeywordsForSplit(SPLIT, TOTAL_SPLITS);
|
||||
}
|
||||
|
||||
public KeywordTestSplit2(String keyword, boolean isReserved)
|
||||
public KeywordSplit2Test(String keyword, boolean isReserved)
|
||||
{
|
||||
super(keyword, isReserved);
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ import org.apache.cassandra.exceptions.SyntaxException;
|
|||
* This class tests all keywords which took a long time. Hence it was split into multiple
|
||||
* KeywordTestSplitN to prevent CI timing out. If timeouts reappear split it further
|
||||
*/
|
||||
public class KeywordTestBase extends CQLTester
|
||||
public abstract class KeywordTestBase extends CQLTester
|
||||
{
|
||||
public static List<Object[]> keywords = Arrays.stream(CqlParser.tokenNames)
|
||||
.filter(k -> k.startsWith("K_"))
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ import static org.apache.cassandra.utils.ByteBufferUtil.EMPTY_BYTE_BUFFER;
|
|||
import static org.apache.cassandra.utils.ByteBufferUtil.bytes;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.reflections.util.Utils.isEmpty;
|
||||
|
||||
public class CompactStorageTest extends CQLTester
|
||||
{
|
||||
|
|
@ -4369,19 +4368,9 @@ public class CompactStorageTest extends CQLTester
|
|||
execute("UPDATE %s SET value = ? WHERE partitionKey = ? AND clustering_1 = ?", null, 0, 0);
|
||||
flush(forceFlush);
|
||||
|
||||
if (isEmpty(compactOption))
|
||||
{
|
||||
assertRows(execute("SELECT * FROM %s WHERE partitionKey = ? AND (clustering_1) IN ((?), (?))",
|
||||
0, 0, 1),
|
||||
row(0, 0, null),
|
||||
row(0, 1, 20));
|
||||
}
|
||||
else
|
||||
{
|
||||
assertRows(execute("SELECT * FROM %s WHERE partitionKey = ? AND (clustering_1) IN ((?), (?))",
|
||||
0, 0, 1),
|
||||
row(0, 1, 20));
|
||||
}
|
||||
assertRows(execute("SELECT * FROM %s WHERE partitionKey = ? AND (clustering_1) IN ((?), (?))",
|
||||
0, 0, 1),
|
||||
row(0, 1, 20));
|
||||
|
||||
// test invalid queries
|
||||
|
||||
|
|
|
|||
|
|
@ -35,11 +35,10 @@ import org.junit.Test;
|
|||
import com.google.common.collect.Sets;
|
||||
|
||||
import org.apache.cassandra.db.marshal.TimeUUIDType;
|
||||
import org.apache.cassandra.utils.UUIDGen;
|
||||
import org.cliffc.high_scale_lib.NonBlockingHashMap;
|
||||
|
||||
|
||||
public class UUIDTests
|
||||
public class UUIDTest
|
||||
{
|
||||
@Test
|
||||
public void verifyType1()
|
||||
Loading…
Reference in New Issue