diff --git a/pengine/regression.core.sh b/pengine/regression.core.sh index 881e988c52..653495e777 100755 --- a/pengine/regression.core.sh +++ b/pengine/regression.core.sh @@ -1,172 +1,173 @@ #!/bin/bash # Copyright (C) 2004 Andrew Beekhof # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This software is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # verbose=$1 io_dir=test10 diff_opts="--ignore-all-space -u -N" failed=.regression.failed.diff # zero out the error log > $failed num_failed=0 function ptest() { if [ "x$VALGRIND_CMD" != "x" ]; then ptest_cmd=`which ptest` elif [ -x ptest ]; then ptest_cmd=./ptest else echo No ptest executable in current directory using installed version ptest_cmd=`which ptest` fi #echo $VALGRIND_CMD $ptest_cmd $* $VALGRIND_CMD $ptest_cmd $* } function do_test { base=$1; shift name=$1; shift input=$io_dir/${base}.xml output=$io_dir/${base}.pe.out expected=$io_dir/${base}.exp te_output=$io_dir/${base}.te.out te_expected=$io_dir/${base}.te.exp dot_output=$io_dir/${base}.pe.dot dot_expected=$io_dir/${base}.dot dot_png=$io_dir/${base}.png scores=$io_dir/${base}.scores score_output=$io_dir/${base}.pe.scores if [ ! -f $input ]; then echo "Test $name ($base)... Error (PE : input)"; num_failed=`expr $num_failed + 1` return; fi echo "Test $base : $name"; if [ "$create_mode" != "true" -a ! -f $expected ]; then echo " Error (PE : expected)"; # return; fi # ../admin/crm_verify -X $input ptest -x $input -D $dot_output -G $output -S -s $* > $score_output if [ $? != 0 ]; then echo " * Failed (PE : rc)"; num_failed=`expr $num_failed + 1` fi if [ -s core ]; then echo " Moved core to core.${base}"; num_failed=`expr $num_failed + 1` rm -f core.$base mv core core.$base fi if [ ! -s $output ]; then echo " Error (PE : no graph)"; num_failed=`expr $num_failed + 1` rm $output return; # else # mv $output $output.sed # cat $output.sed | sed 's/id=.[0-9]*.\ //g' >> $output fi if [ ! -s $dot_output ]; then echo " Error (PE : no dot-file)"; num_failed=`expr $num_failed + 1` rm $output return; else echo "digraph \"g\" {" > $dot_output.sort LC_ALL=POSIX sort -u $dot_output | grep -v -e ^}$ -e digraph >> $dot_output.sort echo "}" >> $dot_output.sort mv -f $dot_output.sort $dot_output fi if [ ! -s $score_output ]; then echo " Error (PE : no scores)"; num_failed=`expr $num_failed + 1` rm $output return; fi if [ "$create_mode" = "true" ]; then cp "$output" "$expected" cp "$dot_output" "$dot_expected" cp "$score_output" "$scores" echo " Created expected output (PE)" fi diff $diff_opts $dot_expected $dot_output >/dev/null rc=$? if [ $rc != 0 ]; then echo " * Failed (PE : dot)"; diff $diff_opts $dot_expected $dot_output 2>/dev/null >> $failed echo "" >> $failed num_failed=`expr $num_failed + 1` else rm $dot_output fi diff $diff_opts $expected $output >/dev/null rc2=$? if [ $rc2 != 0 ]; then echo " * Failed (PE : raw)"; diff $diff_opts $expected $output 2>/dev/null >> $failed echo "" >> $failed num_failed=`expr $num_failed + 1` else rm $output fi diff $diff_opts $scores $score_output >/dev/null rc=$? if [ $rc != 0 ]; then echo " * Failed (PE : scores)"; diff $diff_opts $scores $score_output 2>/dev/null >> $failed echo "" >> $failed num_failed=`expr $num_failed + 1` else rm $score_output fi rm -f $output } function test_results { if [ $num_failed != 0 ]; then if [ -s $failed ]; then if [ "$verbose" = "-v" ]; then echo "Results of $num_failed failed tests...." less $failed else echo "Results of $num_failed failed tests are in $failed...." echo "Use $0 -v to display them automatically." fi else echo "$num_failed tests failed (no diff results)" rm $failed fi fi + exit $num_failed } diff --git a/tools/regression.sh b/tools/regression.sh index d633ffc8cf..374fa19da0 100755 --- a/tools/regression.sh +++ b/tools/regression.sh @@ -1,185 +1,190 @@ #!/bin/bash : ${shadow=tools-regression} WHO=`whoami` if [ $WHO != root ]; then echo This regression test needs to be run as root exit 1 fi num_errors=0 num_passed=0 GREP_OPTIONS= function assert() { rc=$1; shift target=$1; shift app=$1; shift msg=$1; shift exit_code=$1; shift cibadmin -Q if [ $rc -ne $target ]; then num_errors=`expr $num_errors + 1` printf "* Failed (rc=%.3d): %-14s - %s\n" $rc $app "$msg" if [ ! -z $exit_code ]; then echo "Aborting tests" exit $exit_code fi exit 1 else printf "* Passed: %-14s - %s\n" $app "$msg" num_passed=`expr $num_passed + 1` fi } function usage() { echo "Usage: ./regression.sh [-s(ave)] [-x] [-v(erbose)]" exit $1 } done=0 do_save=0 while test "$done" = "0"; do case "$1" in -v) verbose=1; shift;; -x) set -x; shift;; -s) do_save=1; shift;; -?) usage 0;; -*) echo "unknown option: $1"; usage 1;; *) done=1;; esac done function test_tools() { crm_shadow --batch --force --create-empty $shadow CIB_shadow=$shadow ; export CIB_shadow cibadmin -Q cibadmin -E assert $? 1 cibadmin "Require --force for CIB erasure" cibadmin -E --force assert $? 0 cibadmin "Allow CIB erasure with --force" cibadmin -Q > /tmp/$$.existing.xml assert $? 0 cibadmin "Query CIB" crm_attribute -n cluster-delay -v 60s assert $? 0 crm_attribute "Set cluster option" cibadmin -Q -o crm_config | grep cib-bootstrap-options-cluster-delay assert $? 0 cibadmin "Query new cluster option" cibadmin -Q -o crm_config > /tmp/$$.opt.xml assert $? 0 cibadmin "Query cluster options" cibadmin -D -o crm_config --xml-text '' assert $? 0 cibadmin "Delete nvpair" cibadmin -C -o crm_config --xml-file /tmp/$$.opt.xml assert $? 21 cibadmin "Create operaton should fail with: -21, The object already exists" cibadmin -M -o crm_config --xml-file /tmp/$$.opt.xml assert $? 0 cibadmin "Modify cluster options section" cibadmin -Q -o crm_config | grep cib-bootstrap-options-cluster-delay assert $? 0 cibadmin "Query updated cluster option" crm_attribute -n cluster-delay -v 40s -s duplicate assert $? 0 crm_attribute "Set duplicate cluster option" crm_attribute -n cluster-delay -v 30s assert $? 216 crm_attribute "Setting multiply defined cluster option should fail with -216, Could not set cluster option" crm_attribute -n cluster-delay -v 30s -s duplicate assert $? 0 crm_attribute "Set cluster option with -s" crm_attribute -n cluster-delay -D -i cib-bootstrap-options-cluster-delay assert $? 0 crm_attribute "Delete cluster option with -i" cibadmin -C -o nodes --xml-text '' assert $? 0 cibadmin "Create node entry" cibadmin -C -o status --xml-text '' assert $? 0 cibadmin "Create node status entry" crm_attribute -n ram -v 1024M -U clusterNode-UNAME -t nodes assert $? 0 crm_attribute "Create node attribute" cibadmin -Q -o nodes | grep clusterNode-UUID-ram assert $? 0 cibadmin "Query new node attribute" cibadmin -Q | cibadmin -5 -p 2>&1 > /dev/null assert $? 0 cibadmin "Digest calculation" # This update will fail because it has version numbers cibadmin -R --xml-file /tmp/$$.existing.xml assert $? 45 cibadmin "Replace operation should fail with: -45, Update was older than existing configuration" crm_standby -N clusterNode-UNAME -G assert $? 0 crm_standby "Default standby value" crm_standby -N clusterNode-UNAME -v true assert $? 0 crm_standby "Set standby status" crm_standby -N clusterNode-UNAME -G assert $? 0 crm_standby "Query standby value" crm_standby -N clusterNode-UNAME -D assert $? 0 crm_standby "Delete standby value" cibadmin -C -o resources --xml-text '' assert $? 0 cibadmin "Create a resource" crm_resource -r dummy --meta -p is-managed -v false assert $? 0 crm_resource "Create a resource meta attribute" crm_resource -r dummy --meta -g is-managed assert $? 0 crm_resource "Query a resource meta attribute" crm_resource -r dummy --meta -d is-managed assert $? 0 crm_resource "Remove a resource meta attribute" crm_resource -r dummy -p delay -v 10s assert $? 0 crm_resource "Create a resource attribute" crm_resource -L assert $? 0 crm_resource "List the configured resources" crm_failcount -r dummy -v 10 -N clusterNode-UNAME assert $? 0 crm_resource "Set a resource's fail-count" crm_resource -r dummy -M assert $? 244 crm_resource "Require a destination when migrating a resource that is stopped" crm_resource -r dummy -M -N i.dont.exist assert $? 234 crm_resource "Don't support migration to non-existant locations" crm_resource -r dummy -M -N clusterNode-UNAME assert $? 0 crm_resource "Migrate a resource" crm_resource -r dummy -U assert $? 0 crm_resource "Un-migrate a resource" } test_tools 2>&1 | sed s/cib-last-written.*\>/\>/ > regression.out rc=$? if [ $do_save = 1 ]; then cp regression.out regression.exp fi diff -u regression.exp regression.out diff_rc=$? if [ $rc != 0 ]; then echo Tests failed + exit 1 + elif [ $diff_rc != 0 ]; then echo Tests passed but diff failed + exit 2 + else echo Tests passed + exit 0 fi