#!/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 launch_shell() { PS1="$PROGNAME> " bash --norc || true } inspect_repos() { echo "$PROGNAME: listing repos ($1) ..." filter_variant_text "paa listrepos" echo "$PROGNAME: inspecting repos ($1) ..." filter_variant_text "( cd $SANDPIT && find repos 2>&1 | LC_ALL=C sort )" } inspect_hosts() { echo "$PROGNAME: listing hosts ($1) ..." filter_variant_text "paa listhosts" } inspect_accesses() { echo "$PROGNAME: listing accesses ($1) ..." filter_variant_text "paa listaccesses" echo "$PROGNAME: inspecting accesses ($1) ..." filter_variant_text "( cd $SANDPIT && find etc -name init.d -prune -o -print 2>&1 | LC_ALL=C sort )" echo "$PROGNAME: display accesses' contents ($1) ..." ( cd $SANDPIT && find etc -name init.d -prune -o -type f -print | LC_ALL=C sort | while read F; do filter_variant_text "echo \"file: $F\"" echo filter_variant_text "cat $F" echo done ) } 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]} } # 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 # Force use of non-interactive editor export EDITOR=$SANDPIT/bin/caton # Don't put the apache config files in $MODROOT/var 'cos they'll contaminate it. export PAA_STATE_PREFIX=$SANDPIT/var # Misc UNAMEN=$(uname -n) # Set up other stuff mkdir -p $SANDPIT/bin echo -e '#!/bin/sh\n\ncat > $1' > $SANDPIT/bin/caton chmod 755 $SANDPIT/bin/caton # This will quieten some of the reports mkdir repos etc # Register repos inspect_repos "before repoing" echo "$PROGNAME: adding various repos ..." paa -v repo debian deb accessed true paa -v repo multimedia deb accessed false inspect_repos "after repoing" echo # Configure repos inspect_repos "before configuring repos properly" echo "$PROGNAME: configuring repos properly ..." paa -v editrepo debian <./" EOF paa -v editrepo multimedia <./" EOF inspect_repos "after configuring repos properly" echo # Hosts inspect_hosts "before hosting" echo "$PROGNAME: adding some hosts ..." filter_variant_text "paa -v host $UNAMEN deb debian squeeze amd64 2>&1" inspect_hosts "after hosting" echo # Accesses inspect_accesses "before accessing" #launch_shell echo "$PROGNAME: accessing ..." paa -v access ALL-REPOS inspect_accesses "after accessing" echo # Unaccesses inspect_accesses "before unaccessing" echo "$PROGNAME: unaccessing ..." adetestsupport_invert_rc "paa -v unaccess ALL-REPOS" echo "$PROGNAME: trying again with force ..." paa -v --force unaccess ALL-REPOS inspect_accesses "after unaccessing" echo # Unhosts inspect_hosts "before unhosting" echo "$PROGNAME: unhosting ..." adetestsupport_invert_rc "paa -v unhost ALL-HOSTS" echo "$PROGNAME: trying again with force ..." filter_variant_text "paa -v --force unhost ALL-HOSTS 2>&1" inspect_hosts "after unhosting" echo # Unrepos inspect_repos "before unrepoing" echo "$PROGNAME: unrepoing ..." adetestsupport_invert_rc "paa -v unrepo ALL-REPOS" echo "$PROGNAME: trying again with force ..." filter_variant_text "paa -v --force unrepo ALL-REPOS 2>&1" inspect_repos "after unrepoing" echo echo "$PROGNAME: done"