Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

DUnit tests are JUnit tests that extend CacheTestCase or DistributedTestCase and run code in more than one VM. Because these tests tend to involve multiple members in a distributed system, these tests are more prone to potential race conditions. Here are some tips for tracking down failures and fixing these tests.

Running a single junit test

 

Panel

./gradlew --no-daemon geode-core:test -Dtest.single=BucketRegionJUnitTest

 

 

Running a single dunit test

You can use the standard Gradle properties to run a single test. Or, better yet, run the test in your IDE to help you debug it.

...

Running a single hydra test, continously if necessary

We often need to reproduce a hydra test failure. The following scripts are very useful in practice. It can keep running one specific hydra test until it failed. I added another parameter to only stop when a specific failure happened.

 

There're following files: runbt.sh, local.conf, testforever.sh

 

  1. runbt.sh
Code Block
#! /bin/sh
exec 1>&1
exec 2>&1
exec 0>&1
set -v
date
##
rm batterytest.log
rm oneliner.txt
rm summ*.txt
################################################################################
# edit this section as desired to choose
#   1) java version
#   2) checkout directory
#   3) an open or closed build
JAVA_HOME=/export/gcm/where/jdk/1.8.0_45/x86_64.linux
checkoutDir=/export/aruba2/users/zhouxh/wan_develop/git3/gemfire
buildRoot=$checkoutDir     #  when build is redirected
 
# choose to run open or closed
# open
#buildType=open
#GEMFIRE=$buildRoot/$buildType/gemfire-assembly/build/install/geode
# closed
buildType=closed
GEMFIRE=$buildRoot/$buildType/pivotalgf-assembly/build/install/pivotal-gemfire
################################################################################
PATH=$JAVA_HOME/bin:$PATH
JTESTS=$buildRoot/closed/gemfire-test/build/resources/test
CLASSPATH=$GEMFIRE/lib/geode-core-9.0.0-SNAPSHOT.jar:$JTESTS:$JTESTS/../../classes/test:$JTESTS/../../classes/hydraClasses:$GEMFIRE/lib/gemfire-core-dependencies.jar:$GEMFIRE/lib/log4j-api-2.5.jar:$GEMFIRE/lib/log4j-core-2.5.jar:$JTESTS/../extraJars/groovy-all-2.4.3.jar
BT=batt.bt
if [ "$1" != "" ]; then
  BT="$1"
fi
echo "BT=$BT"
CONF=./local.conf
if [ "$2" != "" ]; then
  CONF="$2"
fi
echo "local.conf=$CONF"
java -cp $CLASSPATH \
  -DRELEASE_DIR=/export/gcm/where/gemfire/releases \
  -DprovideBugReportTemplate=true \
  -DprovideRegressionSummary=true \
  -DlocalConf=$CONF \
  -DmoveRemoteDirs=true \
  -DremovePassedTest=true \
  -DnukeHungTest=true \
  -DJTESTS=$JTESTS \
  -DGEMFIRE=$GEMFIRE \
  -DtestFileName=$BT \
  -DnumTimesToRun=1 batterytest.BatteryTest

 

2. local.conf

Code Block
// hydra.GemFirePrms-logLevel=fine;
// hydra.VmPrms-extraVMArgs = "-DDistributionManager.VERBOSE=true -ea";
// hydra.GemFirePrms-lockMemory = ONEOF true false FOENO;
// hydra.VmPrms-extraClassPaths += "$GEMFIRE/lib/jna-4.0.0.jar";
// hydra.GemFirePrms-extraLocatorClassPath += "$GEMFIRE/lib/jna-4.0.0.jar";
// hydra.Prms-maxResultWaitSec=1200;
// hydra.Prms-randomSeed=1427554905641;
// newWan.WANOperationsClientPrms-randModValueForDebug = true;
// hydra.RegionPrms-concurrencyChecksEnabled = true;

An advanced local.conf to run on multiple hosts using hostdirs. 

Code Block
hydra.HostPrms-hostNames =
  fcn "newWan.WanTestConfigFcns.pool(\"w2-2013-lin-03 w2-2013-lin-04 w2-2013-lin-14 w2-2013-lin-15\",  1, 4)" ncf
  fcn "newWan.WanTestConfigFcns.pool(\"w2-2013-lin-03 w2-2013-lin-04 w2-2013-lin-14 w2-2013-lin-15\",  1, 4)" ncf
  fcn "newWan.WanTestConfigFcns.pool(\"w2-2013-lin-03 w2-2013-lin-04 w2-2013-lin-14 w2-2013-lin-15\",  1, 4)" ncf
  ;
hydra.HostPrms-resourceDirBaseMapFileName = /home/xzhou/bin/hostdirs.prop;

 

3. testforever.sh

Code Block
#!/bin/bash
testfile=$1
testcase=$2
greppattern=$3
if [ "$testcase" = "" ]; then
    echo "Usage: ./testforever.sh testX.bt testcase [greppattern]"
    exit 1
fi
while [ 1 -eq 1 ]
do
./runbt.sh ${testfile}
if [ -f ${testcase}*/errors.txt ]; then
  date >> merged_errors.txt
  cat ${testcase}*/errors.txt >> merged_errors.txt
  if [ "$greppattern" != "" ]; then
    grep "${greppattern}" ${testcase}*/errors.txt
    if [ $? -eq 0 ]; then
      ${testcase}*/nukerun.sh
      break
    else
      ${testcase}*/nukerun.sh
      sleep 30
      rm -rf ${testcase}*
    fi
  else
    ${testcase}*/nukerun.sh
    break
  fi
else
    ${testcase}*/nukerun.sh
    sleep 30
    rm -rf ${testcase}*
fi
done


 

An example of using the scripts: 

 

If only to run it once:

 

./runbt.sh ./test52028.bt

 

To reproduce bug 52028, run:
 
./testforever.sh ./test52028.bt p2pEventTransportFilterHA 
 
It will run until the hydra test fails. 
 
However, it might fail due to other reasons, while I only care about reproducing NullPointerException. So run following command instead:
 
./testforever.sh test52028.bt p2pEventTransportFilterHA NullPointerException
 
Under current directory, you will find a merged_errors.txt file, which contains all the errors ever happened before the script detected a NullPointerException. 

 https://sites.google.com/a/pivotal.io/gem-engineering/process/issue-tracking/run-a-single-hydra-test