Import CI smoke test from RHEL

This is taken and edited from RHEL distgit tests/python-requests,
directory Sanity/smoke.
The commit hash this was copied from: 050c2979f27cc70506ddf669f9e0803a7b67c2d5

Only the necessary files were kept.

Co-authored-by: Lukas Zachar <lzachar@redhat.com>
This commit is contained in:
Adam Kolar 2024-08-06 13:49:33 +02:00 committed by Karolina Surma
parent cf7d3f8fc7
commit 54447e6554
3 changed files with 71 additions and 0 deletions

6
tests/smoke/main.fmf Normal file
View File

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

54
tests/smoke/runtest.sh Executable file
View File

@ -0,0 +1,54 @@
#!/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

11
tests/smoke/test.py Normal file
View File

@ -0,0 +1,11 @@
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")