#1851 beaker: fix results-json test
Merged 3 years ago by praiskup. Opened 3 years ago by praiskup.
Unknown source beaker-json-results  into  main

@@ -1,4 +1,4 @@

- FROM fedora:33

+ FROM fedora:34

  ARG COPR_PACKAGES=devel

  MAINTAINER copr-devel@lists.fedorahosted.org

  ENV container docker
@@ -6,9 +6,11 @@

  RUN dnf -y update \

      && dnf -y install dnf-plugins-core wget \

      && wget https://beaker-project.org/yum/beaker-client-Fedora.repo -P /etc/yum.repos.d \

+     && true "see https://github.com/beakerlib/beakerlib/issues/103" \

+     && sed -i 's/$releasever/33/' /etc/yum.repos.d/beaker-client-Fedora.repo \

      && dnf -y copr enable @copr/copr \

      && if test "$COPR_PACKAGES" = devel; then dnf -y copr enable @copr/copr-dev; fi \

-     && dnf -y install htop net-tools iputils vim mlocate git sudo \

+     && dnf -y install hostname htop net-tools iputils vim mlocate git sudo \

                openssh-server psmisc python-jedi procps-ng findutils tmux \

                expect python3-behave python3-hamcrest \

      && dnf -y install python3-copr rpm-build copr-cli jq \

@@ -20,7 +20,7 @@

  # Some tests might want to install built packages

  # Therefore, these packages need to be built for the same fedora version

  # as this script is going to be run from

- FEDORA_VERSION=33

+ FEDORA_VERSION=34

  CHROOT="fedora-$FEDORA_VERSION-x86_64"

  BRANCH="f$FEDORA_VERSION"

  

@@ -9,11 +9,12 @@

  source "$HERE/config"

  source "$HERE/helpers"

  

+ set -o pipefail

  

  rlJournalStart

      rlPhaseStartSetup

          setup_checks

-         RESULTDIR=`mktemp -d`

+         RESULTDIR=$(mktemp -d)

      rlPhaseEnd

  

      rlPhaseStartTest
@@ -22,42 +23,46 @@

          rlRun "parse_build_id"

          rlRun "copr watch-build $BUILD_ID"

  

- 	checkResults()

- 	{

-             rlAssertEquals "There should be 4 results" `cat $RESULTDIR/results.json |jq '.packages | length'` 4

- 	    path=$1

- 	    rlRun "cat $path |jq -e '.packages[0].name == \"hello-debugsource\"'"

- 	    rlRun "cat $path |jq -e '.packages[0].epoch == 0'"

- 	    rlRun "cat $path |jq -e '.packages[0].version == \"2.8\"'"

- 	    rlRun "cat $path |jq -e '.packages[0].release == \"1.fc$FEDORA_VERSION\"'"

- 	    rlRun "cat $path |jq -e '.packages[0].arch == \"x86_64\"'"

- 

- 	    rlRun "cat $path |jq -e '.packages[1].name == \"hello\"'"

- 	    rlRun "cat $path |jq -e '.packages[1].epoch == 0'"

- 	    rlRun "cat $path |jq -e '.packages[1].version == \"2.8\"'"

- 	    rlRun "cat $path |jq -e '.packages[1].release == \"1.fc$FEDORA_VERSION\"'"

- 	    rlRun "cat $path |jq -e '.packages[1].arch == \"x86_64\"'"

- 

- 	    rlRun "cat $path |jq -e '.packages[2].name == \"hello\"'"

- 	    rlRun "cat $path |jq -e '.packages[2].epoch == 0'"

- 	    rlRun "cat $path |jq -e '.packages[2].version == \"2.8\"'"

- 	    rlRun "cat $path |jq -e '.packages[2].release == \"1.fc$FEDORA_VERSION\"'"

- 	    rlRun "cat $path |jq -e '.packages[2].arch == \"src\"'"

- 

- 	    rlRun "cat $path |jq -e '.packages[3].name == \"hello-debuginfo\"'"

- 	    rlRun "cat $path |jq -e '.packages[3].epoch == 0'"

- 	    rlRun "cat $path |jq -e '.packages[3].version == \"2.8\"'"

- 	    rlRun "cat $path |jq -e '.packages[3].release == \"1.fc$FEDORA_VERSION\"'"

- 	    rlRun "cat $path |jq -e '.packages[3].arch == \"x86_64\"'"

- 	}

- 

- 	# Check the results.json file that is stored on backend

+         checkResults()

