Skip to content

Commit

Permalink
Merge pull request #29 from c-kuhlman/release-8.0
Browse files Browse the repository at this point in the history
Modified components of poolTester so that it works under Solaris10
  • Loading branch information
c-kuhlman authored Aug 29, 2017
2 parents c530b4c + 27f9aaa commit 568e332
Show file tree
Hide file tree
Showing 12 changed files with 141 additions and 79 deletions.
37 changes: 37 additions & 0 deletions software/testtools/poolTester/example.poolTester
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# An example .poolTester init file:

# poolTester will look for this file in your home directory, and then in your current directory,
# loading it to initalize whatever settings you desire or need ...


# poolTester makes use of the native Linux utility 'seq' in many places
# Before I found an implementation in an out of the way directory on my
# Solaris machine, I used this function to provide a sufficient subset of
# 'seq' functionality to satisfy poolTester's needs.

#function seq ()
#{
# i=$1;
# if [[ -z $2 ]]; then
# l=$1
# i=1
# else
# l=$2
# fi
# while [ $i -le $l ]; do
# printf "%d\n" $i
# i=`expr $i + 1`
# done
#}

# need a grep that understands the -q option ....
alias grep=/usr/xpg4/bin/grep

# the following is needed to make regular expressions work properly on some versions of bash
shopt -s expand_aliases compat31

# a location for the executables under test
export Tools=exe

