mirror of https://github.com/apache/cassandra
Restore running each test class in its own separate jvm and cassandra directory
(Remove test parallelism from ant build.xml) patch by Mick Semb Wever; reviewed by Yifan Cai, David Capwell for CASSANDRA-16595
This commit is contained in:
parent
1185593907
commit
c52f50f046
66
build.xml
66
build.xml
|
|
@ -1268,6 +1268,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
|
||||
|
|
@ -1280,7 +1317,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"/>
|
||||
|
|
@ -1315,7 +1351,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"/>
|
||||
<jvmarg value="-Dcassandra.testtag=@{testtag}"/>
|
||||
<!-- The first time SecureRandom initializes can be slow if it blocks on /dev/random -->
|
||||
|
|
@ -1335,9 +1370,9 @@
|
|||
<filelist dir="@{inputdir}" files="@{filelist}"/>
|
||||
</batchtest>
|
||||
</junit>
|
||||
<delete quiet="true" failonerror="false" dir="${build.test.dir}/cassandra/commitlog:@{poffset}"/>
|
||||
<delete quiet="true" failonerror="false" dir="${build.test.dir}/cassandra/data:@{poffset}"/>
|
||||
<delete quiet="true" failonerror="false" dir="${build.test.dir}/cassandra/saved_caches:@{poffset}"/>
|
||||
<delete quiet="true" failonerror="false" dir="${build.test.dir}/cassandra/commitlog"/>
|
||||
<delete quiet="true" failonerror="false" dir="${build.test.dir}/cassandra/data"/>
|
||||
<delete quiet="true" failonerror="false" dir="${build.test.dir}/cassandra/saved_caches"/>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
|
|
@ -1410,7 +1445,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>
|
||||
|
|
@ -1436,7 +1470,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>
|
||||
|
|
@ -1479,8 +1512,8 @@
|
|||
<fileset dir="${test.unit.src}" excludes="**/pig/*.java" 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="msg-ser-gen-test" depends="build-test" description="Generates message serializations">
|
||||
|
|
@ -1740,13 +1773,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>
|
||||
|
|
@ -1767,8 +1799,8 @@
|
|||
<path id="all-test-classes-path">
|
||||
<fileset dir="${test.unit.src}" includes="**/${test.name}.java" excludes="**/pig/*.java **/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">
|
||||
|
|
@ -1787,16 +1819,16 @@
|
|||
<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="test-distributed" depends="build-test" description="Execute unit tests">
|
||||
|
|
|
|||
|
|
@ -1,63 +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();
|
||||
|
||||
|
||||
config.rpc_port += offset;
|
||||
config.native_transport_port += offset;
|
||||
config.storage_port += offset;
|
||||
|
||||
config.commitlog_directory += File.pathSeparator + offset;
|
||||
config.saved_caches_directory += File.pathSeparator + offset;
|
||||
for (int i = 0; i < config.data_file_directories.length; i++)
|
||||
config.data_file_directories[i] += File.pathSeparator + offset;
|
||||
|
||||
|
||||
return config;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue