Merge branch 'cassandra-3.0' into cassandra-3.11

This commit is contained in:
Mick Semb Wever 2021-04-16 00:41:55 +02:00
commit cca5ce56ac
No known key found for this signature in database
GPG Key ID: E91335D77E3E87CB
3 changed files with 55 additions and 100 deletions

View File

@ -1279,6 +1279,43 @@
</copy>
</target>
<!-- Run tests separately and report errors after and generate a junit report -->
<macrodef name="testhelper">
<attribute name="testdelegate"/>
<sequential>
<testhelper_ testdelegate="@{testdelegate}"/>
<fail message="Some test(s) failed.">
<condition>
<and>
<isset property="testfailed"/>
<not>
<isset property="ant.test.failure.ignore"/>
</not>
</and>
</condition>
</fail>
</sequential>
</macrodef>
<!-- Run a list of junit tasks but don't track errors or generate a report after
If a test fails the testfailed property will be set. All the tests are run using the testdelegate
macro that is specified as an attribute and they will be run sequentially in this ant process -->
<scriptdef name="testhelper_" language="javascript">
<attribute name="testdelegate"/>
<![CDATA[
sep = project.getProperty("path.separator");
all = project.getProperty("all-test-classes").split(sep);
var p = project.createTask('sequential');
for (i = 0; i < all.length; i++) {
if (all[i] == undefined) continue;
task = project.createTask( attributes.get("testdelegate") );
task.setDynamicAttribute( "test.file.list", "" + all[i]);
p.addTask(task);
}
p.perform();
]]>
</scriptdef>
<!-- Defines how to run a set of tests. If you change the defaults for attributes
you should also update them in testmacro.,
The two are split because the helper doesn't generate
@ -1291,7 +1328,6 @@
<attribute name="filter" default="**/${test.name}.java"/>
<attribute name="exclude" default="" />
<attribute name="filelist" default="" />
<attribute name="poffset" default="0"/>
<attribute name="testtag" default=""/>
<attribute name="usejacoco" default="no"/>
<attribute name="showoutput" default="false"/>
@ -1327,7 +1363,6 @@
<jvmarg value="-XX:SoftRefLRUPolicyMSPerMB=0" />
<jvmarg value="-Dcassandra.memtable_row_overhead_computation_step=100"/>
<jvmarg value="-Dcassandra.test.use_prepared=${cassandra.test.use_prepared}"/>
<jvmarg value="-Dcassandra.test.offsetseed=@{poffset}"/>
<jvmarg value="-Dcassandra.test.sstableformatdevelopment=true"/>
<!-- The first time SecureRandom initializes can be slow if it blocks on /dev/random -->
<jvmarg value="-Djava.security.egd=file:/dev/urandom" />
@ -1354,19 +1389,11 @@
</batchtest>
</junit-timeout>
<condition property="fileSep" value=";">
<os family="windows"/>
</condition>
<condition property="fileSep" else=":">
<isset property="fileSep"/>
</condition>
<fail unless="fileSep">Failed to set File Separator. This shouldn't happen.</fail>
<delete quiet="true" failonerror="false" dir="${build.test.dir}/cassandra/commitlog${fileSep}@{poffset}"/>
<delete quiet="true" failonerror="false" dir="${build.test.dir}/cassandra/cdc_raw${fileSep}@{poffset}"/>
<delete quiet="true" failonerror="false" dir="${build.test.dir}/cassandra/data${fileSep}@{poffset}"/>
<delete quiet="true" failonerror="false" dir="${build.test.dir}/cassandra/saved_caches${fileSep}@{poffset}"/>
<delete quiet="true" failonerror="false" dir="${build.test.dir}/cassandra/hints${fileSep}@{poffset}"/>
<delete quiet="true" failonerror="false" dir="${build.test.dir}/cassandra/commitlog"/>
<delete quiet="true" failonerror="false" dir="${build.test.dir}/cassandra/cdc_raw"/>
<delete quiet="true" failonerror="false" dir="${build.test.dir}/cassandra/data"/>
<delete quiet="true" failonerror="false" dir="${build.test.dir}/cassandra/saved_caches"/>
<delete quiet="true" failonerror="false" dir="${build.test.dir}/cassandra/hints"/>
</sequential>
</macrodef>
@ -1392,7 +1419,6 @@
<jvmarg value="-Dmigration-sstable-root=${test.data}/migration-sstables"/>
<jvmarg value="-Dcassandra.ring_delay_ms=1000"/>
<jvmarg value="-Dcassandra.tolerate_sstable_size=true"/>
<jvmarg value="-Dcassandra.config.loader=org.apache.cassandra.OffsetAwareConfigurationLoader"/>
<jvmarg value="-Dcassandra.skip_sync=true" />
</testmacrohelper>
</sequential>
@ -1417,7 +1443,6 @@
<jvmarg value="-Dcassandra.tolerate_sstable_size=true"/>
<jvmarg value="-Dcassandra.config=file:///${compressed_yaml}"/>
<jvmarg value="-Dcassandra.skip_sync=true" />
<jvmarg value="-Dcassandra.config.loader=org.apache.cassandra.OffsetAwareConfigurationLoader"/>
</testmacrohelper>
</sequential>
</macrodef>
@ -1439,7 +1464,6 @@
<jvmarg value="-Dcassandra.tolerate_sstable_size=true"/>
<jvmarg value="-Dcassandra.config=file:///${cdc_yaml}"/>
<jvmarg value="-Dcassandra.skip_sync=true" />
<jvmarg value="-Dcassandra.config.loader=org.apache.cassandra.OffsetAwareConfigurationLoader"/>
</testmacrohelper>
</sequential>
</macrodef>
@ -1484,16 +1508,16 @@
<fileset dir="${test.unit.src}" includes="**/${test.name}.java" />
<fileset dir="${test.distributed.src}" includes="**/${test.name}.java" />
</path>
<property name="test.file.list" refid="all-test-classes-path"/>
<testlist-compression test.file.list="${test.file.list}"/>
<property name="all-test-classes" refid="all-test-classes-path"/>
<testhelper testdelegate="testlist-compression" />
</target>
<target name="test-cdc" depends="build-test" description="Execute unit tests with change-data-capture enabled">
<path id="all-test-classes-path">
<fileset dir="${test.unit.src}" includes="**/${test.name}.java" />
</path>
<property name="test.file.list" refid="all-test-classes-path"/>
<testlist-cdc test.file.list="${test.file.list}"/>
<property name="all-test-classes" refid="all-test-classes-path"/>
<testhelper testdelegate="testlist-cdc" />
</target>
<target name="msg-ser-gen-test" depends="build-test" description="Generates message serializations">
@ -1709,13 +1733,12 @@
<attribute name="filter" default="**/${test.name}.java"/>
<attribute name="exclude" default="" />
<attribute name="filelist" default="" />
<attribute name="poffset" default="0"/>
<attribute name="testtag" default=""/>
<sequential>
<testmacrohelper inputdir="@{inputdir}" timeout="@{timeout}"
forkmode="@{forkmode}" filter="@{filter}"
exclude="@{exclude}" filelist="@{filelist}" poffset="@{poffset}"
exclude="@{exclude}" filelist="@{filelist}"
testtag="@{testtag}" showoutput="false" >
<optjvmargs/>
</testmacrohelper>
@ -1736,8 +1759,8 @@
<path id="all-test-classes-path">
<fileset dir="${test.unit.src}" includes="**/${test.name}.java" excludes="**/distributed/test/UpgradeTest*.java" />
</path>
<property name="test.file.list" refid="all-test-classes-path"/>
<testlist test.file.list="${test.file.list}"/>
<property name="all-test-classes" refid="all-test-classes-path"/>
<testhelper testdelegate="testlist"/>
</target>
<target name="generate-test-report" description="Generates JUnit's HTML report from results already in build/output">
@ -1756,24 +1779,24 @@
<path id="all-test-classes-path">
<fileset dir="${test.dir}/${test.classlistprefix}" includesfile="${test.classlistfile}"/>
</path>
<property name="test.file.list" refid="all-test-classes-path"/>
<testlist test.file.list="${test.file.list}"/>
<property name="all-test-classes" refid="all-test-classes-path"/>
<testhelper testdelegate="testlist"/>
</target>
<target name="testclasslist-compression" depends="build-test" description="Run tests given in file -Dtest.classlistfile (one-class-per-line, e.g. org/apache/cassandra/db/SomeTest.java)">
<path id="all-test-classes-path">
<fileset dir="${test.dir}/${test.classlistprefix}" includesfile="${test.classlistfile}"/>
</path>
<property name="test.file.list" refid="all-test-classes-path"/>
<testlist-compression test.file.list="${test.file.list}"/>
<property name="all-test-classes" refid="all-test-classes-path"/>
<testhelper testdelegate="testlist-compression"/>
</target>
<target name="testclasslist-cdc" depends="build-test" description="Run tests given in file -Dtest.classlistfile (one-class-per-line, e.g. org/apache/cassandra/db/SomeTest.java)">
<path id="all-test-classes-path">
<fileset dir="${test.dir}/${test.classlistprefix}" includesfile="${test.classlistfile}"/>
</path>
<property name="test.file.list" refid="all-test-classes-path"/>
<testlist-cdc test.file.list="${test.file.list}"/>
<property name="all-test-classes" refid="all-test-classes-path"/>
<testhelper testdelegate="testlist-cdc"/>
</target>
<target name="dtest-jar" depends="build-test, build" description="Create dtest-compatible jar, including all dependencies">

