#!/bin/bash # $HeadURL$ $LastChangedRevision$ PROGNAME=`basename $0` SANDPIT=`pwd` . $(ade-config ade_share_prefix)/include/adetestsupport.sh ############################################################################## # # Purpose of test: to verify that long operations (mirror,freeze,unfreeze, # unmirror) performed on the same repository read the # repository status information *just before* starting the # operation - at a time when another instance of the long # operation may already be running - and *not* (as they did # when this test was written) load the state information # a *long time before* starting the operation (by which # time the information they have on the repository's status # (locked/not locked) can be out of date). # # Bug id: # ############################################################################## # Ensure dates are consistently formatted export LC_ALL=C # Start of support functions filter_variant_text() { eval "$@" | sed -e 's/\(testrepo: locked (\)[1-9][0-9]*\( is working on this)\)/\199999\2/' \ -e 's/\(testrepo.\)[0-9]*\(: locked (\)[1-9][0-9]*\( is working on this)\)/\119991231235999\299999\3/' \ # return the passed command's return code, not sed's. return ${PIPESTATUS[0]} } # End of support functions # Set up environment echo "setting up environment ..." # 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 mkdir $SANDPIT/bin echo -e '#!/bin/sh\n\ncat > $1' > $SANDPIT/bin/caton chmod 755 $SANDPIT/bin/caton 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) # Some operations are so quick that they generate inconsistent results. E.g. unmirroring # may see another unmirroring going on and report that another process is doing something, # but if that other process actually finishes then it'll report that there's no such mirror. # So we *must* slow everything down. export SLEEP=5 # Set up repos echo "setting up a repo ..." # Create base dirs mkdir -p $SANDPIT/{repos,mirrors,freezes,indirects} # Create a repository to mirror (don't use paa, 'cos it's # not owned repos we're interested in here). mkdir -p $SANDPIT/repos/testrepo ls > $SANDPIT/repos/testrepo/file1 ls > $SANDPIT/repos/testrepo/file2 # Get the DB created *without* contention. This way when we # define a repo twice in parallel we won't get "table already exists" # errors. paa listrepos > /dev/null # Define twice in parallel echo "running define twice in parallel ..." filter_variant_text "paa repo testrepo deb mirrored true 2>&1" & filter_variant_text "paa repo testrepo deb mirrored true 2>&1" & wait # Configure repo minimally paa editrepo testrepo <" freeze_dir "$SANDPIT/freezes/." indirect_dir "$SANDPIT/indirects/." mirror_cmd "rsync -a --delete $SANDPIT/repos/testrepo/ ./" EOF # Run mirror twice in parallel. echo "running mirror twice in parallel ..." filter_variant_text "paa mirror testrepo 2>&1" & filter_variant_text "paa mirror testrepo 2>&1" & wait # Run freeze twice in parallel. echo "running freeze twice in parallel ..." filter_variant_text "paa freeze testrepo 2>&1" & # This one might not fail! If the time is 00:00:00.99 when the first one # runs and 00:00:01.01 when the second one runs then they will create different # freezes. filter_variant_text "paa freeze testrepo 2>&1" & wait # Run unfreeze twice in parallel. echo "running unfreeze twice in parallel ..." filter_variant_text "paa --force unfreeze testrepo ALL-FREEZES 2>&1" & filter_variant_text "paa --force unfreeze testrepo ALL-FREEZES 2>&1" & wait # Run freeze twice in parallel. echo "running unmirror twice in parallel ..." filter_variant_text "paa unmirror testrepo 2>&1" & filter_variant_text "paa unmirror testrepo 2>&1" & wait # Undefine twice in parallel echo "running undefine twice in parallel ..." filter_variant_text "paa unrepo testrepo 2>&1" & filter_variant_text "paa unrepo testrepo 2>&1" & wait # End of test echo "end of test"