From 4cab181bcedbb7ec63e473dd3aad9c09484b06f8 Mon Sep 17 00:00:00 2001 From: Iveta Cesalova Date: Wed, 24 Mar 2021 22:47:29 +0100 Subject: [PATCH] add new test --- core/nginx-sanity-test/TC#0326941.fmf | 12 ++++ core/nginx-sanity-test/main.fmf | 20 ++++++ core/nginx-sanity-test/nginx.conf | 11 ++++ core/nginx-sanity-test/runtest.sh | 90 +++++++++++++++++++++++++++ 4 files changed, 133 insertions(+) create mode 100644 core/nginx-sanity-test/TC#0326941.fmf create mode 100644 core/nginx-sanity-test/main.fmf create mode 100644 core/nginx-sanity-test/nginx.conf create mode 100755 core/nginx-sanity-test/runtest.sh diff --git a/core/nginx-sanity-test/TC#0326941.fmf b/core/nginx-sanity-test/TC#0326941.fmf new file mode 100644 index 0000000..2d30fdd --- /dev/null +++ b/core/nginx-sanity-test/TC#0326941.fmf @@ -0,0 +1,12 @@ +component: +- nginx +tag: +- TIPpass +- TIPpass_Apps +- Tier1 +- ci-tier-1 +relevancy: | + product = rhel && distro < rhel-8 : False + distro = rhel-alt : False +extra-nitrate: TC#0326941 +extra-summary: /CoreOS/nginx/Sanity/nginx-sanity-test diff --git a/core/nginx-sanity-test/main.fmf b/core/nginx-sanity-test/main.fmf new file mode 100644 index 0000000..7143fba --- /dev/null +++ b/core/nginx-sanity-test/main.fmf @@ -0,0 +1,20 @@ +summary: What the test does +description: '' +contact: None +component: +- nginx +test: ./runtest.sh +framework: beakerlib +require: +- library(nginx/nginx) +- library(selinux-policy/common) +recommend: +- nginx +- curl +- httpd-tools +- httpd +duration: 5m +enabled: true +tier: '1' +extra-summary: /CoreOS/nginx/Sanity/nginx-sanity-test +extra-task: /CoreOS/nginx/Sanity/nginx-sanity-test diff --git a/core/nginx-sanity-test/nginx.conf b/core/nginx-sanity-test/nginx.conf new file mode 100644 index 0000000..ec5fb57 --- /dev/null +++ b/core/nginx-sanity-test/nginx.conf @@ -0,0 +1,11 @@ +server { + listen 81; + server_name localhost; + root ROOTDIR/rhts-nginx-root; + + location /rp/ { + proxy_pass http://127.0.0.1:81/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + } +} diff --git a/core/nginx-sanity-test/runtest.sh b/core/nginx-sanity-test/runtest.sh new file mode 100755 index 0000000..b828c9e --- /dev/null +++ b/core/nginx-sanity-test/runtest.sh @@ -0,0 +1,90 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/nginx/Sanity/nginx-sanity-test +# Description: Sanity test for nginx +# Author: Joe Orton +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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 + + +URL=http://127.0.0.1:81/ +RPURL=http://127.0.0.1:81/rp/ +PHPURL=http://127.0.0.1:81/info.php + +PACKAGES=${PACKAGES:-"nginx"} + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm --all + rlRun "rlImport nginx/nginx" + rlRun "rlImport selinux-policy/common" + MYCONF=${nginxCONFDIR}/conf.d/rhts-nginx-sanity.conf + DOCROOT=$nginxROOTDIR/rhts-nginx-root + rlAssertBinaryOrigin nginx + rlAssertExists ${nginxCONFDIR} + rlAssertExists ${nginxLOGDIR} + + rlSEBooleanOn httpd_can_network_connect + + rlRun "mkdir ${DOCROOT}" + rlRun "echo this is the index > ${DOCROOT}/index.html" + rlRun "echo ' ${DOCROOT}/info.php" + + rlRun "cp nginx.conf ${MYCONF}" + rlRun "sed -i 's|ROOTDIR|$nginxROOTDIR|' ${MYCONF}" + + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + rlRun "rlServiceStart $nginxHTTPD" + rlRun "sleep 2" 0 "Wainting on nginx to start" + rlPhaseEnd + + rlPhaseStartTest + rlRun "curl $URL > output.html" + rlAssertNotDiffer output.html $DOCROOT/index.html + rlRun "curl $URL/rp/ > output2.html" + rlAssertNotDiffer output2.html $DOCROOT/index.html + + rlAssertExists "$nginxLOGDIR/access.log" + rlAssertExists "$nginxLOGDIR/error.log" + + rlRun "ab -c 10 -n 10000 $URL" + rlRun "ab -c 10 -n 10000 $RPURL" + + rlRun "rlServiceStop $nginxHTTPD" + rlRun "sleep 2" + + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlSEBooleanRestore httpd_can_network_connect + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlRun "rm -rf ${DOCROOT}" + rlRun "rm -f ${MYCONF}" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd