From d7a223fe98d09e5043cdbcccca913917b93f0467 Mon Sep 17 00:00:00 2001 From: Carl George Date: Apr 24 2020 05:40:17 +0000 Subject: mod_wsgi overhaul In CentOS Stream, python3-mod_wsgi no longer provides mod_wsgi, so ask for the package name directly. This is part of an upcoming 8.2 update. This change also does some related cleanup. * un-nest the main code from the skip conditions * remove service control from the installation script * utilize str.encode() to get the correct string type on either py2 or py3 * use systemctl where appropriate * remove files when done https://git.centos.org/rpms/mod_wsgi/c/4a746b53e9e3fef74b227e016e785449160871b8?branch=c8s https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8-beta/html-single/8.2_release_notes/index#enhancement_dynamic-programming-languages-web-and-database-servers --- diff --git a/tests/p_mod_wsgi/0-install_mod_wsgi.sh b/tests/p_mod_wsgi/0-install_mod_wsgi.sh index 1713b67..c1f5a6b 100755 --- a/tests/p_mod_wsgi/0-install_mod_wsgi.sh +++ b/tests/p_mod_wsgi/0-install_mod_wsgi.sh @@ -1,12 +1,15 @@ #!/bin/bash # Author: Athmane Madjoudj -if [ $centos_ver -ge 6 ] -then - t_InstallPackage mod_wsgi - service httpd restart -else - echo "Skipped on CentOS 5" -fi +t_Log "Running $0 - installing mod_wsgi" +if [[ $centos_ver -lt 6 ]]; then + t_Log "mod_wsgi doesn't exist before CentOS 6 -> SKIP" + exit 0 +fi +if [[ $centos_ver -ge 8 ]]; then + t_InstallPackage python3-mod_wsgi +else + t_InstallPackage mod_wsgi +fi diff --git a/tests/p_mod_wsgi/10-mod_wsgi_test.sh b/tests/p_mod_wsgi/10-mod_wsgi_test.sh new file mode 100755 index 0000000..8dfd53b --- /dev/null +++ b/tests/p_mod_wsgi/10-mod_wsgi_test.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +t_Log "Running $0 - Apache httpd mod_wsgi is functional" + +if [[ $centos_ver -lt 6 ]]; then + t_Log "mod_wsgi doesn't exist before CentOS 6 -> SKIP" + exit 0 +fi + +cat > /etc/httpd/conf.d/tfapp.conf << EOF +WSGIScriptAlias /tfapp /var/www/html/tfapp.wsgi +EOF + +cat > /var/www/html/tfapp.wsgi << EOF +def application(environ, start_response): + status = '200 OK' + output = 't_functional_mod_wsgi_test'.encode() + response_headers = [ + ('Content-type', 'text/plain'), + ('Content-Length', str(len(output))) + ] + start_response(status, response_headers) + return [output] +EOF + +if [[ $centos_ver -ge 7 ]]; then + systemctl restart httpd +else + service httpd restart +fi + +curl -s http://localhost/tfapp | grep -q 't_functional_mod_wsgi_test' +t_CheckExitStatus $? + +if [[ $centos_ver -ge 7 ]]; then + systemctl stop httpd +else + service httpd stop +fi + +rm /etc/httpd/conf.d/tfapp.conf /var/www/html/tfapp.wsgi diff --git a/tests/p_mod_wsgi/mod_wsgi_test.sh b/tests/p_mod_wsgi/mod_wsgi_test.sh deleted file mode 100755 index 7dc7587..0000000 --- a/tests/p_mod_wsgi/mod_wsgi_test.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh - -t_Log "Running $0 - Apache httpd mod_wsgi is functional" -if [ $centos_ver -ge 6 ] -then - while [ `ps fax | grep 'sbin/httpd' | grep -v grep | wc -l` -gt 0 ]; do - #t_ServiceControl httpd stop - killall -s KILL httpd - sleep 1 - done - - cat > /etc/httpd/conf.d/tf_app.conf < /var/www/html/tf_app.wsgi <