Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

beakertests: move PyPI tests into one file #3525

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 0 additions & 61 deletions beaker-tests/Sanity/copr-cli-basic-operations/runtest-pyp2spec.sh

This file was deleted.

117 changes: 117 additions & 0 deletions beaker-tests/Sanity/copr-cli-basic-operations/runtest-pypi.sh
Original file line number Diff line number Diff line change
@@ -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
46 changes: 5 additions & 41 deletions beaker-tests/Sanity/copr-cli-basic-operations/runtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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
Expand All @@ -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
Expand Down