#!/bin/bash # $HeadURL$ $LastChangedRevision$ PROGNAME=`basename $0` SANDPIT=`pwd` . $(ade-config ade_share_prefix)/include/adetestsupport.sh ############################################################################## # # Purpose of test: to verify basic paa functions # # Bug id: # ############################################################################## # Ensure dates are consistently formatted export LC_ALL=C # Start of support functions filter_variant_text() { # Note how the variable *width* of a hostname - and therefore of the padding # that follows it in column-aligned output - means that we can't change # just to VARIANT-HOSTNAME but *with* padding to # VARIANT-HOSTNAME with fixed width padding. Another padding issues comes # from that summer and winter timezones have different widths and therefore # different paddings. Although the timezone is devarianted the spacing is # not. This only seems to be a problem on the end of the line because dates # are always in the last column. eval "$@" | sed -e 's/[A-Z][a-z][a-z] [A-Z][a-z][a-z] [1-3 ][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9] [A-Z][A-Z]* [1-2][0-9][0-9][0-9]/Fri Dec 31 23:59:59 GMT 1999/g' \ -e 's/^\(pub\)\( *\)\([^ ]*\)\( *\)\([^ ]*\)$/\1\2VARIANT-KEY-ID\4VARIANT-DATE/' \ -e "s@$SANDPIT@VARIANT-SANDPIT@g" \ -e "s/$UNAMEN */VARIANT-HOSTNAME /g" \ -e "s/$UNAMEN\([^ \t]\)/VARIANT-HOSTNAME\1/g" \ -e "s/20[1-9][0-9][0-1][0-9][0-3][0-9][0-2][0-9][0-5][0-9][0-5][0-9]/VARIANT-TIMESTAMP/g" \ -e "s/ *\$//" # return the passed command's return code, not sed's. return ${PIPESTATUS[0]} } launch_shell() { PS1="$PROGNAME> " bash --norc || true } echo "$PROGNAME: setting up environment ..." # Set variables used in this test # Ensure DB is created in sandpit export PAA_RCDIR=$SANDPIT/.paa # Ensure effects on OS (modiying the *OS*'s idea of repos, restarting apache, etc) are not real export PAA_ROOTDIR=$SANDPIT # Use a test-specific gpg configuration export GNUPGHOME=$SANDPIT/.gpupg # Don't use any running gpg-agent unset GPG_AGENT_INFO # Don't put the apache config files in $ADETEST_MODROOT/var 'cos they'll contaminate it. export PAA_STATE_PREFIX=$SANDPIT/var # Misc UNAMEN=$(uname -n) echo "$PROGNAME: creating non-interactive editor ..." mkdir -p $SANDPIT/{bin,etc/init.d} echo -e '#!/bin/sh\n\ncat > $1' > $SANDPIT/bin/caton chmod 755 $SANDPIT/bin/caton echo echo "setting up database ..." mkdir -p $PAA_RCDIR cp $ADETEST_MODROOT/tests/in/$PROGNAME.paa.sqlite $PAA_RCDIR/paa.sqlite # 'paa indirect' will try to remove an old symlink and create a new one; the paths of # those links are *not* determined by $PAA_ROOTDIR, but rather by the path in the repo # config. So we need to fix that, inserting $PAA_ROOTDIR into the beginning of them. export EDITOR=cat paa editrepo localpublic-deb > localpublic-deb.cfg perl -pi -e "s@/pub/@$SANDPIT/pub/@" localpublic-deb.cfg export EDITOR=$SANDPIT/bin/caton paa editrepo localpublic-deb < localpublic-deb.cfg rm -f localpublic-deb.cfg echo "$PROGNAME: noting freeze currently used by indirect ..." CURRENT_FREEZE=$(paa listindirects localpublic-deb gnocchi | sed -e '1,2d' -e '$d' | awk '{ print $4 }') echo "$PROGNAME: CURRENT_FREEZE=$CURRENT_FREEZE" echo echo "$PROGNAME: noting newest freeze ..." NEWEST_FREEZE=$(paa listfreezes localpublic-deb | sed -e '1,2d' -e '$d' | awk '{ print $2 }' | sort -k 1rn | head -1) echo "$PROGNAME: NEWEST_FREEZE=$NEWEST_FREEZE" echo echo "$PROGNAME: setting up indirect to newest freeze ..." paa indirect localpublic-deb gnocchi NEWEST-FREEZE echo echo "$PROGNAME: noting freeze currently used by indirect ..." CURRENT_FREEZE=$(paa listindirects localpublic-deb gnocchi | sed -e '1,2d' -e '$d' | awk '{ print $4 }') echo "$PROGNAME: CURRENT_FREEZE=$CURRENT_FREEZE" echo if [ $CURRENT_FREEZE = $NEWEST_FREEZE ]; then echo "indirect has been updated to point to newest freeze" else echo "indirect has ***NOT*** been updated to point to newest freeze" fi echo