From 87c403095cb9b98f9d831535792f3a94a5666870 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Wed, 20 Nov 2024 10:22:31 +0100 Subject: [PATCH] beakertests: move PyPI tests into one file This makes the runtest.sh at least shorter (but still the longest-running test-case). Adapt the test-cases to post-F39 state. Relates: #3517 Relates: #3521 Relates: #3523 --- .../runtest-pyp2spec.sh | 61 --------- .../copr-cli-basic-operations/runtest-pypi.sh | 117 ++++++++++++++++++ .../copr-cli-basic-operations/runtest.sh | 46 +------ 3 files changed, 122 insertions(+), 102 deletions(-) delete mode 100755 beaker-tests/Sanity/copr-cli-basic-operations/runtest-pyp2spec.sh create mode 100755 beaker-tests/Sanity/copr-cli-basic-operations/runtest-pypi.sh diff --git a/beaker-tests/Sanity/copr-cli-basic-operations/runtest-pyp2spec.sh b/beaker-tests/Sanity/copr-cli-basic-operations/runtest-pyp2spec.sh deleted file mode 100755 index 874856c5d..000000000 --- a/beaker-tests/Sanity/copr-cli-basic-operations/runtest-pyp2spec.sh +++ /dev/null @@ -1,61 +0,0 @@ -#! /bin/bash -# -# Copyright (c) 2022 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/share/beakerlib/beakerlib.sh || exit 1 - -# Load config settings -HERE=$(dirname "$(realpath "$0")") -source "$HERE/config" -source "$HERE/helpers" - -PYPI_PACKAGE="pello" -PACKAGE="test_package_pypi" - - -rlJournalStart - rlPhaseStartSetup - setup_checks - setupProjectName "Pyp2spec" - rlPhaseEnd - - rlPhaseStartTest - rlRun "copr-cli create --chroot $CHROOT $PROJECT" - - # Submit pyp2spec build directly - rlRun "copr-cli buildpypi $PROJECT --packagename $PYPI_PACKAGE --spec-generator pyp2spec" - - # Create pyp2spec package - rlRun "copr-cli add-package-pypi $PROJECT --name $PACKAGE --packagename $PYPI_PACKAGE --spec-generator pyp2spec" - - # Build the package - rlRun -s "copr-cli build-package --name $PACKAGE $PROJECT -r $CHROOT --nowait" - rlRun "parse_build_id" - rlRun "copr watch-build $BUILD_ID" - - # rlRun "copr-cli download-build $BUILD_ID" - rlRun "wget $BACKEND_URL/results/$PROJECT/srpm-builds/$(printf %08d "$BUILD_ID")/builder-live.log.gz" - rlRun "gzip -fd builder-live.log.gz" - rlRun "head builder-live.log -n 50 |grep spec_generator |grep pyp2spec" - rlPhaseEnd - - rlPhaseStartCleanup - cleanProject - rlPhaseEnd -rlJournalPrintText -rlJournalEnd diff --git a/beaker-tests/Sanity/copr-cli-basic-operations/runtest-pypi.sh b/beaker-tests/Sanity/copr-cli-basic-operations/runtest-pypi.sh new file mode 100755 index 000000000..f8e584c7c --- /dev/null +++ b/beaker-tests/Sanity/copr-cli-basic-operations/runtest-pypi.sh @@ -0,0 +1,117 @@ +#! /bin/bash +# +# Copyright (c) 2024 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/share/beakerlib/beakerlib.sh || exit 1 + +# Load config settings +HERE=$(dirname "$(realpath "$0")") +source "$HERE/config" +source "$HERE/helpers" + +# The "pello" package was previously included here but did not conform +# to PEP 625 standards. +PYPI_PACKAGE="pyp2spec" +PACKAGE_OVERRIDE=test_package_pypi + +# TODO: Test PEP 625 non-compliant package. Refer to #3517 discussion. + +rlJournalStart + rlPhaseStartSetup + setup_checks + workdirSetup + setupProjectName "Pyp2spec" + rlPhaseEnd + + rlPhaseStartTest + rlRun "copr-cli create --chroot $CHROOT $PROJECT" + + # Submit pyp2rpm build directly. Package is old and not buildable with + # pyp2spec (at least the last motionpaint version v1.52). + rlRun "copr-cli buildpypi $PROJECT --spec-generator pyp2rpm --template fedora --packagename motionpaint --pythonversions 3" + + # Submit pyp2spec build directly, generates python-pyp2spec package + rlRun "copr-cli buildpypi $PROJECT --packagename $PYPI_PACKAGE --spec-generator pyp2spec" + + # Create pyp2spec package, not python-pyp2spec + rlRun "copr-cli add-package-pypi $PROJECT --name pyp2spec --packagename $PYPI_PACKAGE --spec-generator pyp2spec" + + # Build the package + rlRun -s "copr-cli build-package --name pyp2spec $PROJECT -r $CHROOT --nowait" + rlRun "parse_build_id" + rlRun "copr watch-build $BUILD_ID" + + # rlRun "copr-cli download-build $BUILD_ID" + rlRun "wget $BACKEND_URL/results/$PROJECT/srpm-builds/$(printf %08d "$BUILD_ID")/builder-live.log.gz" + rlRun "gzip -fd builder-live.log.gz" + rlRun "head builder-live.log -n 50 |grep spec_generator |grep pyp2spec" + + OUTPUT=output-file.log + SOURCE_DICT=source-dict.json + + # PyPI package creation, pyp2rpm building itself + rlRun "copr-cli add-package-pypi $PROJECT --name $PACKAGE_OVERRIDE --packagename pyp2rpm --spec-generator pyp2rpm --packageversion 1.5 --pythonversions 3" + rlRun "copr-cli get-package $PROJECT --name $PACKAGE_OVERRIDE > $OUTPUT" + rlRun "cat $OUTPUT | jq '.source_dict' > $SOURCE_DICT" + rlAssertEquals "package.name == \"$PACKAGE_OVERRIDE\"" `cat $OUTPUT | jq '.name'` "\"$PACKAGE_OVERRIDE\"" + rlAssertEquals "package.source_type == \"pypi\"" `cat $OUTPUT | jq '.source_type'` '"pypi"' + rlRun `cat $SOURCE_DICT | jq '.python_versions == ["3"]'` 0 "package.source_dict.python_versions == [\"3\"]" + rlAssertEquals "package.source_dict.pypi_package_name == \"pyp2rpm\"" `cat $SOURCE_DICT | jq '.pypi_package_name'` '"pyp2rpm"' + rlAssertEquals "package.source_dict.pypi_package_version == \"bar\"" `cat $SOURCE_DICT | jq '.pypi_package_version'` '"1.5"' + rlAssertEquals "package.source_dict.spec_generator == \"pyp2rpm\"" `cat $SOURCE_DICT | jq '.spec_generator'` '"pyp2rpm"' + + # PyPI package modification. + # - reset the copr package to a different PyPI project + # - reset (implicitly) to pyp2spec generator by default https://github.com/fedora-copr/copr/issues/3523 + rlRun "copr-cli edit-package-pypi $PROJECT --name $PACKAGE_OVERRIDE --packagename motionpaint --packageversion 1.4 --pythonversions 3" + rlRun "copr-cli get-package $PROJECT --name $PACKAGE_OVERRIDE > $OUTPUT" + cat $OUTPUT | jq '.source_dict' > $SOURCE_DICT + rlAssertEquals "package.name == \"$PACKAGE_OVERRIDE\"" `cat $OUTPUT | jq '.name'` "\"$PACKAGE_OVERRIDE\"" + rlAssertEquals "package.source_type == \"pypi\"" `cat $OUTPUT | jq '.source_type'` '"pypi"' + rlRun `cat $SOURCE_DICT | jq '.python_versions == ["3"]'` 0 "package.source_dict.python_versions == [\"3\"]" + rlAssertEquals "package.source_dict.pypi_package_name == \"motionpaint\"" `cat $SOURCE_DICT | jq '.pypi_package_name'` '"motionpaint"' + rlAssertEquals "package.source_dict.pypi_package_version == \"bar\"" `cat $SOURCE_DICT | jq '.pypi_package_version'` '"1.4"' + rlAssertEquals "package.source_dict.spec_template == \"\"" `cat $SOURCE_DICT | jq '.spec_template'` '""' + rlAssertEquals "package.source_dict.spec_generator == \"pyp2rpm\"" `cat $SOURCE_DICT | jq '.spec_generator'` '"pyp2spec"' + + # PyPI package templates + rlRun "copr-cli edit-package-pypi $PROJECT --name $PACKAGE_OVERRIDE --template fedora" + rlRun "copr-cli get-package $PROJECT --name $PACKAGE_OVERRIDE > $OUTPUT" + cat $OUTPUT | jq '.source_dict' > $SOURCE_DICT + rlAssertEquals "package.source_dict.spec_template == \"fedora\"" `cat $SOURCE_DICT | jq '.spec_template'` '"fedora"' + + # build the package, but first reset back to pyp2rpm (otherwise # motionpaint fails to build) + OUTPUT=motionpaint-package.json + rlRun "copr-cli edit-package-pypi $PROJECT --name $PACKAGE_OVERRIDE --spec-generator pyp2rpm --packageversion 1.4 --pythonversions 3" + rlRun "copr-cli build-package --name $PACKAGE_OVERRIDE $PROJECT -r $CHROOT" + rlRun "copr-cli get-package $PROJECT --name $PACKAGE_OVERRIDE > $OUTPUT" + rlAssertEquals "check that motionpaint is used" "$(jq '.source_dict.pypi_package_name' < "$OUTPUT")" '"motionpaint"' + + ## Package listing + rlAssertEquals "len(package_list) == 4" `copr-cli list-packages $PROJECT | jq '. | length'` 4 + + # try to build copr-cli from pypi, broken now, uncomment once #3517 is fixed + #rlRun "copr-cli add-package-pypi $PROJECT --name copr-cli --packagename copr-cli" + rlPhaseEnd + + rlPhaseStartCleanup + cleanProject + workdirCleanup + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/beaker-tests/Sanity/copr-cli-basic-operations/runtest.sh b/beaker-tests/Sanity/copr-cli-basic-operations/runtest.sh index a32215c18..a004eeb50 100755 --- a/beaker-tests/Sanity/copr-cli-basic-operations/runtest.sh +++ b/beaker-tests/Sanity/copr-cli-basic-operations/runtest.sh @@ -237,36 +237,6 @@ rlJournalStart # create special repo for our test rlRun "copr-cli create --chroot $CHROOT ${NAME_PREFIX}Project4" - # PyPI package creation - rlRun "copr-cli add-package-pypi ${NAME_PREFIX}Project4 --name test_package_pypi --packagename pyp2rpm --packageversion 1.5 --pythonversions 3" - rlRun "copr-cli get-package ${NAME_PREFIX}Project4 --name test_package_pypi > $OUTPUT" - cat $OUTPUT | jq '.source_dict' > $SOURCE_DICT - rlAssertEquals "package.name == \"test_package_pypi\"" `cat $OUTPUT | jq '.name'` '"test_package_pypi"' - rlAssertEquals "package.source_type == \"pypi\"" `cat $OUTPUT | jq '.source_type'` '"pypi"' - rlRun `cat $SOURCE_DICT | jq '.python_versions == ["3"]'` 0 "package.source_dict.python_versions == [\"3\"]" - rlAssertEquals "package.source_dict.pypi_package_name == \"pyp2rpm\"" `cat $SOURCE_DICT | jq '.pypi_package_name'` '"pyp2rpm"' - rlAssertEquals "package.source_dict.pypi_package_version == \"bar\"" `cat $SOURCE_DICT | jq '.pypi_package_version'` '"1.5"' - - # PyPI package editing - rlRun "copr-cli edit-package-pypi ${NAME_PREFIX}Project4 --name test_package_pypi --packagename motionpaint --packageversion 1.4 --pythonversions 3" - rlRun "copr-cli get-package ${NAME_PREFIX}Project4 --name test_package_pypi > $OUTPUT" - cat $OUTPUT | jq '.source_dict' > $SOURCE_DICT - rlAssertEquals "package.name == \"test_package_pypi\"" `cat $OUTPUT | jq '.name'` '"test_package_pypi"' - rlAssertEquals "package.source_type == \"pypi\"" `cat $OUTPUT | jq '.source_type'` '"pypi"' - rlRun `cat $SOURCE_DICT | jq '.python_versions == ["3"]'` 0 "package.source_dict.python_versions == [\"3\"]" - rlAssertEquals "package.source_dict.pypi_package_name == \"motionpaint\"" `cat $SOURCE_DICT | jq '.pypi_package_name'` '"motionpaint"' - rlAssertEquals "package.source_dict.pypi_package_version == \"bar\"" `cat $SOURCE_DICT | jq '.pypi_package_version'` '"1.4"' - rlAssertEquals "package.source_dict.spec_template == \"\"" `cat $SOURCE_DICT | jq '.spec_template'` '""' - - # PyPI package templates - rlRun "copr-cli edit-package-pypi ${NAME_PREFIX}Project4 --name test_package_pypi --template fedora" - rlRun "copr-cli get-package ${NAME_PREFIX}Project4 --name test_package_pypi > $OUTPUT" - cat $OUTPUT | jq '.source_dict' > $SOURCE_DICT - rlAssertEquals "package.source_dict.spec_template == \"fedora\"" `cat $SOURCE_DICT | jq '.spec_template'` '"fedora"' - - ## Package listing - rlAssertEquals "len(package_list) == 1" `copr-cli list-packages ${NAME_PREFIX}Project4 | jq '. | length'` 1 - # RubyGems package creation rlRun "copr-cli add-package-rubygems ${NAME_PREFIX}Project4 --name xxx --gem yyy" rlRun "copr-cli get-package ${NAME_PREFIX}Project4 --name xxx > $OUTPUT" @@ -284,7 +254,7 @@ rlJournalStart rlAssertEquals "package.source_dict.gem_name == \"zzz\"" `cat $SOURCE_DICT | jq '.gem_name'` '"zzz"' ## Package listing - rlAssertEquals "len(package_list) == 2" `copr-cli list-packages ${NAME_PREFIX}Project4 | jq '. | length'` 2 + rlAssertEquals "len(package_list) == 1" `copr-cli list-packages ${NAME_PREFIX}Project4 | jq '. | length'` 1 ## Package reseting rlRun "copr-cli add-package-scm ${NAME_PREFIX}Project4 --name test_package_reset --clone-url $COPR_HELLO_GIT --method tito" @@ -305,20 +275,20 @@ rlJournalStart rlAssertEquals "package.source_dict == \"{}\"" `cat $OUTPUT | jq '.source_dict'` '{}' ## Package listing - rlAssertEquals "len(package_list) == 3" `copr-cli list-packages ${NAME_PREFIX}Project4 | jq '. | length'` 3 + rlAssertEquals "len(package_list) == 2" `copr-cli list-packages ${NAME_PREFIX}Project4 | jq '. | length'` 2 ## Package deletion rlRun "copr-cli add-package-scm ${NAME_PREFIX}Project4 --name test_package_delete --clone-url $COPR_HELLO_GIT --method tito" rlRun "copr-cli get-package ${NAME_PREFIX}Project4 --name test_package_delete > /dev/null" ## Package listing - rlAssertEquals "len(package_list) == 4" `copr-cli list-packages ${NAME_PREFIX}Project4 | jq '. | length'` 4 + rlAssertEquals "len(package_list) == 3" `copr-cli list-packages ${NAME_PREFIX}Project4 | jq '. | length'` 3 rlRun "copr-cli delete-package ${NAME_PREFIX}Project4 --name test_package_delete" rlRun "copr-cli get-package ${NAME_PREFIX}Project4 --name test_package_delete" 1 # package cannot be fetched now (cause it is deleted) ## Package listing - rlAssertEquals "len(package_list) == 3" `copr-cli list-packages ${NAME_PREFIX}Project4 | jq '. | length'` 3 + rlAssertEquals "len(package_list) == 2" `copr-cli list-packages ${NAME_PREFIX}Project4 | jq '. | length'` 2 # Packages having all sort of symbols in name, these succeed .. rlRun "copr-cli add-package-rubygems ${NAME_PREFIX}Project4 --name gcc-c++ --gem yyy" @@ -329,7 +299,7 @@ rlJournalStart rlRun "copr-cli add-package-rubygems ${NAME_PREFIX}Project4 --name x:x --gem yyy" 1 rlRun "copr-cli add-package-rubygems ${NAME_PREFIX}Project4 --name x@x --gem yyy" 1 - rlAssertEquals "len(package_list) == 3" `copr-cli list-packages ${NAME_PREFIX}Project4 | jq '. | length'` 6 + rlAssertEquals "len(package_list) == 5" `copr-cli list-packages ${NAME_PREFIX}Project4 | jq '. | length'` 5 ## test package building # create special repo for our test @@ -341,12 +311,6 @@ rlJournalStart # build the package rlRun "copr-cli build-package --name test_package_scm ${NAME_PREFIX}Project6 --timeout 10000 -r $CHROOT" # TODO: timeout not honored - # create pyp2spec (default) package - rlRun "copr-cli add-package-pypi ${NAME_PREFIX}Project6 --name test_package_pypi --template fedora --packagename copr-cli --pythonversions 3" - - # build the package - rlRun "copr-cli build-package --name test_package_pypi ${NAME_PREFIX}Project6 -r $CHROOT" - # test unlisted_on_hp project attribute rlRun "copr-cli create --unlisted-on-hp on --chroot $CHROOT ${NAME_PREFIX}Project7" rlRun "curl $FRONTEND_URL --silent | grep Project7" 1 # project won't be present on hp