#1206 beaker-tests: racy test for package-delete
Merged 4 years ago by praiskup. Opened 4 years ago by praiskup.
Unknown source racy-beaker-tests-2  into  master

@@ -0,0 +1,61 @@

+ #! /bin/bash

+ #

+ # Copyright (c) 2020 Red Hat, Inc.

+ #

+ # 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 of

+ # the License, or (at your option) any later version.

+ #

+ # This program 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 program. If not, see http://www.gnu.org/licenses/.

+ 

+ 

+ # Include Beaker environment

+ . /usr/bin/rhts-environment.sh || exit 1

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ # Load config settings

+ HERE=$(dirname "$(realpath "$0")")

+ source "$HERE/config"

+ source "$HERE/helpers"

+ 

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm "copr-cli"

+         rlAssertRpm "jq"

+         rlAssertExists ~/.config/copr

+         TMP=$(mktemp -d)

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+         # Bug 1368259 - Deleting a build from a group project doesn't delete backend files

+         rlRun "copr-cli create ${NAME_PREFIX}TestDeleteGroupBuild --chroot $CHROOT" 0

+         rlRun "copr-cli add-package-scm ${NAME_PREFIX}TestDeleteGroupBuild --name example --clone-url $COPR_HELLO_GIT"

+         rlRun "copr-cli build-package --name example ${NAME_PREFIX}TestDeleteGroupBuild | grep 'Created builds:' | sed 's/Created builds: \([0-9][0-9]*\)/\1/g' > $TMP/TestDeleteGroupBuild_example_build_id.txt"

+         BUILD_ID=$(cat "$TMP"/TestDeleteGroupBuild_example_build_id.txt)

+ 

+         chroot_url=$BACKEND_URL/results/${NAME_PREFIX}TestDeleteGroupBuild/$CHROOT

+         check_url=$chroot_url/$(printf "%08d" "$BUILD_ID")-example

+         rlRun "curl -f $check_url" 0 "check that the directory still exists"

+         rlRun "copr-cli delete-package --name example ${NAME_PREFIX}TestDeleteGroupBuild"

+         i=0

+         while curl -f "$check_url"; do

+             sleep 2

+             i=$(( i + 2 ))

+             test "$i" -gt 60 && break

+         done

+         rlAssertGreater "Check that we did not wait longer than 60s" 60 "$i"

+     rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+         cleanProject "${NAME_PREFIX}TestDeleteGroupBuild"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

@@ -467,23 +467,6 @@

          sleep 30

          rlAssertEquals "Test that the project was successfully deleted from backend" `curl -w '%{response_code}' -silent -o /dev/null $BACKEND_URL/results/${NAME_PREFIX}TestConsequentDeleteActions/` 404

  

-         # Bug 1368259 - Deleting a build from a group project doesn't delete backend files

-         TMP=`mktemp -d`

-         rlRun "copr-cli create ${NAME_PREFIX}TestDeleteGroupBuild --chroot $CHROOT" 0

-         rlRun "copr-cli add-package-scm ${NAME_PREFIX}TestDeleteGroupBuild --name example --clone-url $COPR_HELLO_GIT"

-         rlRun "copr-cli build-package --name example ${NAME_PREFIX}TestDeleteGroupBuild | grep 'Created builds:' | sed 's/Created builds: \([0-9][0-9]*\)/\1/g' > $TMP/TestDeleteGroupBuild_example_build_id.txt"

-         BUILD_ID=`cat $TMP/TestDeleteGroupBuild_example_build_id.txt`

-         MYTMPDIR=`mktemp -d -p .` && cd $MYTMPDIR

-         wget -r -np $BACKEND_URL/results/${NAME_PREFIX}TestDeleteGroupBuild/$CHROOT/

-         rlRun "find . -type d | grep '${BUILD_ID}-example'" 0 "Test that the build directory, ideally with results, is present on backend"

-         cd - && rm -r $MYTMPDIR

-         MYTMPDIR=`mktemp -d -p .` && cd $MYTMPDIR

-         rlRun "copr-cli delete-package --name example ${NAME_PREFIX}TestDeleteGroupBuild" # FIXME: We don't have copr-cli delete-build yet

-         sleep 11 # default sleeptime + 1

-         wget -r -np $BACKEND_URL/results/${NAME_PREFIX}TestDeleteGroupBuild/$CHROOT/

-         rlRun "find . -type d | grep '${BUILD_ID}-example'" 1 "Test that the build directory is not present on backend"

-         cd - && rm -r $MYTMPDIR

- 

          # test that results and configs are correctly retrieved from builders after build

          rlRun "copr-cli create ${NAME_PREFIX}DownloadMockCfgs --chroot $CHROOT" 0

          rlRun "copr-cli build ${NAME_PREFIX}DownloadMockCfgs $HELLO"
@@ -563,7 +546,6 @@

          cleanProject "${NAME_PREFIX}TestBug1393361-2"

          cleanProject "${NAME_PREFIX}ModifyProjectChroots"

          cleanProject "${NAME_PREFIX}EditChrootProject"

-         cleanProject "${NAME_PREFIX}TestDeleteGroupBuild"

          cleanProject "${NAME_PREFIX}MockConfig"

          cleanProject "${NAME_PREFIX}MockConfigParent"

          cleanProject "${NAME_PREFIX}TestBug1444804"

11 seconds sleep might not be enough sometimes, and sometimes it can be
too much. Let's retry each 2 seconds, and fail after 60s.

Also, while I'm on it - let's cut the test out into a separate file.

thanks for the review!

rebased onto bacf132

4 years ago

Pull-Request has been merged by praiskup

4 years ago