#756 use jq in beaker tests
Merged 4 years ago by praiskup. Opened 4 years ago by praiskup.
Unknown source jq-in-beaker-tests  into  master

@@ -0,0 +1,60 @@

+ #! /bin/bash

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of /tools/copr/Sanity/auto-prune

+ #   Description: Tests that --auto-prune works in cli.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2019 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"

+ 

+ assert_auto_prune ()

+ {

+     rlRun -s "curl --silent ${FRONTEND_URL}/api/coprs/${NAME_PREFIX}AutoPrune/detail/" 0

+     rlRun "auto_prune=$(jq .detail.auto_prune < "$rlRun_LOG")"

+     rlAssertEquals "auto prune is $1" "$auto_prune" "$1"

+ }

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm "copr-cli"

+         rlAssertRpm "jq"

+         rlAssertExists ~/.config/copr

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+         rlRun "copr-cli create --auto-prune off --chroot $CHROOT ${NAME_PREFIX}AutoPrune"

+         assert_auto_prune false

+         rlRun "copr-cli modify --auto-prune on ${NAME_PREFIX}AutoPrune"

+         assert_auto_prune true

+     rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+         rlRun "copr-cli delete ${NAME_PREFIX}AutoPrune"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

@@ -155,7 +155,7 @@

      rlLogInfo "Still should fail, since this build is not triggered by webhook."

      rlRun 'copr watch-build $BUILD_ID' 4

  

-     copr_id=$(curl "$FRONTEND_URL/api_3/project?ownername=$USER&projectname=$PROJECT" | sed -n 's/.*"id": \([0-9]\+\),.*/\1/p')

+     copr_id=$(curl "$FRONTEND_URL/api_3/project?ownername=$USER&projectname=$PROJECT" | jq '.id')

      trigger_url="$FRONTEND_URL/webhooks/custom/$copr_id/webhook_secret/quick-package/"

      rlRun -s 'curl -I "$trigger_url"' 0 # GET can't work

      rlRun 'check_http_status 405'

@@ -191,7 +191,7 @@

          rlRun "rpm -q mksh"

          rlRun "dnf -y module remove testmodule:beakertest/default"

          rlRun "dnf -y module disable testmodule"

- 

+         rlRun "rm /etc/yum.repos.d/testmodule.repo"

  

          # @TODO Test that enabled module info is correct

          # Feature for enabling module from Copr is not in upstream

@@ -137,12 +137,6 @@

          rlRun "cat $TMP/hello_p3.id|xargs copr-cli delete-build"

          rlRun "copr-cli status `cat $TMP/hello_p3.id`" 1

  

-         ## test --auto-prune option

-         rlRun "copr-cli create --auto-prune off --chroot $CHROOT ${NAME_PREFIX}AutoPrune"

-         rlRun "curl --silent ${FRONTEND_URL}/api/coprs/${NAME_PREFIX}AutoPrune/detail/ | grep '\"auto_prune\": false'" 0

-         rlRun "copr-cli modify --auto-prune on ${NAME_PREFIX}AutoPrune"

-         rlRun "curl --silent ${FRONTEND_URL}/api/coprs/${NAME_PREFIX}AutoPrune/detail/ | grep '\"auto_prune\": true'" 0

- 

          ## test to modify list of enabled chroots in the project

          # create project

          rlRun "copr-cli create --chroot $CHROOT ${NAME_PREFIX}ModifyProjectChroots"
@@ -573,7 +567,6 @@

          rlRun "copr-cli delete ${NAME_PREFIX}ProjectDistGitBuilds"

          rlRun "copr-cli delete ${NAME_PREFIX}TestBug1393361-1"

          rlRun "copr-cli delete ${NAME_PREFIX}TestBug1393361-2"

-         rlRun "copr-cli delete ${NAME_PREFIX}AutoPrune"

          rlRun "copr-cli delete ${NAME_PREFIX}ModifyProjectChroots"

          rlRun "copr-cli delete ${NAME_PREFIX}EditChrootProject"

          rlRun "copr-cli delete ${NAME_PREFIX}TestDeleteGroupBuild"

no initial comment

Completely unrelated to this PR, it would be cool if we had something like copr-cli auth-check based on BaseProxy.auth_check().

Agreed, but here I suppose we can live without calling 'copr-cli list'. I just C&P'ed it from the original file.

3 new commits added

  • [beaker-tests] modules: remove module repo once we are done
  • [beaker-tests] use jq in --auto-prune test as well
  • [beaker-tests] use jq instead of grep
4 years ago

3 new commits added

  • [beaker-tests] modules: remove module repo once we are done
  • [beaker-tests] use jq in --auto-prune test as well
  • [beaker-tests] use jq instead of grep
4 years ago

Merging, I only removed the copr-cli list and replaced tab with space in added code since last +1.

Pull-Request has been merged by praiskup

4 years ago