View File

@ -1,67 +0,0 @@
/**
* 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
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* 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;
import org.apache.cassandra.config.Config;
import org.apache.cassandra.config.YamlConfigurationLoader;
import org.apache.cassandra.exceptions.ConfigurationException;
import java.io.File;
public class OffsetAwareConfigurationLoader extends YamlConfigurationLoader
{
static final String OFFSET_PROPERTY = "cassandra.test.offsetseed";
int offset = 0;
public OffsetAwareConfigurationLoader()
{
String offsetStr = System.getProperty(OFFSET_PROPERTY);
if (offsetStr == null)
throw new RuntimeException("offset property is not set: "+OFFSET_PROPERTY);
offset = Integer.valueOf(offsetStr);
assert offset >= 0;
}
@Override
public Config loadConfig() throws ConfigurationException
{
Config config = super.loadConfig();
String sep = File.pathSeparator;
config.rpc_port += offset;
config.native_transport_port += offset;
config.storage_port += offset;
config.commitlog_directory += sep + offset;
config.saved_caches_directory += sep + offset;
config.hints_directory += sep + offset;
config.cdc_raw_directory += sep + offset;
for (int i = 0; i < config.data_file_directories.length; i++)
config.data_file_directories[i] += sep + offset;
return config;
}
}

View File

@ -125,7 +125,6 @@ public class DatabaseDescriptorRefTest
"org.apache.cassandra.utils.FBUtilities$1",
"org.apache.cassandra.utils.CloseableIterator",
"org.apache.cassandra.utils.Pair",
"org.apache.cassandra.OffsetAwareConfigurationLoader",
"org.apache.cassandra.ConsoleAppender",
"org.apache.cassandra.ConsoleAppender$1",
"org.apache.cassandra.LogbackStatusListener",