Merge branch 'cassandra-3.11' into trunk

This commit is contained in:
Mick Semb Wever 2021-04-16 00:43:30 +02:00
commit 65b6dfa822
No known key found for this signature in database
GPG Key ID: E91335D77E3E87CB
3 changed files with 61 additions and 145 deletions

100
build.xml
View File

@ -1304,6 +1304,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
@ -1316,7 +1353,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"/>
@ -1356,7 +1392,6 @@
<jvmarg value="-Dcassandra.test.driver.read_timeout_ms=${test.driver.read_timeout_ms}"/>
<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" />
@ -1392,24 +1427,16 @@
</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/system_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/system_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>
<target name="testold" depends="build-test" description="Execute unit tests">
<target name="testold" depends="build-test" description="Execute unit tests">
<testmacro inputdir="${test.unit.src}" timeout="${test.timeout}">
<jvmarg value="-Dlegacy-sstable-root=${test.data}/legacy-sstables"/>
<jvmarg value="-Dinvalid-legacy-sstable-root=${test.data}/invalid-legacy-sstables"/>
@ -1429,7 +1456,6 @@
<jvmarg value="-Dinvalid-legacy-sstable-root=${test.data}/invalid-legacy-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>
@ -1453,7 +1479,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>
@ -1474,7 +1499,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>
@ -1495,7 +1519,6 @@
<jvmarg value="-Dcassandra.tolerate_sstable_size=true"/>
<jvmarg value="-Dcassandra.config=file:///${system_keyspaces_directory_yaml}"/>
<jvmarg value="-Dcassandra.skip_sync=true" />
<jvmarg value="-Dcassandra.config.loader=org.apache.cassandra.OffsetAwareConfigurationLoader"/>
</testmacrohelper>
</sequential>
</macrodef>
@ -1555,24 +1578,24 @@
<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="test-system-keyspace-directory" depends="build-test" description="Execute unit tests with a system keyspaces directory configured">
<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-system-keyspace-directory test.file.list="${test.file.list}"/>
<property name="all-test-classes" refid="all-test-classes-path"/>
<testhelper testdelegate="testlist-system-keyspace-directory" />
</target>
<target name="msg-ser-gen-test" depends="build-test" description="Generates message serializations">
@ -1784,13 +1807,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>
@ -1811,8 +1833,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">
@ -1831,29 +1853,29 @@
<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="testclasslist-system-keyspace-directory" 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-system-keyspace-directory test.file.list="${test.file.list}"/>
<property name="all-test-classes" refid="all-test-classes-path"/>
<testhelper testdelegate="testlist-system-keyspace-directory"/>
</target>
<!-- Build a self-contained jar for e.g. remote execution; not currently used for running burn tests with this build script -->

View File

@ -1,105 +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 org.apache.cassandra.locator.InetAddressAndPort;
import java.io.File;
import java.net.Inet6Address;
import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.stream.Collectors;
import com.google.common.base.Joiner;
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;
assert offset < 2000;
config.native_transport_port += offset;
if (config.native_transport_port_ssl != null)
config.native_transport_port_ssl += offset;
config.storage_port += offset;
config.ssl_storage_port += offset;
//Rewrite the seed ports string
String[] hosts = config.seed_provider.parameters.get("seeds").split(",", -1);
String rewrittenSeeds = Joiner.on(", ").join(Arrays.stream(hosts).map(host -> {
StringBuilder sb = new StringBuilder();
try
{
InetAddressAndPort address = InetAddressAndPort.getByName(host.trim());
if (address.address instanceof Inet6Address)
{
sb.append('[').append(address.address.getHostAddress()).append(']');
}
else
{
sb.append(address.address.getHostAddress());
}
sb.append(':').append(address.port + offset);
return sb.toString();
}
catch (UnknownHostException e)
{
throw new ConfigurationException("Error in OffsetAwareConfigurationLoader reworking seed list", e);
}
}).collect(Collectors.toList()));
config.seed_provider.parameters.put("seeds", rewrittenSeeds);
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;
if (config.local_system_data_file_directory != null)
config.local_system_data_file_directory += sep + offset;
return config;
}
}

View File

@ -149,7 +149,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",