#!/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 } 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_mirrors() { echo "$PROGNAME: listing mirrors ($1) ..." filter_variant_text "paa listmirrors" echo "$PROGNAME: inspecting mirrors ($1)..." filter_variant_text "( cd $SANDPIT && find mirrors 2>&1 | LC_ALL=C sort )" } inspect_freezes() { echo "$PROGNAME: listing freezes ($1) ..." filter_variant_text "paa listfreezes" echo "$PROGNAME: inspecting freezes ($1)..." filter_variant_text "( cd $SANDPIT && find freezes ! -type l 2>&1 | LC_ALL=C sort )" } inspect_indirects() { echo "$PROGNAME: listing indirects ($1) ..." filter_variant_text "paa listindirects" echo "$PROGNAME: inspecting indirects ($1)..." filter_variant_text "( cd $SANDPIT && find indirects -type l -printf \"%p -> %l\\n\" 2>&1 | LC_ALL=C sort )" } inspect_shares() { echo "$PROGNAME: listing shares ($1) ..." filter_variant_text "paa listshares" echo "$PROGNAME: inspecting shares ($1)..." filter_variant_text "( cd $SANDPIT && find var 2>&1 | LC_ALL=C sort )" } 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 )" } inspect_hosts() { echo "$PROGNAME: listing hosts ($1) ..." filter_variant_text "paa listhosts" } # End of support functions # 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 # 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 $MODROOT/var 'cos they'll contaminate it. export PAA_STATE_PREFIX=$SANDPIT/var # Misc UNAMEN=$(uname -n) ## rngd is needed to prevent 'gpg --gen-key' from blocking on insufficent entropy. #echo "$PROGNAME: checking rngd is running ..." #pidof rngd > /dev/null || { echo "rngd is not running"; false; } 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 "$PROGNAME: generating a gpg key ..." # Generate a key without a password and without communicating with my agent mkdir $GNUPGHOME chmod 700 $GNUPGHOME #gpg --quiet --batch --gen-key 2> /dev/null <./" mirror_dir "$SANDPIT/mirrors/" freeze_dir "$SANDPIT/freezes/." indirect_dir "$SANDPIT/indirects/." path "$SANDPIT/repos/owned-deb-repo" origin "Joe Tester" label "Joe Tester" signer "joe" EOF paa -v editrepo owned-rpm-repo <./" mirror_dir "$SANDPIT/mirrors/" freeze_dir "$SANDPIT/freezes/." indirect_dir "$SANDPIT/indirects/." path "$SANDPIT/repos/owned-rpm-repo" EOF inspect_repos "after configuring repos properly" echo # Inserts inspect_repos "before inserting" echo "$PROGNAME: inserting RPMs into owned-rpm-repo one at a time ..." # insert the RPMs one at a time so we are sure that missing arguments # are detected and not slurped from further along the command line. for RPM in $ADETEST_MODROOT/tests/in/*.rpm; do paa -v insert owned-rpm-repo 4,5,6 $RPM done echo "$PROGNAME: inserting DEBs into owned-deb-repo one at a time ..." for DEB in $ADETEST_MODROOT/tests/in/*.deb; do paa -v insert owned-deb-repo squeeze main $DEB done # same packages again in a batch echo "$PROGNAME: inserting RPMs into owned-rpm-repo all in one go ..." paa -v insert owned-rpm-repo 4,5,6 $ADETEST_MODROOT/tests/in/*.rpm echo "$PROGNAME: inserting DEBs into owned-deb-repo all in one go ..." paa -v insert owned-deb-repo squeeze main $ADETEST_MODROOT/tests/in/*.deb inspect_repos "after inserting" echo # Control inspect_repos "before controlling" echo "$PROGNAME: controlling owned-deb-repo ..." paa -v control owned-deb-repo echo "$PROGNAME: controlling owned-rpm-repo ..." paa -v control owned-rpm-repo echo "$PROGNAME: controlling ALL-REPOS ..." paa -v control ALL-REPOS inspect_repos "after controlling" echo # Unrepo 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 "$PROGNAME: manually cleaning up ..." rm -fr repos/owned-rpm-repo repos/owned-deb-repo inspect_repos "after manual cleanup" echo echo "$PROGNAME: done"