Add gating

Remove existing tests and keep just bundled testsuite.
This commit is contained in:
Lukáš Zachar 2025-10-31 16:59:00 +01:00 committed by Lumir Balhar
parent 0ed5e56504
commit a8203594b3
10 changed files with 22 additions and 273 deletions

6
gating.yaml Normal file
View File

@ -0,0 +1,6 @@
--- !Policy
product_versions:
- rhel-*
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}

View File

@ -1,5 +1,19 @@
execute:
how: tmt
discover:
how: fmf
discover:
how: shell
dist-git-source: true
tests:
- name: unit
test: |
pip3.14 install trustme httpbin~=0.10.0 pytest-httpbin==2.1.0 "PySocks>=1.5.6, !=1.5.7"
cd $(dirname $TMT_SOURCE_DIR/*/tests)
pytest-3.14 -v tests/
require:
- python3.14-requests
- python3.14-pytest
- python3.14-pip

View File

@ -1,7 +0,0 @@
require:
- nmap-ncat
- python3
- python3-requests
test: "${PYTHON:-python3} repro.py"
tty: "true"

View File

@ -1,74 +0,0 @@
import subprocess
import requests
import os
import time
import atexit
subprocesses = []
python = os.environ.get("PYTHON","python3")
server_url = os.environ.get("SERVER_URL", None)
testing_no_proxy = os.environ.get("TESTING_NO_PROXY", None)
# Clean up
@atexit.register
def cleanup():
print("Cleaning up subprocesses")
for process in subprocesses:
process.terminate()
time.sleep(1)
for process in subprocesses:
process.wait()
# Part one, assert that everything works
if server_url is None:
print("starting server")
p = subprocess.Popen([python, "server.py"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
subprocesses.append(p)
time.sleep(1)
server_url = "http://[::1]:8888"
no_proxy = "::1/128"
else:
print(f"using provided {server_url} as server")
print(f"using provided {testing_no_proxy} as NO_PROXY value")
assert testing_no_proxy, "TESTING_NO_PROXY envar missing"
# Send request and check the response
print("sending first request")
assert requests.get(server_url, timeout=2).text.startswith("Hello")
# Part two, dummy proxy causes timeout, that's fine
# Start proxy
print("starting proxy")
p = subprocess.Popen(["nc", "-k", "-l", "10000"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
subprocesses.append(p)
time.sleep(1)
# Set proxy to environment
os.environ["HTTP_PROXY"] = "http://127.0.0.1:10000"
# Send request, expect timeout because proxy is dummy and do not respond
print("Sending request via proxy")
try:
requests.get(server_url, timeout=2)
except requests.exceptions.ReadTimeout:
print("timeout is fine, expected")
pass
# Part three, NO_PROXY bypass the proxy and the request should work as before
os.environ["NO_PROXY"] = testing_no_proxy or no_proxy
print("sending last request")
try:
assert requests.get(server_url, timeout=2).text.startswith("Hello")
except requests.exceptions.ReadTimeout:
print("PROBLEM - the last request timed out, NO_PROXY setting does not work!")
raise SystemExit(1)
else:
print("OK - NO_PROXY setting works fine - the last request bypassed proxy")

View File

@ -1,25 +0,0 @@
from http.server import SimpleHTTPRequestHandler, HTTPServer
import socket
import sys
class IPv6OnlyHandler(SimpleHTTPRequestHandler):
def do_GET(self):
client_address = self.client_address[0]
# Check if the client address is an IPv6 address
if ":" in client_address:
self.send_response(200)
self.send_header('Content-type', 'text/plain')
self.end_headers()
self.wfile.write(b'Hello')
else:
# Raise a RuntimeError if the client address is an IPv4 address
raise SystemExit(f"IPv4 address ({client_address}) detected. Only IPv6 addresses are allowed.")
class HTTPServerV6(HTTPServer):
address_family = socket.AF_INET6
if __name__ == '__main__':
# Use IPv6 address and port 8080
server_address = ('::', 8888)
httpd = HTTPServerV6(server_address, IPv6OnlyHandler)
print('Server running on port 8888...')
httpd.serve_forever()

View File

@ -1,6 +0,0 @@
summary: Basic sanity test for python-requests
test: ./runtest.sh
framework: beakerlib
require:
- python3-requests
duration: 5m

View File

@ -1,54 +0,0 @@
#!/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 <akolar@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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:-"python"}
TEST="test.py"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm --all
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "cp $TEST $TmpDir"
rlRun "pushd $TmpDir"
rlPhaseEnd
rlPhaseStartTest
rlRun "$PYTHON $TEST" 0 "Running sanity test for python requests"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View File

@ -1,11 +0,0 @@
import requests
from requests import *
class ExceptionRequests(Exception):
pass
if __name__=="__main__":
r=requests.get('https://redhat.com')
if r.status_code!=200 or \
not r.text or r.encoding.lower() != 'utf-8':
raise ExceptionRequests("Sanity error")

View File

@ -1,14 +0,0 @@
summary: Runs upstream test suite
require:
- python3-requests
- python3-pip
- python3-pytest
- python3-cryptography
- python3-devel
- python3-httpbin
- rpm-build
- gcc
- gcc-c++
test: ./runtest.sh
framework: beakerlib
duration: 30m

View File

@ -1,80 +0,0 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/python-requests/Sanity/upstream
# Description: Runs upstream test suite
# Author: Lukas Zachar <lzachar@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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:-python}"
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*/src"
# pip-install libraries not in the repos
# pytest is installed in fmf requirement
rlRun "$PYTHON -m pip install pytest-mock==3.14.0 trustme==1.2.0 werkzeug==3.1.3 \
pytest-httpbin==2.1.0"
# Move to test dir, print what is there
rlRun "cd $(dirname $TmpDir/BUILD/*requests*/requests*/tests)"
rlRun "touch tests/requirements-dev.txt"
rlRun "find . -type f"
rlRun "yum repolist"
rlRun "$PYTHON -m pip list"
rlPhaseEnd
rlPhaseStartTest "$EXTRA_PARAMS"
# test_unicode_header_name hangs with urllib3 < 2
rlRun 'pytest -v -p no:warnings --junit-xml $TmpDir/result.xml -k "not test_use_proxy_from_environment and not test_unicode_header_name"'
rlAssertGrep '<testcase' $TmpDir/result.xml
rlPhaseEnd
rlPhaseStartCleanup
# upload log if test failed
rlGetTestState || rlRun "rlFileSubmit $TmpDir/result.xml"
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd