From 436b191467296b7f5a3de5b4e9eb471418f76381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zachar?= Date: Fri, 14 Aug 2026 11:38:14 +0200 Subject: [PATCH] Use osci and tmt for gating --- .fmf/version | 1 + gating.yaml | 2 +- plan.fmf | 7 ++++ tests/smoke/main.fmf | 6 +++ tests/smoke/runtest.sh | 61 ++++++++++++++++++++++++++++ tests/smoke/test.py | 12 ++++++ tests/upstream/main.fmf | 13 ++++++ tests/upstream/runtest.sh | 85 +++++++++++++++++++++++++++++++++++++++ 8 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 .fmf/version create mode 100644 plan.fmf create mode 100644 tests/smoke/main.fmf create mode 100755 tests/smoke/runtest.sh create mode 100644 tests/smoke/test.py create mode 100644 tests/upstream/main.fmf create mode 100755 tests/upstream/runtest.sh diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/gating.yaml b/gating.yaml index 9e0ee4a..6985029 100644 --- a/gating.yaml +++ b/gating.yaml @@ -3,4 +3,4 @@ product_versions: - rhel-8 decision_context: osci_compose_gate rules: - - !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.tier1.functional} \ No newline at end of file + - !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional} diff --git a/plan.fmf b/plan.fmf new file mode 100644 index 0000000..801029e --- /dev/null +++ b/plan.fmf @@ -0,0 +1,7 @@ +environment: + PYTHON: /usr/libexec/platform-python +execute: + how: tmt +discover: + how: fmf + diff --git a/tests/smoke/main.fmf b/tests/smoke/main.fmf new file mode 100644 index 0000000..b10b038 --- /dev/null +++ b/tests/smoke/main.fmf @@ -0,0 +1,6 @@ +summary: Basic sanity test for python-requests +test: ./runtest.sh +framework: beakerlib +require: + - python3-requests +duration: 5m diff --git a/tests/smoke/runtest.sh b/tests/smoke/runtest.sh new file mode 100755 index 0000000..9de4050 --- /dev/null +++ b/tests/smoke/runtest.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/python-requests/Sanity/smoke +# Description: Basic sanity test for python-requests module. +# Author: Adam Kolar +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# 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, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGES=${PACKAGES:-"python3-requests"} + +PYTHON=${PYTHON:-"python3"} +TEST="test.py" +PORT=8901 + +cleanup(){ + if [[ -n $SERVER_PID ]]; then + kill -9 $SERVER_PID + fi +} + +trap cleanup EXIT + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm --all + rlWaitForSocket $PORT --close -t 5 || rlDie "Port $PORT not available" + # start server + $PYTHON -m http.server $PORT & + export SERVER_PID="$!" + rlWaitForSocket $PORT -t 5 || rlDie "Couldn't start the server" + rlPhaseEnd + + rlPhaseStartTest + rlRun "$PYTHON $TEST $PORT" 0 "Running sanity test for python requests" + rlPhaseEnd + +rlJournalPrintText +rlJournalEnd diff --git a/tests/smoke/test.py b/tests/smoke/test.py new file mode 100644 index 0000000..1f7cba5 --- /dev/null +++ b/tests/smoke/test.py @@ -0,0 +1,12 @@ +import requests +import sys +from requests import * + +class ExceptionRequests(Exception): + pass + +if __name__=="__main__": + port = sys.argv[1] + r=requests.get('http://localhost:'+port) + if r.status_code!=200 or not r.text: + raise ExceptionRequests("Sanity error") diff --git a/tests/upstream/main.fmf b/tests/upstream/main.fmf new file mode 100644 index 0000000..a150453 --- /dev/null +++ b/tests/upstream/main.fmf @@ -0,0 +1,13 @@ +summary: Runs upstream test suite +require: + - python3-requests + - python3-pip + - python3-pytest + - python3-cryptography + - platform-python-devel + - rpm-build + - gcc + - gcc-c++ +test: ./runtest.sh +framework: beakerlib +duration: 30m diff --git a/tests/upstream/runtest.sh b/tests/upstream/runtest.sh new file mode 100755 index 0000000..ec51e05 --- /dev/null +++ b/tests/upstream/runtest.sh @@ -0,0 +1,85 @@ +#!/bin/bash +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/python-requests/Sanity/upstream +# Description: Runs upstream test suite +# Author: Lukas Zachar +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2019 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# 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, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGES="${PACKAGES:-python3-requests}" +PYTHON="${PYTHON:-python3}" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm --all + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + + # So we can inject version of srpm + if [[ -z "$FORCE_SRPM" ]]; then + rlRun "rlFetchSrcForInstalled $(rpm --qf '%{name}' -qf $($PYTHON -c 'import requests;print(requests.__file__)'))" + else + rlRun "rlRpmDownload $FORCE_SRPM" + fi + rlRun "rpm -i --define '_topdir $TmpDir' --nodeps *rpm" + rlRun "rpmbuild -bp --define '_topdir $TmpDir' --nodeps $TmpDir/SPECS/*" + + # Remove module from extracted sources so installed one is used + rlRun "rm -rf $TmpDir/BUILD/*requests*/requests*" + + rlRun "$PYTHON -m venv --system-site-packages $TmpDir/VENV" + rlRun "source $TmpDir/VENV/bin/activate" + + # pip-install libraries not in the repos + # pytest is installed in fmf requirement + # MarkupSafe>=2.0 needed for pytest-httpbin, system one is much older + rlRun "$PYTHON -m pip install pytest-mock==3.2.0 pytest-httpbin==0.0.7 MarkupSafe==2.0" + + # Move to test dir, print what is there + rlRun "cd $(dirname $TmpDir/BUILD/*requests*/tests)" + rlRun "touch tests/requirements-dev.txt" + rlRun "find . -type f" + rlRun "dnf repolist" + rlRun "$PYTHON -m pip list" + rlPhaseEnd + + rlPhaseStartTest + # These fail: + # test_should_bypass_proxies_no_proxy[http://google.com:5000/v1.0/-False] + # test_should_bypass_proxies_no_proxy[http://172.16.1.12:5000/-False] + # test_should_bypass_proxies_no_proxy[http://172.16.1.12/-False] + rlRun 'pytest-3 -v -p no:warnings --junit-xml $TmpDir/result.xml -k "not test_should_bypass_proxies_no_proxy"' + + rlAssertGrep '