+         {

+             orig_file=$1

+             path=$orig_file.sorted

+ 

+             jq -e '.packages|=sort_by(.name,.arch)' < "$orig_file" > "$path"

+             rlAssertEquals "There should be 4 results" "$(jq '.packages|length' < "$path")" 4

+ 

+             rlRun "cat $path |jq -e '.packages[0].name == \"hello\"'"

+             rlRun "cat $path |jq -e '.packages[0].epoch == 0'"

+             rlRun "cat $path |jq -e '.packages[0].version == \"2.8\"'"

+             rlRun "cat $path |jq -e '.packages[0].release == \"1.fc$FEDORA_VERSION\"'"

+             rlRun "cat $path |jq -e '.packages[0].arch == \"src\"'"

+ 

+             rlRun "cat $path |jq -e '.packages[1].name == \"hello\"'"

+             rlRun "cat $path |jq -e '.packages[1].epoch == 0'"

+             rlRun "cat $path |jq -e '.packages[1].version == \"2.8\"'"

+             rlRun "cat $path |jq -e '.packages[1].release == \"1.fc$FEDORA_VERSION\"'"

+             rlRun "cat $path |jq -e '.packages[1].arch == \"x86_64\"'"

+ 

+             rlRun "cat $path |jq -e '.packages[2].name == \"hello-debuginfo\"'"

+             rlRun "cat $path |jq -e '.packages[2].epoch == 0'"

+             rlRun "cat $path |jq -e '.packages[2].version == \"2.8\"'"

+             rlRun "cat $path |jq -e '.packages[2].release == \"1.fc$FEDORA_VERSION\"'"

+             rlRun "cat $path |jq -e '.packages[2].arch == \"x86_64\"'"

+ 

+             rlRun "cat $path |jq -e '.packages[3].name == \"hello-debugsource\"'"

+             rlRun "cat $path |jq -e '.packages[3].epoch == 0'"

+             rlRun "cat $path |jq -e '.packages[3].version == \"2.8\"'"

+             rlRun "cat $path |jq -e '.packages[3].release == \"1.fc$FEDORA_VERSION\"'"

+             rlRun "cat $path |jq -e '.packages[3].arch == \"x86_64\"'"

+         }

+ 

+         # Check the results.json file that is stored on backend

          URL_PATH="results/${NAME_PREFIX}TestResultsJson/$CHROOT/$(build_id_with_leading_zeroes)-hello/results.json"

-         rlRun "wget -P $RESULTDIR $BACKEND_URL/$URL_PATH"

- 	checkResults "$RESULTDIR/results.json"

+         rlRun "curl $BACKEND_URL/$URL_PATH > $RESULTDIR/results.json"

+         checkResults "$RESULTDIR/results.json"

  

  

- 	# Check the /build-chroot/built-packages/ APIv3 route

+         # Check the /build-chroot/built-packages/ APIv3 route

          python << END

  from copr.v3 import Client

  from copr_cli.util import json_dumps
@@ -67,10 +72,10 @@

  with open("$RESULTDIR/results-api-build-chroot.json", "w") as f:

      f.write(json_dumps(response))

  END

- 	checkResults "$RESULTDIR/results-api-build-chroot.json"

+         checkResults "$RESULTDIR/results-api-build-chroot.json"

  

  

- 	# Check the /build/built-packages/ APIv3 route

+         # Check the /build/built-packages/ APIv3 route

          python << END

  from copr.v3 import Client

  from copr_cli.util import json_dumps
@@ -80,7 +85,7 @@

  with open("$RESULTDIR/results-api-build.json", "w") as f:

      f.write(json_dumps(response["$CHROOT"]))

  END

- 	checkResults "$RESULTDIR/results-api-build.json"

+         checkResults "$RESULTDIR/results-api-build.json"

  

  

      rlPhaseEnd

@@ -17,6 +17,6 @@

  

      @packages @builds

      Scenario: Test that we can add and build dist-git packages

-         When a DistGit CentOS "setup" package from branch "c8" is added

+         When a DistGit CentOS "filesystem" package from branch "c8" is added

          And the package build is requested

          Then the build results are distributed

Sort the results.json file (by default unsorted) and then compare the
contents correctly. Re-tab while I'm on it to avoid mixed spaces/tabs.

Fixes: #1846

Build succeeded.

rebased onto f5950aea52aefca2060e20ae076d5da332a8b754

3 years ago

Build succeeded.

rebased onto ea67a3896fc92fe19db02f1af07e7f46396c71f1

3 years ago

1 new commit added

  • beaker: install hostname.rpm into the testing environment
3 years ago

Build succeeded.

rebased onto f91edc0

3 years ago

Build succeeded.

1 new commit added

  • beaker: move testsuite to f34
3 years ago

Build succeeded.

3 new commits added

  • beaker: move testsuite to f34
  • beaker: install hostname.rpm into the testing environment
  • beaker: fix results-json test
3 years ago

Build succeeded.

3 new commits added

  • beaker: move testsuite to f34
  • beaker: install hostname.rpm into the testing environment
  • beaker: fix results-json test
3 years ago

Build succeeded.

Pull-Request has been merged by praiskup

3 years ago

Re-tab while I'm on it to avoid mixed spaces/tabs.

Sorry, I need to pay better attention to this next time.