# NDF for running testDeck01 and its ilk ...
export NDFPathName=../td/testNetwork-sparc/NDF
2 changes: 1 addition & 1 deletion software/testtools/poolTester/include/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function isntFileRetained() {
#
function clean() {
rmOptions="-rf"
debug_on && rmOptions="$rmOptions -v"
# debug_on && rmOptions="$rmOptions -v"
local file
for file in "$scratchSpace/testpool$poolIdx"/*; do
if isntFileRetained "$file"; then
Expand Down
3 changes: 2 additions & 1 deletion software/testtools/poolTester/include/logging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ function compareLog() {
dumpLog -s > $logFileStripped
dumpLog -f $expectedLogFile -s > $expectedLogFileStripped

diff -q $logFileStripped $expectedLogFileStripped >/dev/null
# diff -q $logFileStripped $expectedLogFileStripped >/dev/null
diff $logFileStripped $expectedLogFileStripped >/dev/null
case $? in
0)
verbose_inform "Pool log matches '$expectedLogFile'."
Expand Down
6 changes: 3 additions & 3 deletions software/testtools/poolTester/include/pool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ EOD
function doesPoolExist () {
debug_inform "doesPoolExist called"

local poolID=1
local poolID=$poolIdx
# Get current user.
local user=`whoami`
local poolPID
Expand All @@ -174,9 +174,9 @@ debug_inform "doesPoolExist called"
[[ $val -eq 0 ]] && retWarn="pool does not exist"

# Perform check.
debug_inform "Waiting up to $timeout seconds for pool connection evaluation ($val)."
debug_inform "Checking for pool existence ($val)."

poolPID=`ps aux|grep vpool| grep $user | grep testpool$poolID| grep -v grep| awk '{print $2}'`
poolPID=`ps -af|grep vpool| grep $user | grep testpool$poolID| grep -v grep| awk '{print $2}'`
toReturn=$?

[[ $poolPID -ne 0 ]] && [[ $toReturn -eq 0 ]] && actual=0 || actual=1
Expand Down
10 changes: 6 additions & 4 deletions software/testtools/poolTester/include/query.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ function query() {
local toRun
if [[ ! -z "$queryFile" ]]; then
toRun="$queryFile"
verbose_inform "Running query file: $queryFile"
verbose_inform "NFD env variable: $NDFPathName"
verbose_inform "Running query file: $queryFile expectedResults: $expectedResultsFile"
verbose_inform "NDF env variable: $NDFPathName"
verbose_inform "Workers startup query: $WorkerStartupQuery"
getVPrompt $vpromptOptions < $queryFile > $actualResultsFile & 2>&1
local vpromptPID=$!
Expand All @@ -114,16 +114,18 @@ function query() {
else
toRun="$queryExpression"
[[ ! -z "$queryURL" ]] && toRun="\"$queryURL\" asUrl;"
verbose_inform "Running query: $toRun"
verbose_inform "Running query: $toRun expectedResults: $expectedResultsFile"
toRun="$toRun
?g"

debug_inform "Running query: $toRun"
echo "$toRun" | getVPrompt $vpromptOptions > $actualResultsFile
fi
# Compare results.
verbose_inform "Compare results: $actualResultsFile $expectedResultsFile"
[[ -z "$expectedResultsFile" ]] && return 0
diff -q $actualResultsFile $expectedResultsFile >/dev/null
# diff -q $actualResultsFile $expectedResultsFile >/dev/null
diff $actualResultsFile $expectedResultsFile >/dev/null
case $? in
0)
# Test passed. Delete the file and return.
Expand Down
5 changes: 3 additions & 2 deletions software/testtools/poolTester/include/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ function runScript_getValue() {

# TODO: enhance robustness of runScript_getValue()
local -a kvps # Array of key-value pairs.
lines_to_array "`echo $line | sed 's/,/\n/g'`" kvps # Populate array
lines_to_array "`echo $line | tr , '\n'`" kvps # Populate array
for i in `seq 0 $((${#kvps[@]} - 1))`; do # Iterate over array
# Check if this key-value-pair has the key we're looking for.
[[ "${kvps[$i]}" =~ "[ ]*$searchKey[ ]*:(.*)" ]] || continue

# We've found the correct key. Output the value and return.
local value=`trim "${BASH_REMATCH[1]}"`
eval "$toReturn='$(echo `eval echo \"$value\"`)'"
debug_inform "value found: '$value' -- '$toReturn'"
break;
done
}
Expand Down Expand Up @@ -205,7 +206,7 @@ function runScript() {
runScript_getValue "${threadLines[$i]}" thread threadID

# Start thread.
debug_inform "Starting thread $threadID."
debug_inform "Starting thread $threadID.($threadLines[$i])"
runScript_runThread "$scriptFile" "$threadID" &
done

Expand Down
1 change: 1 addition & 0 deletions software/testtools/poolTester/include/startStop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ EOD
function restart() {
require_pool
local waitForWorkers=false
local OPTIND=1
while getopts 'w' OPTION; do
case $OPTION in
w)
Expand Down
4 changes: 3 additions & 1 deletion software/testtools/poolTester/include/wait.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function waitForStat() {
local actual
local timeout=120
local conditionMet=false
local OPTIND=1
while getopts 'c:t:' OPTION; do
case $OPTION in
c)
Expand Down Expand Up @@ -50,6 +51,7 @@ function waitForStat() {
conditionMet=true
break
else
debug_inform "$i of $timeout: $actual $cond $val"
sleep 1
fi
done
Expand Down Expand Up @@ -78,7 +80,7 @@ Waits until a given pool statistic condition is met, up to a given timeout. For
At least one of the following arguments must be specified:
-c CONDITION Specify statistical condition that should be checked for. Should be in the form <VAR><OPERATOR><VALUE> Where <VAR> is the statistic name, <OPERATOR> is the conditional operator (one of: <, <=, >, >=, =, !=) and <VALUE> is the condition's check value.
-t TIMEOUT The timeout of the wait operation in seconds. Only effects subsequent -c arguments. Defaults to 60.
-t TIMEOUT The timeout of the wait operation in seconds. Only effects subsequent -c arguments. Defaults to 120.
Exit status is zero if condition(s) met, nonzero otherwise.
Expand Down
4 changes: 2 additions & 2 deletions software/testtools/poolTester/queries/longStart.vis
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

[!x <- 500000; [x > 0] whileTrue:[:x <- x - 1]] value;

Utility define:'processId' toBe: 604 asPrimitive;

"sleep 25" filterOutputOf:[];
2 changes: 1 addition & 1 deletion software/testtools/poolTester/scripts/master
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ operation_on_thread:main, poolIdx: $poolIdx/script$operationID, run: runScript -
operation_on_thread:main, poolIdx: $poolIdx/script$operationID, run: runScript -s $POOLTESTERDIR/scripts/hardStop
operation_on_thread:main, poolIdx: $poolIdx/script$operationID, run: runScript -s $POOLTESTERDIR/scripts/stop
operation_on_thread:main, poolIdx: $poolIdx/script$operationID, run: runScript -s $POOLTESTERDIR/scripts/hardRestartNoResume
operation_on_thread:main, poolIdx: $poolIdx/script$operationID, run: runScript -s $POOLTESTERDIR/scripts/checkProperties
#operation_on_thread:main, poolIdx: $poolIdx/script$operationID, run: runScript -s $POOLTESTERDIR/scripts/checkProperties
17 changes: 17 additions & 0 deletions software/testtools/poolTester/scripts/repeatedHardRestart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Repeated hardRestarts left a pool in a suspended state in early versions of 8.1
# This script fails with an error when run against that version.
# It succeeds when run against version 8.0
# It should succeed when run against a version of 8.1 with the bug fixed!!

#
pre_exec: start -c $POOLTESTERDIR/configs/max1.ptc

thread:main, repetitions:1

operation_on_thread:main, run:hardRestart
operation_on_thread:main, run:hardRestart
operation_on_thread:main, run:query -q $POOLTESTERDIR/queries/TestQuery01.vis -a

post_exec: waitForStat -t 60 -c Status=Running
#post_exec: waitForStat -t 60 -c QueriesProcessed=2
post_exec: hardStop
Loading

0 comments on commit 568e332

Please sign in to comment.