public class TestHelper extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
EVENT_ERROR_KEY |
static long |
MICRO_NANO_FACTOR |
static int |
MICROS |
static long |
MILLI_MICRO_FACTOR |
static long |
MILLI_NANO_FACTOR |
static int |
MILLIS |
static int |
NANOS |
static long |
SEC_MILLI_FACTOR |
static long |
SEC_NANO_FACTOR |
static int |
SECONDS |
| Constructor and Description |
|---|
TestHelper() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
borderCase(Long paramKey) |
static int |
calculateStringSize(String aStr)
Calculate the size of a String (often used by the tests for a key)
for use by tests that track bytes for eviction.
|
static void |
checkForEventError(Blackboard bb)
Using TestHelper.EVENT_ERROR_KEY, look in the sharedMap of the given
blackboard for any error strings and throw an error if found.
|
static Object |
createInstance(Class aClass)
Create an instance of the given class.
|
static Object |
createInstance(String className)
Create an instance of the given class name.
|
static Throwable |
findCause(Throwable aThrowable,
Class type)
Get the first Throwable in the cause chain of aThrowable that is
an instanceof type.
|
static String |
format(double adouble,
int placesBeforeDecimal,
int placesAfterDecimal)
Format the given double as a string.
|
static String |
format(long along,
int places)
Format a long and return it as a String.
|
static Set |
getAllKeys(com.gemstone.gemfire.cache.Region aRegion)
Given a region, return a set containing all keys in the region and all subregions of the region.
|
static String |
getConcurrencyChecksEnabled(com.gemstone.gemfire.cache.RegionAttributes attrs)
Display string for concurrencyChecksEnabled.
|
static com.gemstone.gemfire.cache.DataPolicy |
getDataPolicy(String attribute)
Given a dataPolicy attribute, return the corresponding DataPolicy.
|
static com.gemstone.gemfire.cache.ExpirationAction |
getExpirationAction(String action)
Given an action, return the corresponding ExpirationAction.
|
static String |
getGemFireName()
Returns the name of the gemfire system for this VM
|
static com.gemstone.gemfire.cache.InterestPolicy |
getInterestPolicy(String attribute)
Given a interestPolicy attribute, return the corresponding InterestPolicy.
|
static com.gemstone.gemfire.cache.InterestResultPolicy |
getInterestResultPolicy(String attribute)
Given a interestResultPolicy attribute, return the corresponding
InterestResultPolicy.
|
static Throwable |
getLastCausedBy(Throwable e)
Given a Throwable, return the last cause or the given Throwable if no
caused by's.
|
static com.gemstone.gemfire.cache.LossAction |
getLossAction(String lossAction)
Given a lossAction, return the corresponding LossAction
|
static com.gemstone.gemfire.cache.MirrorType |
getMirrorType(String attribute)
Given a mirroring attribute, return the corresponding MirrorType.
|
static double |
getNumCQsCreated()
Return the number of CQs (CqServiceStats.numCQsCreated)
|
static double |
getNumHeapLRUEvictions()
Return the number of HeapLRU evictions that have occurred.
|
static double |
getNumLoadsCompleted()
Return the number of loadsCompleted
|
static double |
getNumLRUEvictions()
Return the number of LRU evictions that have occurred.
|
static double |
getNumMemLRUEvictions()
Return the number of MemLRU evictions that have occurred.
|
static int |
getNumThreads()
Return the number of threads in this test
|
static int |
getNumVMs()
Return the number of VMs in this test
|
static int |
getPercentageOf(int percentage,
int anInt) |
static Object |
getRandomElementInSet(Set aSet)
Return a random element in aSet.
|
static Object |
getRandomKeyInMap(Map aMap)
Return a random key in aMap.
|
static com.gemstone.gemfire.cache.InterestResultPolicy |
getResultPolicy(String policy)
Given a result policy as a string, return the corresponding InterestResultPolicy.
|
static com.gemstone.gemfire.cache.ResumptionAction |
getResumptionAction(String resumptionAction)
Given a resumptionAction, return the corresponding ResumptionAction
|
static com.gemstone.gemfire.cache.Scope |
getScope(String attribute)
Given a scope attribute, return the corresponding Scope.
|
static int |
getSizeInBytes(Object anObj)
Get the size in bytes of anObj.
|
static String |
getStackTrace()
Get a stack trace of the current stack and return it as a String
|
static String |
getStackTrace(String reason)
Get a stack trace of the current stack and return it as a String
|
static String |
getStackTrace(Throwable aThrowable)
Get a stack trace for the given Throwable and return it as a String.
|
static int |
getStat_deltaGetInitialImagesCompleted(String regionName)
Returns the current stat value of CachePerfStats.deltaGetIntialImagesCompleted.
|
static int |
getStat_getInitialImagesCompleted(String regionName)
Returns the current stat value of CachePerfStats.getIntialImagesCompleted.
|
static int |
getStat_getInitialImagesInProgress(String regionName)
Returns the current stat value of CachePerfStats.getIntialImagesInProgress.
|
static long |
getStat_getInitialImageTime(String regionName)
Returns the current stat value of CachePerfStats.getIntialImageTime.
|
static int |
getStat_getRecoveriesInProgress(String diskStoreName)
Returns the current stat value of DiskStoreStatistics(diskStoreName).recoveriesInProgress
This is done by getting the stat directly without going to the archive
file, thus the stat is local to this cache and cannot be combined across
archives, but it is faster than going to the archive.
|
static int |
getTotalNumKeys(com.gemstone.gemfire.cache.Region aRegion)
Given a region, get the number of keys in the region and all subregions of the region.
|
static void |
logRegionHierarchy()
Log all regions in the cache
|
static String |
millisToString(long millis) |
static String |
nanosToString(long nanos) |
static String |
regionAttributesToString(com.gemstone.gemfire.cache.RegionAttributes attr)
Given RegionAttributes, return a string logging its configuration.
|
static String |
regionHierarchyToString()
Return a string representation of the region hierarchy for this test.
|
static String |
regionsToString(com.gemstone.gemfire.cache.Region aRegion,
boolean showAttributes)
Given a Region, return a string logging its name and attributes (if
specified by the arguments) and all its subregions.
|
static String |
regionToString(com.gemstone.gemfire.cache.Region aRegion,
boolean showAttributes)
Given a Region, return a string logging its name and attributes (if
specified by the arguments)
|
static void |
sleepForever() |
static com.gemstone.gemfire.cache.ExpirationAction |
stringToExpirationAction(String eaStr) |
static long |
stringToNanos(String aStr)
Given a String which was returned from TestHelper.nanosToString, return
the nanos as a long.
|
static String |
toString(Object anObj)
Return a String representing anObj.
|
static String |
toString(Object anObj,
int numElements,
int depth)
Return a String representing anObj using the given number of elements
and number of levels.
|
static String |
unitToString(int timeUnit) |
static String |
waitForContainsKey(com.gemstone.gemfire.cache.Region aRegion,
Object key,
boolean expected,
long timeoutMS,
boolean logProgress)
Using the given region and key, wait for containsKey to become the same value
as expected.
|
static String |
waitForContainsValueForKey(com.gemstone.gemfire.cache.Region aRegion,
Object key,
boolean expected,
long timeoutMS,
boolean logProgress)
Using the given region and key, wait for containsValueForKey to become the same value
as expected.
|
static void |
waitForCounter(Blackboard BB,
String counterName,
int whichCounter,
long requiredCounterValue,
boolean exact,
long waitLimitMS)
Wait for a hydra blackboard counter to have a particular value.
|
static void |
waitForCounter(Blackboard BB,
String counterName,
int whichCounter,
long requiredCounterValue,
boolean exact,
long waitLimitMS,
long sleepMS)
Wait for a hydra blackboard counter to have a particular value.
|
static void |
waitForCounterSum(Blackboard BB,
String counterName1,
String counterName2,
long requiredCounterSum,
boolean exact,
long waitLimitMS)
Wait for the sum of two hydra blackboard counters to have a particular value.
|
static void |
waitForObjectValue(com.gemstone.gemfire.cache.Region aRegion,
Object key,
Object expectedObjectValue,
long timeoutMS)
Using the given region and key, wait for the object's value to become
expectedObjectValue.
|
public static final int MILLIS
public static final int NANOS
public static final int MICROS
public static final int SECONDS
public static final long SEC_NANO_FACTOR
public static final long MILLI_NANO_FACTOR
public static final long MILLI_MICRO_FACTOR
public static final long MICRO_NANO_FACTOR
public static final long SEC_MILLI_FACTOR
public static String EVENT_ERROR_KEY
public static String toString(Object anObj)
public static String toString(Object anObj, int numElements, int depth)
numElements - The maximum number of elements in anObj to print.depth - The maximum depth to print for elements of anObj.public static String getStackTrace()
public static String getStackTrace(String reason)
public static Throwable findCause(Throwable aThrowable, Class type)
aThrowable - the head of the cause chaintype - the Class of the cause to look forpublic static String getStackTrace(Throwable aThrowable)
aThrowable - The exception to get the stack trace for.public static String format(double adouble, int placesBeforeDecimal, int placesAfterDecimal)
adouble - The double to format.placesBeforeDecimal - The number of places to have before the decimal point. Pads with
spaces if necessary. If this is not large enough for adouble, more than placesBeforeDecimal
will be used to accomodate the double.placesAfterDecimal - The number of places to have after the decimal point. Pads with
zeroes if necessary. If this is not large enough for adouble, more than placesAfterDecimal
will be used to accomodate the double.public static String format(long along, int places)
along - The long to format.places - The number of places for anInt. Pads with zeroes if necessary.public static String millisToString(long millis)
public static String nanosToString(long nanos)
public static long stringToNanos(String aStr)
public static String unitToString(int timeUnit)
public static int getPercentageOf(int percentage,
int anInt)
public static boolean borderCase(Long paramKey)
public static Object getRandomKeyInMap(Map aMap)
public static Object getRandomElementInSet(Set aSet)
public static com.gemstone.gemfire.cache.ExpirationAction stringToExpirationAction(String eaStr)
public static void sleepForever()
public static void waitForCounterSum(Blackboard BB, String counterName1, String counterName2, long requiredCounterSum, boolean exact, long waitLimitMS)
BB - The hydra blackboard containing the counters to use.counterName1 - The name of the blackboard counter in BB.counterName2 - The name of the blackboard counter in BB.requiredCounterSum - The required counter sum.exact - If true, then the counter sum must have exactly the value requiredCounterSum.
If false, then the counters' sum must be >= requiredCounterSum.waitLimitMS - If the counter sum does not have the required value by this many milliseconds
then throw an error.TestException - if the counter sum does not have the required value in waitLimitMS millis.public static void waitForCounter(Blackboard BB, String counterName, int whichCounter, long requiredCounterValue, boolean exact, long waitLimitMS, long sleepMS)
BB - The hydra blackboard containing the counters to use.counterName - The name of the blackboard counter, used to log information about it.whichCounter - The hydra index of the counter.requiredCounterValue - The required counter value.exact - If true, then the counter value must have exactly the value requiredCounterValue.
If false, then the counter's value must be >= requiredCounterValue.waitLimitMS - If the counter does not have the required value by this many milliseconds
then throw an error.sleepMS - The number of millis to sleep between each read of the counter.TestException - if the counter does not have the required value in waitLimitMS millis.public static void waitForCounter(Blackboard BB, String counterName, int whichCounter, long requiredCounterValue, boolean exact, long waitLimitMS)
BB - The hydra blackboard containing the counters to use.counterName - The name of the blackboard counter, used to log information about it.whichCounter - The hydra index of the counter.requiredCounterValue - The required counter value.exact - If true, then the counter value must have exactly the value requiredCounterValue.
If false, then the counter's value must be >= requiredCounterValue.waitLimitMS - If the counter does not have the required value by this many milliseconds
then throw an error.TestException - if the counter does not have the required value in waitLimitMS millis.public static String waitForContainsKey(com.gemstone.gemfire.cache.Region aRegion, Object key, boolean expected, long timeoutMS, boolean logProgress)
aRegion - The region to use for containsKey.key - The key in aRegion to call containsKey on.expected - The expected value of containsKey.timeoutMS - The number of milliseconds to wait.logProgress - If true, then log the progress of the wait, otherwise wait silently.TestException - if containsKey does not become expectedContainsKey in timeoutMS millis.public static String waitForContainsValueForKey(com.gemstone.gemfire.cache.Region aRegion, Object key, boolean expected, long timeoutMS, boolean logProgress)
aRegion - The region to use for containsValueForKey.key - The key in aRegion to call containsValueForKey on.expected - The expected value of containsValueForKey.timeoutMS - The number of milliseconds to wait.logProgress - If true, then log the progress of the wait, otherwise wait silently.TestException - if containsValueForKey does not become expected in timeoutMS millis.public static void waitForObjectValue(com.gemstone.gemfire.cache.Region aRegion,
Object key,
Object expectedObjectValue,
long timeoutMS)
aRegion - The region to use.key - The key in aRegion.timeoutMS - The number of milliseconds to wait.TestException - if the object does not have the expected valuein timeoutMS millis.public static String getGemFireName()
public static String regionToString(com.gemstone.gemfire.cache.Region aRegion, boolean showAttributes)
aRegion - Return a string describing this region.showAttributes - True if the string should include aRegion's attributes,
false otherwise.public static String regionsToString(com.gemstone.gemfire.cache.Region aRegion, boolean showAttributes)
aRegion - Return a string describing this region and all its subregions.showAttributes - True if the string should include the regions' attributes,
false otherwise.public static String regionAttributesToString(com.gemstone.gemfire.cache.RegionAttributes attr)
attr - Return a string describing this region.public static String getConcurrencyChecksEnabled(com.gemstone.gemfire.cache.RegionAttributes attrs)
public static com.gemstone.gemfire.cache.LossAction getLossAction(String lossAction)
lossAction - The loss action as a stringpublic static com.gemstone.gemfire.cache.ResumptionAction getResumptionAction(String resumptionAction)
resumptionAction - The resumptionAction as a stringpublic static com.gemstone.gemfire.cache.ExpirationAction getExpirationAction(String action)
action - The action as a String.public static com.gemstone.gemfire.cache.InterestResultPolicy getResultPolicy(String policy)
policy - The result policy as a String.public static com.gemstone.gemfire.cache.MirrorType getMirrorType(String attribute)
attribute - The mirroring attribute.public static com.gemstone.gemfire.cache.DataPolicy getDataPolicy(String attribute)
attribute - The dataPolicy attribute.public static com.gemstone.gemfire.cache.InterestPolicy getInterestPolicy(String attribute)
attribute - The interestPolicy attribute.public static com.gemstone.gemfire.cache.InterestResultPolicy getInterestResultPolicy(String attribute)
attribute - The interestResultPolicy attribute.public static com.gemstone.gemfire.cache.Scope getScope(String attribute)
attribute - The scope attribute.public static int getTotalNumKeys(com.gemstone.gemfire.cache.Region aRegion)
aRegion - Get the number of keys in this region and all subregions of this region.public static Set getAllKeys(com.gemstone.gemfire.cache.Region aRegion)
aRegion - Get the keys in this region and all subregions of this region.public static void checkForEventError(Blackboard bb)
bb - The blackboard to check.TestException - if any error string was found in the bb using
key TestHelper.EVENT_ERROR_KEYpublic static double getNumLRUEvictions()
public static double getNumMemLRUEvictions()
public static double getNumHeapLRUEvictions()
public static double getNumLoadsCompleted()
public static double getNumCQsCreated()
public static int getNumVMs()
public static int getNumThreads()
public static int getSizeInBytes(Object anObj)
anObj - Determine the size in bytes of this object.public static int getStat_getRecoveriesInProgress(String diskStoreName)
public static int getStat_getInitialImagesInProgress(String regionName)
public static int getStat_getInitialImagesCompleted(String regionName)
public static int getStat_deltaGetInitialImagesCompleted(String regionName)
public static long getStat_getInitialImageTime(String regionName)
public static Object createInstance(String className)
className - The class to create an instance of.public static Object createInstance(Class aClass)
aClass - The class to create an instance of.public static int calculateStringSize(String aStr)
aStr - The String to calculatepublic static Throwable getLastCausedBy(Throwable e)
e - The Throwable for which to find the last caused by.public static void logRegionHierarchy()
public static String regionHierarchyToString()
Copyright © 2010-2015 Pivotal Software, Inc. All rights reserved.