From 4435ab172b2760fb78848759f5d16ee2049e1caf Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Wed, 9 May 2018 20:58:01 -0700 Subject: [PATCH] Add Zuulv3 functional tests Add functional tests to verify that the mailman functionality, both single host and multihost, works correctly and generates the expected virtualhost config. Depends-On: https://review.openstack.org/565270 Change-Id: Ie3f23cf918f3575e0403626d94a8a0f1f68ae831 --- tests/scenarios/multihost/manifest.pp | 12 ++++ tests/scenarios/multihost/tests.sh | 89 ++++++++++++++++++++++++++ tests/scenarios/singlehost/manifest.pp | 6 ++ tests/scenarios/singlehost/tests.sh | 88 +++++++++++++++++++++++++ 4 files changed, 195 insertions(+) create mode 100644 tests/scenarios/multihost/manifest.pp create mode 100755 tests/scenarios/multihost/tests.sh create mode 100644 tests/scenarios/singlehost/manifest.pp create mode 100755 tests/scenarios/singlehost/tests.sh diff --git a/tests/scenarios/multihost/manifest.pp b/tests/scenarios/multihost/manifest.pp new file mode 100644 index 0000000..9214a1c --- /dev/null +++ b/tests/scenarios/multihost/manifest.pp @@ -0,0 +1,12 @@ +file { '/srv/mailman': + ensure => directory, +} +class { 'mailman': + multihost => true, +} +mailman::site { 'openstack': + default_email_host => 'lists.openstack.org', + default_url_host => 'lists.openstack.org', + install_languages => ['de', 'fr', 'it', 'ko', 'ru', 'vi', 'zh_TW'], + require => Class['mailman'], +} diff --git a/tests/scenarios/multihost/tests.sh b/tests/scenarios/multihost/tests.sh new file mode 100755 index 0000000..8ae49a2 --- /dev/null +++ b/tests/scenarios/multihost/tests.sh @@ -0,0 +1,89 @@ +#!/usr/bin/env bash + +set -eux + +test_site_is_alive() { + curl http://localhost/cgi-bin/mailman/listinfo | grep 'Mailing Lists' || return 1 + return 0 +} + +test_vhost_content() { + expected_vhost=$(mktemp) + cat < $expected_vhost + + ServerName lists.openstack.org + + ErrorLog \${APACHE_LOG_DIR}/lists.openstack.org-error.log + + # Possible values include: debug, info, notice, warn, error, crit, + # alert, emerg. + LogLevel warn + + CustomLog \${APACHE_LOG_DIR}/lists.openstack.org-access.log combined + + DocumentRoot /var/www + +RewriteEngine on +RewriteRule ^/$ /cgi-bin/mailman/listinfo [R] + +# We can find mailman here: +ScriptAlias /cgi-bin/mailman/ /usr/lib/cgi-bin/mailman/ +# And the public archives: +Alias /pipermail/ /srv/mailman/openstack/archives/public/ +# Logos: +Alias /images/mailman/ /usr/share/images/mailman/ + +# Use this if you don't want the "cgi-bin" component in your URL: +# In case you want to access mailman through a shorter URL you should enable +# this: +#ScriptAlias /mailman/ /usr/lib/cgi-bin/mailman/ +# In this case you need to set the DEFAULT_URL_PATTERN in +# /etc/mailman/mm_cfg.py to http://%s/mailman/ for the cookie +# authentication code to work. Note that you need to change the base +# URL for all the already-created lists as well. + + + AllowOverride None + Options ExecCGI + AddHandler cgi-script .cgi + SetEnv MAILMAN_SITE_DIR /srv/mailman/openstack + Order allow,deny + Allow from all + = 2.4> + Require all granted + + + + Options FollowSymlinks + AllowOverride None + Order allow,deny + Allow from all + = 2.4> + Require all granted + + + + AllowOverride None + Order allow,deny + Allow from all + = 2.4> + Require all granted + + + + +EOF + diff $expected_vhost /etc/apache2/sites-enabled/50-lists.openstack.org.conf || return 1 + return 0 +} + +declare -a tests +tests=( + test_site_is_alive + test_vhost_content +) +for test in ${tests[@]} ; do + $test || exit 1 +done + +exit 0 diff --git a/tests/scenarios/singlehost/manifest.pp b/tests/scenarios/singlehost/manifest.pp new file mode 100644 index 0000000..b55708b --- /dev/null +++ b/tests/scenarios/singlehost/manifest.pp @@ -0,0 +1,6 @@ +file { '/srv/mailman': + ensure => directory, +} +class { 'mailman': + vhost_name => 'lists.openstack.org', +} diff --git a/tests/scenarios/singlehost/tests.sh b/tests/scenarios/singlehost/tests.sh new file mode 100755 index 0000000..c7cee63 --- /dev/null +++ b/tests/scenarios/singlehost/tests.sh @@ -0,0 +1,88 @@ +#!/usr/bin/env bash + +set -eux + +test_site_is_alive() { + curl http://localhost/cgi-bin/mailman/listinfo | grep 'Mailing Lists' || return 1 + return 0 +} + +test_vhost_content() { + expected_vhost=$(mktemp) + cat < $expected_vhost + + ServerName lists.openstack.org + + ErrorLog \${APACHE_LOG_DIR}/lists.openstack.org-error.log + + # Possible values include: debug, info, notice, warn, error, crit, + # alert, emerg. + LogLevel warn + + CustomLog \${APACHE_LOG_DIR}/lists.openstack.org-access.log combined + + DocumentRoot /var/www + +RewriteEngine on +RewriteRule ^/$ /cgi-bin/mailman/listinfo [R] + +# We can find mailman here: +ScriptAlias /cgi-bin/mailman/ /usr/lib/cgi-bin/mailman/ +# And the public archives: +Alias /pipermail/ /var/lib/mailman/archives/public/ +# Logos: +Alias /images/mailman/ /usr/share/images/mailman/ + +# Use this if you don't want the "cgi-bin" component in your URL: +# In case you want to access mailman through a shorter URL you should enable +# this: +#ScriptAlias /mailman/ /usr/lib/cgi-bin/mailman/ +# In this case you need to set the DEFAULT_URL_PATTERN in +# /etc/mailman/mm_cfg.py to http://%s/mailman/ for the cookie +# authentication code to work. Note that you need to change the base +# URL for all the already-created lists as well. + + + AllowOverride None + Options ExecCGI + AddHandler cgi-script .cgi + Order allow,deny + Allow from all + = 2.4> + Require all granted + + + + Options FollowSymlinks + AllowOverride None + Order allow,deny + Allow from all + = 2.4> + Require all granted + + + + AllowOverride None + Order allow,deny + Allow from all + = 2.4> + Require all granted + + + + +EOF + diff $expected_vhost /etc/apache2/sites-enabled/50-lists.openstack.org.conf || return 1 + return 0 +} + +declare -a tests +tests=( + test_site_is_alive + test_vhost_content +) +for test in ${tests[@]} ; do + $test || exit 1 +done + +exit 0