diff --git a/conf/samples/cassandra-3.11.4.properties b/conf/samples/cassandra-3.11.4.properties new file mode 100644 index 0000000..cbf51ed --- /dev/null +++ b/conf/samples/cassandra-3.11.4.properties @@ -0,0 +1,52 @@ +#Required (user-specific): +system_dir_path=/home/robertking/cc/OrderLab/T2C/OK-systems/cassandra +ticket_collection_path=${ok_dir}/conf/samples/cs-collections + +#Required (customized rule-related): +time_window_length_in_millis=5000 +#(deprecated) enable_full_instrument_mode=true +#select instrumentation range: strict-selective, relaxed-selective, specified_selective, full +gentrace_instrument_mode=relaxed-selective +verify_survivor_mode=false + +#Required (system related): +java_class_path="${system_dir_path}/build/classes/main/:${system_dir_path}/build/classes/thrift/:${system_dir_path}/lib/*:${system_dir_path}/build/lib/jars/*" +test_classes_dir_path="${system_dir_path}/build/test/classes/" +system_package_prefix=org.apache.cassandra +test_class_name_regex=.*Test$ +compile_test_cmd="ant clean build-test" +jvm_args_for_tests="-Dcassandra.config=file://${system_dir_path}/test/conf/cassandra.yaml \ +-Dlegacy-sstable-root=${system_dir_path}/test/data/legacy-sstables \ +-Dinvalid-legacy-sstable-root=${system_dir_path}/test/data/invalid-legacy-sstables \ +-Dcorrupt-sstable-root=${system_dir_path}/test/data/corrupt-sstables \ +-Dmigration-sstable-root=${system_dir_path}/test/data/migration-sstables \ +-Dcassandra.config.loader=org.apache.cassandra.OffsetAwareConfigurationLoader \ +-Dcassandra.ring_delay_ms=1000 \ +-Dcassandra.tolerate_sstable_size=true \ +-Dstorage-config=file://${system_dir_path}/test/conf/cassandra.yaml \ +-Dcassandra.skip_sync=true \ +-Dcassandra.memtable_row_overhead_computation_step=100 \ +-Dcassandra.test.use_prepared=true \ +-Dcassandra.test.offsetseed=0 \ +-Dcassandra.test.sstableformatdevelopment=true \ +-Djava.security.egd=file:/dev/urandom \ +-Dcassandra.testtag= \ +-Dcassandra.strict.runtime.checks=true" + +#Optional (testing-use): +verify_abort_after_three_test=false +force_instrument_nothing=false +force_track_no_states=true +force_disable_prod_checking=false +force_disable_enqueue_events=false +dump_suppress_inv_list_when_checking=false + +#Optional: +instrument_state_fields= +instrument_class_allmethods= +exclude_class_list=pl4c3h0ld3r_57r1n6 + +##in case you only want to run certain test classes, leave empty means run all +#specified_test_class_list=org.apache.zookeeper.test.ClientTest +##mark some test methods to be incapable to generate templates, these will still run but will not dump templates and will not counted in ratio +#excluded_test_method_list= diff --git a/conf/samples/cs-collections/CASSANDRA-10606.properties b/conf/samples/cs-collections/CASSANDRA-10606.properties new file mode 100644 index 0000000..b0832d8 --- /dev/null +++ b/conf/samples/cs-collections/CASSANDRA-10606.properties @@ -0,0 +1,6 @@ +# https://issues.apache.org/jira/browse/CASSANDRA-10606 +# https://github.com/apache/cassandra/commit/3615da58310a778c7ee6d9b2d77fd3fb7a6700f4 +commit_id=3615da58310a778c7ee6d9b2d77fd3fb7a6700f4 +test_name=org.apache.cassandra.db.partition.PartitionUpdateTest +test_trace_prefix=org.apache.cassandra.db.partition.PartitionUpdateTest +compile_test_cmd="cp ${ok_dir}/conf/samples/cs-patches/build.properties.default . && git apply ${ok_dir}/conf/samples/cs-patches/repo.patch && ant clean build-test" diff --git a/conf/samples/cs-collections/CASSANDRA-11803.properties b/conf/samples/cs-collections/CASSANDRA-11803.properties new file mode 100644 index 0000000..d284189 --- /dev/null +++ b/conf/samples/cs-collections/CASSANDRA-11803.properties @@ -0,0 +1,8 @@ +# https://issues.apache.org/jira/browse/CASSANDRA-11803 +# https://github.com/apache/cassandra/commit/bc9a0793944f7dd481646c4014d13b844439906c +commit_id=bc9a0793944f7dd481646c4014d13b844439906c +test_name=org.apache.cassandra.cql3.ReservedKeywordsTest +test_trace_prefix=org.apache.cassandra.cql3.ReservedKeywordsTest +compile_test_cmd="cp ${ok_dir}/conf/samples/cs-patches/build.properties.default . && git apply ${ok_dir}/conf/samples/cs-patches/repo.patch && ant clean build-test" + +# tag: no suitable template, and hard to make one diff --git a/conf/samples/cs-collections/CASSANDRA-13174.properties b/conf/samples/cs-collections/CASSANDRA-13174.properties new file mode 100644 index 0000000..d8db7be --- /dev/null +++ b/conf/samples/cs-collections/CASSANDRA-13174.properties @@ -0,0 +1,8 @@ +# https://issues.apache.org/jira/browse/CASSANDRA-13174 +# https://github.com/apache/cassandra/commit/6487876dde14c46d5753f972909e5acec854cb53 +commit_id=6487876dde14c46d5753f972909e5acec854cb53 +test_name=org.apache.cassandra.cql3.validation.operations.SelectTest +test_trace_prefix=org.apache.cassandra.cql3.validation.operations.SelectTest@testFilteringOnDurationColumn +compile_test_cmd="cp ${ok_dir}/conf/samples/cs-patches/build.properties.default . && git apply ${ok_dir}/conf/samples/cs-patches/repo.patch && ant clean build-test" + +# tag: non-semantic (failure signal) diff --git a/conf/samples/cs-collections/CASSANDRA-13246.properties b/conf/samples/cs-collections/CASSANDRA-13246.properties new file mode 100644 index 0000000..d454544 --- /dev/null +++ b/conf/samples/cs-collections/CASSANDRA-13246.properties @@ -0,0 +1,8 @@ +# https://issues.apache.org/jira/browse/CASSANDRA-13246 +# https://github.com/apache/cassandra/commit/0eebc6e6b7cd7fc801579e57701608e7bf155ee0 +commit_id=0eebc6e6b7cd7fc801579e57701608e7bf155ee0 +test_name=org.apache.cassandra.cql3.validation.entities.SecondaryIndexTest +test_trace_prefix=org.apache.cassandra.cql3.validation.entities.SecondaryIndexTest@testSelectOnMultiIndexOnCollectionsWithNull +compile_test_cmd="cp ${ok_dir}/conf/samples/cs-patches/build.properties.default . && git apply ${ok_dir}/conf/samples/cs-patches/repo.patch && ant clean build-test" + +# tag: non-semantic, failure signal diff --git a/conf/samples/cs-collections/CASSANDRA-13691.properties b/conf/samples/cs-collections/CASSANDRA-13691.properties new file mode 100644 index 0000000..cd7b7e6 --- /dev/null +++ b/conf/samples/cs-collections/CASSANDRA-13691.properties @@ -0,0 +1,10 @@ +# https://issues.apache.org/jira/browse/CASSANDRA-13691 +# https://github.com/apache/cassandra/commit/ba71289778369e71d9abbdb93cb6b91ba67f9c85 +commit_id=ba71289778369e71d9abbdb93cb6b91ba67f9c85 +test_name=org.apache.cassandra.db.context.CounterContextTest +test_trace_prefix=org.apache.cassandra.db.context.CounterContextTest@testCounterUpdate +compile_test_cmd="cp ${ok_dir}/conf/samples/cs-patches/build.properties.default . && git apply ${ok_dir}/conf/samples/cs-patches/repo.patch && ant clean build-test" + +# RK: probably won't use +# tag: upgrade +# dtest in 55c4ca8bd450b81da6eed5055981b629b55dea15 diff --git a/conf/samples/cs-collections/CASSANDRA-13730.properties b/conf/samples/cs-collections/CASSANDRA-13730.properties new file mode 100644 index 0000000..2711f00 --- /dev/null +++ b/conf/samples/cs-collections/CASSANDRA-13730.properties @@ -0,0 +1,6 @@ +# https://issues.apache.org/jira/browse/CASSANDRA-13730 +# https://github.com/apache/cassandra/commit/d9eabd3d0cbf1287aa7d01bc23dd8e39c3acf232 +commit_id=d9eabd3d0cbf1287aa7d01bc23dd8e39c3acf232 +test_name=org.apache.cassandra.cql3.validation.operations.DropTest +test_trace_prefix=org.apache.cassandra.cql3.validation.operations.DropTest@testDropTableWithDroppedColumns +compile_test_cmd="cp ${ok_dir}/conf/samples/cs-patches/build.properties.default . && git apply $[ok_dir]/conf/samples/cs-patches/repo.patch && ant clean build-test" diff --git a/conf/samples/cs-collections/CASSANDRA-14937.properties.invalid b/conf/samples/cs-collections/CASSANDRA-14937.properties.invalid new file mode 100644 index 0000000..1297fd8 --- /dev/null +++ b/conf/samples/cs-collections/CASSANDRA-14937.properties.invalid @@ -0,0 +1,8 @@ +# This is a feature ticket, and not a regression test, but still put here for +# future reference. +# https://issues.apache.org/jira/browse/CASSANDRA-14937 +#case specific +commit_id=c100f1ac40137a0d6d0793930cdfce3845880a12 +test_name=org.apache.cassandra.distributed.upgrade.UpgradeTest +test_trace_prefix=org.apache.cassandra.distributed.upgrade.UpgradeTest +compile_test_cmd="cp ${ok_dir}/conf/samples/cs-patches/build.properties.default . && git apply ${ok_dir}/conf/samples/cs-patches/repo.patch && ant clean build-test" diff --git a/conf/samples/cs-collections/CASSANDRA-15072.properties.invalid b/conf/samples/cs-collections/CASSANDRA-15072.properties.invalid new file mode 100644 index 0000000..d3068a1 --- /dev/null +++ b/conf/samples/cs-collections/CASSANDRA-15072.properties.invalid @@ -0,0 +1,7 @@ +# https://issues.apache.org/jira/browse/CASSANDRA-15072 +# pregen_cmd="git reset --hard && git checkout 63ff65a8dd3a31e500ae5ec6232f1f9eade6fa3d && ant dtest-jar && ant clean" + +commit_id=d27c3ad0d2d006a5f156f0a2f2a24286d31c5069 +test_name=org.apache.cassandra.distributed.upgrade.CompactStorage2to3UpgradeTest +test_trace_prefix=org.apache.cassandra.distributed.upgrade.CompactStorage2to3UpgradeTest +compile_test_cmd="cp ${ok_dir}/conf/samples/cs-patches/build.properties.default . && git apply ${ok_dir}/conf/samples/cs-patches/{repo.patch,NPE.patch} && ant clean dtest-jar" diff --git a/conf/samples/cs-collections/CASSANDRA-8558.properties b/conf/samples/cs-collections/CASSANDRA-8558.properties new file mode 100644 index 0000000..1c93c3d --- /dev/null +++ b/conf/samples/cs-collections/CASSANDRA-8558.properties @@ -0,0 +1,8 @@ +# https://issues.apache.org/jira/browse/CASSANDRA-8558 +# https://github.com/apache/cassandra/commit/1c9c47d26f2da98d1a923254858bcde550122445 +commit_id=1c9c47d26f2da98d1a923254858bcde550122445 +test_name=org.apache.cassandra.cql3.RangeDeletionTest +test_trace_prefix=org.apache.cassandra.cql3.RangeDeletionTest +compile_test_cmd="cp ${ok_dir}/conf/samples/cs-patches/build.properties.default . && git apply ${ok_dir}/conf/samples/cs-patches/repo.patch && ant clean build-test" + +# tag: Cassandra v2 diff --git a/conf/samples/cs-collections/CASSANDRA-9540.properties b/conf/samples/cs-collections/CASSANDRA-9540.properties new file mode 100644 index 0000000..c9d9e07 --- /dev/null +++ b/conf/samples/cs-collections/CASSANDRA-9540.properties @@ -0,0 +1,8 @@ +# https://issues.apache.org/jira/browse/CASSANDRA-9540 +# https://github.com/apache/cassandra/commit/d6c37bdd18b2632ea9093f2422a0cfa723e36b96 +commit_id=d6c37bdd18b2632ea9093f2422a0cfa723e36b96 +test_name=org.apache.cassandra.cql3.LargeCompactValueTest +test_trace_prefix=org.apache.cassandra.cql3.LargeCompactValueTest +compile_test_cmd="cp ${ok_dir}/conf/samples/cs-patches/build.properties.default . && git apply ${ok_dir}/conf/samples/cs-patches/repo.patch && ant clean build-test" + +# tag: semantic, v2 diff --git a/conf/samples/cs-collections/gentmpl.sh b/conf/samples/cs-collections/gentmpl.sh new file mode 100755 index 0000000..cc5bf58 --- /dev/null +++ b/conf/samples/cs-collections/gentmpl.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +if [[ $# < 3 ]]; then + echo Expected 3 arguments and 1 optional, found $# + echo 'Usage example: gentmpl.sh 11803 bc9a0793944f7dd481646c4014d13b844439906c org.apache.cassandra.cql3.ReservedKeywordsTest [methodName]' + exit 1 +fi + +ticket_id=$1 +commit_id=$2 +test_name=$3 + +if ![[ "$ticket_id" =~ ^CASSANDRA.*$ ]]; then + ticket_id=CASSANDRA-${ticket_id} +fi + +if [[ "$test_name" =~ .java$ ]]; then + test_name=$(echo $test_name | perl -pe 's/.*(org.*).java/\1/ and s/\//./g') +fi + +prefix=$test_name +if [[ $# > 3 ]]; then + prefix="${prefix}@$4" +fi + +cat > ${ticket_id}.properties < +Date: Thu Apr 25 15:18:07 2019 -0700 + + ninja: fix CASSANDRA-15078 NPE + +diff --git a/test/distributed/org/apache/cassandra/distributed/impl/AbstractCluster.java b/test/distributed/org/apache/cassandra/distributed/impl/AbstractCluster.java +index 1dc7a657fa..c27d9bf2d8 100644 +--- a/test/distributed/org/apache/cassandra/distributed/impl/AbstractCluster.java ++++ b/test/distributed/org/apache/cassandra/distributed/impl/AbstractCluster.java +@@ -141,7 +141,7 @@ public abstract class AbstractCluster implements ICluster, + { + if (!isShutdown) + throw new IllegalStateException(); +- delegate.startup(AbstractCluster.this); ++ delegate().startup(AbstractCluster.this); + isShutdown = false; + updateMessagingVersions(); + } diff --git a/conf/samples/cs-patches/build.properties.default b/conf/samples/cs-patches/build.properties.default new file mode 100644 index 0000000..0144f14 --- /dev/null +++ b/conf/samples/cs-patches/build.properties.default @@ -0,0 +1,3 @@ +# Maven2 Repository Locations (you can override these in "build.properties" to point to a local proxy, e.g. Nexus) +artifact.remoteRepository.central: https://repo1.maven.org/maven2 +artifact.remoteRepository.apache: https://repository.apache.org/content/repositories/releases diff --git a/conf/samples/cs-patches/repo.patch b/conf/samples/cs-patches/repo.patch new file mode 100644 index 0000000..93d5cfa --- /dev/null +++ b/conf/samples/cs-patches/repo.patch @@ -0,0 +1,13 @@ +diff --git a/build.xml b/build.xml +index 94b07f3396..c08105d9d2 100644 +--- a/build.xml ++++ b/build.xml +@@ -86,7 +86,7 @@ + + + ++ value="https://repo1.maven.org/maven2/org/apache/maven/maven-ant-tasks" /> + + + diff --git a/conf/samples/hbase-1.3.1.properties b/conf/samples/hbase-1.3.1.properties index 9434d61..659f5a6 100644 --- a/conf/samples/hbase-1.3.1.properties +++ b/conf/samples/hbase-1.3.1.properties @@ -26,6 +26,7 @@ test_classes_dir_path="${system_dir_path}/hbase-server/target/test-classes/" system_package_prefix=org.apache.hadoop.hbase test_class_name_regex=Test.* compile_test_cmd="mvn clean package -DskipTests" +jvm_args_for_tests= #Optional (testing-use): verify_abort_after_three_test=false diff --git a/conf/samples/hbase-2.4.properties b/conf/samples/hbase-2.4.properties index 7aa88b2..3d8f42c 100644 --- a/conf/samples/hbase-2.4.properties +++ b/conf/samples/hbase-2.4.properties @@ -44,6 +44,7 @@ test_classes_dir_path="${system_dir_path}/hbase-server/target/test-classes/" system_package_prefix=org.apache.hadoop.hbase. test_class_name_regex=Test.* compile_test_cmd="mvn clean package -DskipTests" +jvm_args_for_tests= #Optional (testing-use): verify_abort_after_three_test=false diff --git a/conf/samples/hdfs-3.2.1.properties b/conf/samples/hdfs-3.2.1.properties index 2588a2d..937b922 100644 --- a/conf/samples/hdfs-3.2.1.properties +++ b/conf/samples/hdfs-3.2.1.properties @@ -19,6 +19,7 @@ hadoop-common-project/hadoop-nfs,hadoop-common-project/hadoop-kms,\ hadoop-hdfs-project/hadoop-hdfs,\ hadoop-hdfs-project/hadoop-hdfs-client,hadoop-hdfs-project/hadoop-hdfs-httpfs,hadoop-hdfs-project/hadoop-hdfs-native-client,\ hadoop-hdfs-project/hadoop-hdfs-nfs,hadoop-hdfs-project/hadoop-hdfs-rbf -am" +jvm_args_for_tests= #Optional (testing-use): verify_abort_after_three_test=false diff --git a/conf/samples/kafka-0.10.0.0.properties b/conf/samples/kafka-0.10.0.0.properties index 6e9b112..a0d4f0f 100644 --- a/conf/samples/kafka-0.10.0.0.properties +++ b/conf/samples/kafka-0.10.0.0.properties @@ -15,6 +15,7 @@ test_classes_dir_path="${system_dir_path}/core/build/classes/scala/test/" system_package_prefix=kafka. test_class_name_regex=.*Test$ compile_test_cmd="./gradlew jar" +jvm_args_for_tests= #Optional (testing-use): verify_abort_after_three_test=false diff --git a/conf/samples/kafka-2.6.properties b/conf/samples/kafka-2.6.properties index 2a04da6..e940bd7 100644 --- a/conf/samples/kafka-2.6.properties +++ b/conf/samples/kafka-2.6.properties @@ -18,6 +18,7 @@ test_classes_dir_path="${system_dir_path}/core/build/classes/scala/test/" system_package_prefix=kafka. test_class_name_regex=.*Test$ compile_test_cmd="gradle && ./gradlew jar" +jvm_args_for_tests= #Optional (testing-use): verify_abort_after_three_test=false diff --git a/conf/samples/zk-3.6.1.properties b/conf/samples/zk-3.6.1.properties index 9a517b4..766e42c 100644 --- a/conf/samples/zk-3.6.1.properties +++ b/conf/samples/zk-3.6.1.properties @@ -15,6 +15,7 @@ test_classes_dir_path="${system_dir_path}/build/test/classes/" system_package_prefix=org.apache.zookeeper test_class_name_regex=.*Test$ compile_test_cmd="ant clean compile-test" +jvm_args_for_tests= #Optional (testing-use): verify_abort_after_three_test=false diff --git a/run_engine.sh b/run_engine.sh index ae51661..f00df81 100755 --- a/run_engine.sh +++ b/run_engine.sh @@ -76,20 +76,16 @@ gentrace_test () { cd ${system_dir_path} || return echo "full_class_path: ${full_class_path}" echo "gentrace_test:" - echo "java -cp ${full_class_path} \ - -Xmx8g \ - -Dok.testname=${test_name} -Dok.invmode=dump -Dok.patchstate=${patchstate} \ - -Dok.conf=${conf_file_realpath} -Dok.filediff="${diff_file_list}" -Dlog4j.configuration=${log4j_conf} \ - -Dok.ok_root_abs_path=${ok_dir} -Dok.target_system_abs_path=${system_dir_path} \ - -Dok.test_trace_prefix=${test_trace_prefix} \ - -Dok.ticket_id=${ticket_id} oathkeeper.engine.tester.TestEngine" + (set -x; timeout ${single_command_timeout_threshold} java -cp ${full_class_path} \ -Xmx8g \ -Dok.testname=${test_name} -Dok.invmode=dump -Dok.patchstate=${patchstate} \ -Dok.conf=${conf_file_realpath} -Dok.filediff="${diff_file_list}" -Dlog4j.configuration=${log4j_conf} \ -Dok.ok_root_abs_path=${ok_dir} -Dok.target_system_abs_path=${system_dir_path} \ -Dok.test_trace_prefix=${test_trace_prefix} \ - -Dok.ticket_id=${ticket_id} oathkeeper.engine.tester.TestEngine + -Dok.ticket_id=${ticket_id} \ + ${jvm_args_for_tests} \ + oathkeeper.engine.tester.TestEngine) if [ $? -eq 124 ] then @@ -149,16 +145,12 @@ infer () ticket_id=$(basename $ticket_file_path) ticket_id="${ticket_id%.*}" - echo "java -cp ${full_class_path} -Dok.conf=${conf_file_realpath} \ - -Dok.ok_root_abs_path=${ok_dir} -Dok.target_system_abs_path=${system_dir_path} \ - -Dok.ticket_id=${ticket_id} \ - -Dok.template_version=${template_version} \ - oathkeeper.engine.InferEngine ${test_trace_prefix}" + (set -x; timeout ${single_command_timeout_threshold} java -cp ${full_class_path} -Dok.conf=${conf_file_realpath} \ -Dok.ok_root_abs_path=${ok_dir} -Dok.target_system_abs_path=${system_dir_path} \ -Dok.ticket_id=${ticket_id} \ -Dok.template_version=${template_version} \ - oathkeeper.engine.InferEngine ${test_trace_prefix} + oathkeeper.engine.InferEngine ${test_trace_prefix}) if [ $? -eq 124 ] then @@ -188,16 +180,14 @@ verify () #recalculate once in case this case customize full_class_path=${test_classes_dir_path}:${java_class_path}:${ok_lib} - echo "java -cp ${full_class_path} -Dok.invmode=${invmode} -Dok.invfile=${test_name} -Dok.patchstate=patched \ - -Dok.conf=${conf_file_realpath} -Dlog4j.configuration=${log4j_conf} \ - -Dok.ok_root_abs_path=${ok_dir} -Dok.target_system_abs_path=${system_dir_path} \ - -Dok.ticket_id=${ticket_id} -Dok.verify_test_package=${verify_test_package} \ - oathkeeper.engine.tester.TestEngine" + (set -x; timeout ${single_command_timeout_threshold} java -cp ${full_class_path} -Dok.invmode=${invmode} -Dok.invfile=${test_name} -Dok.patchstate=patched \ -Dok.conf=${conf_file_realpath} -Dlog4j.configuration=${log4j_conf} \ -Dok.ok_root_abs_path=${ok_dir} -Dok.target_system_abs_path=${system_dir_path} \ -Dok.ticket_id=${ticket_id} -Dok.verify_test_package=${verify_test_package} \ - oathkeeper.engine.tester.TestEngine + oathkeeper.engine.tester.TestEngine) + # jvm_args_for_tests does not need to be set here. TestEngine main mode + # will spawn child with jvm_args_for_tests according to properties file. if [ $? -eq 124 ] then diff --git a/src/main/java/oathkeeper/engine/tester/TestEngine.java b/src/main/java/oathkeeper/engine/tester/TestEngine.java index 07cfe48..b04202f 100644 --- a/src/main/java/oathkeeper/engine/tester/TestEngine.java +++ b/src/main/java/oathkeeper/engine/tester/TestEngine.java @@ -11,8 +11,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintStream; -import java.util.ArrayList; -import java.util.List; +import java.util.*; import java.util.concurrent.TimeUnit; /** @@ -63,7 +62,7 @@ public int spawnProcess(String klass) throws IOException, String rootPath = System.getProperty("user.dir"); - ProcessBuilder builder = new ProcessBuilder( + List cmds = new ArrayList<>(Arrays.asList( javaBin, "-cp", classpath, "-Dok.testname="+klass, "-Dok.invmode="+System.getProperty("ok.invmode"), @@ -78,7 +77,13 @@ public int spawnProcess(String klass) throws IOException, "-Dok.target_system_abs_path="+System.getProperty("ok.target_system_abs_path"), "-Dok.test_trace_prefix="+System.getProperty("ok.test_trace_prefix"), "-Dok.verify_test_package="+System.getProperty("ok.verify_test_package"), - className); + )); + + String jvm_args = ConfigManager.config.getString(ConfigManager.JVM_ARGS_FOR_TESTS_KEY); + if (!jvm_args.equals("")) + cmds.addAll(Arrays.asList(jvm_args.split("\\s+"))); + cmds.add(className); + ProcessBuilder builder = new ProcessBuilder(cmds); Process process = builder.inheritIO().start(); //set the timeout threshold to be @@ -209,4 +214,4 @@ else if(System.getProperty("ok.invmode").equals("verify_baremetal")) } } } -} \ No newline at end of file +} diff --git a/src/main/java/oathkeeper/runtime/ConfigManager.java b/src/main/java/oathkeeper/runtime/ConfigManager.java index 9231a7a..cf5a42a 100644 --- a/src/main/java/oathkeeper/runtime/ConfigManager.java +++ b/src/main/java/oathkeeper/runtime/ConfigManager.java @@ -30,6 +30,7 @@ enum InstrumentMode public static String SYSTEM_DIR_PATH_KEY = "system_dir_path"; public static String SYSTEM_PACKAGE_PREFIX_KEY = "system_package_prefix"; public static String TEST_CLASS_NAME_REGEX_KEY = "test_class_name_regex"; + public static String JVM_ARGS_FOR_TESTS_KEY = "jvm_args_for_tests"; public static String SPECIFIED_TEST_CLASS_LIST_KEY = "specified_test_class_list"; public static String EXCLUDED_TEST_METHOD_LIST_KEY = "excluded_test_method_list"; public static String OP_INTERFACE_CLASS_LIST_KEY = "op_interface_class_list"; @@ -65,6 +66,10 @@ public void initConfig() { String system_dir_path = config.getString(SYSTEM_DIR_PATH_KEY); String prefix = config.getString(SYSTEM_PACKAGE_PREFIX_KEY); String regex = config.getString(TEST_CLASS_NAME_REGEX_KEY); + // trim double quote + config.setProperty(JVM_ARGS_FOR_TESTS_KEY, + config.getString(JVM_ARGS_FOR_TESTS_KEY).replaceAll("^\"|\"$", "")); + String jvm_args = config.getString(JVM_ARGS_FOR_TESTS_KEY); String[] specifiedClassList = config.getStringArray(SPECIFIED_TEST_CLASS_LIST_KEY); String[] excludedMethodList = config.getStringArray(EXCLUDED_TEST_METHOD_LIST_KEY); String[] interfaceClassList = config.getStringArray(OP_INTERFACE_CLASS_LIST_KEY); @@ -89,6 +94,7 @@ public void initConfig() { System.out.println(SYSTEM_DIR_PATH_KEY + ":" + system_dir_path); System.out.println(SYSTEM_PACKAGE_PREFIX_KEY + ":" + prefix); System.out.println(TEST_CLASS_NAME_REGEX_KEY + ":" + regex); + System.out.println(JVM_ARGS_FOR_TESTS_KEY + ":" + jvm_args); System.out.println(SPECIFIED_TEST_CLASS_LIST_KEY + ":" + Arrays.toString(specifiedClassList)); System.out.println(EXCLUDED_TEST_METHOD_LIST_KEY + ":" + Arrays.toString(excludedMethodList)); System.out.println(OP_INTERFACE_CLASS_LIST_KEY + ":" + Arrays.toString(interfaceClassList)); diff --git a/src/main/java/oathkeeper/runtime/DynamicClassModifier.java b/src/main/java/oathkeeper/runtime/DynamicClassModifier.java index b5d6268..fdfbb2e 100644 --- a/src/main/java/oathkeeper/runtime/DynamicClassModifier.java +++ b/src/main/java/oathkeeper/runtime/DynamicClassModifier.java @@ -95,7 +95,17 @@ private void initFromDiffFileFromCommit(boolean appendUsage) Reflections reflections = new Reflections(prefix, new SubTypesScanner(false)); - Set allClasses = reflections.getAllTypes(); + Set allClasses; + try { + allClasses = reflections.getAllTypes(); + } catch (org.reflections8.ReflectionsException e) { + System.out.println("Reflection cannot find class: " + clazz); + e.printStackTrace(); + continue; + } + System.out.print("Reflection successfully get classes: "); + System.out.println(allClasses); + for(String clazz2:allClasses) { opInstClasses.add(clazz2); @@ -244,6 +254,7 @@ private void appendTrackedStates() { total++; cc.defrost(); } catch (Exception e) { + System.out.println("appendTrackedStates failed on class: " + clazz); e.printStackTrace(); } } @@ -425,7 +436,7 @@ public void modifyOperationEntry(Set allowedSet) { continue; } succMethodCounter += localCounter; - System.out.println("prepare for " + cName); + // System.out.println("prepare for " + cName); } System.out.println("succMethodCounter" + succMethodCounter + " failClassCounter" + failClassCounter); @@ -576,7 +587,7 @@ public void modifyStateAccess(Set allowedSet) { continue; } succMethodCounter += localCounter; - System.out.println("prepare for " + cName); + // System.out.println("prepare for " + cName); } System.out.println("succMethodCounter" + succMethodCounter + " failClassCounter" + failClassCounter); @@ -586,6 +597,8 @@ public void writeToClasses() { for (CtClass ctClass : toDumpClasses.values()) { try { ctClass.toClass(); + } catch (javassist.CannotCompileException ex) { + // ex.printStackTrace(); } catch (Exception ex) { ex.printStackTrace(); } @@ -637,7 +650,7 @@ public void markEndOfTestMethods() System.err.println("potential hints: reorder the class loading to bring forward oathkeeper javassist, this might be a conflict between oathkeeper and target system dependency"); } } - System.out.println("prepare for test " + testName); + // System.out.println("prepare for test " + testName); } System.out.println("suppress " + errCounters+" no method body errors in markEndOfTestMethods()");