From 0a3c81c89cfbe74a676200172a3cc0819613def9 Mon Sep 17 00:00:00 2001 From: Athmane Madjoudj Date: Jun 28 2011 11:59:47 +0000 Subject: - Fixed some tests, added a helper function t_GetPkgRel to make cross-release test ie CentOS5 and CentOS6 --- diff --git a/tests/0_lib/functions.sh b/tests/0_lib/functions.sh index 266503d..093f176 100755 --- a/tests/0_lib/functions.sh +++ b/tests/0_lib/functions.sh @@ -81,6 +81,12 @@ function t_ServiceControl sleep 3 } +# Description: Get a package (rpm) release number +function t_GetPkgRel +{ + rpm -q --queryformat '%{RELEASE}' $1 +} + export -f t_Log export -f t_CheckExitStatus export -f t_InstallPackage @@ -88,3 +94,4 @@ export -f t_RemovePackage export -f t_Process export -f t_CheckDeps export -f t_ServiceControl +export -f t_GetPkgRel diff --git a/tests/p_dovecot/1-config_dovecot.sh b/tests/p_dovecot/1-config_dovecot.sh new file mode 100755 index 0000000..95912b3 --- /dev/null +++ b/tests/p_dovecot/1-config_dovecot.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# Author: Athmane Madjoudj + +if (t_GetPkgRel dovecot | grep -q el6) +then + t_Log "Running $0 - Configuration of Dovecot" + + cat > /etc/dovecot/conf.d/11-mail.conf </dev/null +{ userdel -rf imaptest; useradd imaptest && echo imaptest | passwd --stdin imaptest; } &>/dev/null t_Log "Dovecot IMAP login test" echo -e "01 LOGIN imaptest imaptest\n" | nc localhost 143 | grep "01 OK Logged in." diff --git a/tests/p_squirrelmail/0-install_squirrelmail.sh b/tests/p_squirrelmail/0-install_squirrelmail.sh index 078159e..941e3dd 100755 --- a/tests/p_squirrelmail/0-install_squirrelmail.sh +++ b/tests/p_squirrelmail/0-install_squirrelmail.sh @@ -2,5 +2,13 @@ # Author: Athmane Madjoudj # NOTE: squirrelmail rpm has require: httpd php php-mbstring -t_InstallPackage squirrelmail -t_ServiceControl httpd reload +# Squirellmail has been removed from el6 + +if (t_GetPkgRel basesystem | grep -q el6) +then + t_Log It seems to be a CentOS 6.x system, this test will be disabled + exit 0 +else + t_InstallPackage squirrelmail + t_ServiceControl httpd restart +fi diff --git a/tests/p_squirrelmail/squirrelmail_test.sh b/tests/p_squirrelmail/squirrelmail_test.sh index f150b57..7a386ae 100755 --- a/tests/p_squirrelmail/squirrelmail_test.sh +++ b/tests/p_squirrelmail/squirrelmail_test.sh @@ -1,6 +1,11 @@ #!/bin/sh # Author: Athmane Madjoudj +if (t_GetPkgRel basesystem | grep -q el6) +then + t_Log It seems to be a CentOS 6.x system, this test will be disabled +else + t_Log "Running $0 - test SquirrelMail URL." + curl -s http://localhost/webmail/src/login.php | grep 'SquirrelMail' > /dev/null 2>&1 +fi -t_Log "Running $0 - test SquirrelMail URL." -curl -s http://localhost/webmail/src/login.php | grep 'SquirrelMail' > /dev/null 2>&1 t_CheckExitStatus $? diff --git a/tests/p_tomcat/0-install_tomcat.sh b/tests/p_tomcat/0-install_tomcat.sh new file mode 100755 index 0000000..69e57c3 --- /dev/null +++ b/tests/p_tomcat/0-install_tomcat.sh @@ -0,0 +1,13 @@ +#!/bin/bash +# Author: Athmane Madjoudj + +if (t_GetPkgRel basesystem | grep -q el6) +then + t_Log "$0 - installing Tomcat 6" + t_InstallPackage tomcat6 tomcat6-admin-webapps + service tomcat6 start +else + t_Log "$0 - installing Tomcat 5" + t_InstallPackage tomcat5 tomcat5-admin-webapps tomcat5-webapps + service tomcat5 start +fi diff --git a/tests/p_tomcat/1-config_tomcat.sh b/tests/p_tomcat/1-config_tomcat.sh new file mode 100755 index 0000000..c13c7c1 --- /dev/null +++ b/tests/p_tomcat/1-config_tomcat.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# Author: Athmane Madjoudj + +t_Log "$0 - Configuring Tomcat" + +if (t_GetPkgRel basesystem | grep -q el6) +then + TOMCAT_SRV_NAME=tomcat6 + TOMCAT_CONF_DIR=/etc/tomcat6/ +else + TOMCAT_SRV_NAME=tomcat5 + TOMCAT_CONF_DIR=/etc/tomcat5/ +fi + +sed -i 's/<\/tomcat-users>/\n<\/tomcat-users>/' $TOMCAT_CONF_DIR/tomcat-users.xml + + +service $TOMCAT_SRV_NAME restart diff --git a/tests/p_tomcat/tomcat_manager_test.sh b/tests/p_tomcat/tomcat_manager_test.sh new file mode 100755 index 0000000..ca31401 --- /dev/null +++ b/tests/p_tomcat/tomcat_manager_test.sh @@ -0,0 +1,8 @@ +#!/bin/sh +# Author: Athmane Madjoudj + +t_Log "Running $0 - Tomcat Web Application Manager test." + +curl -u admin:admin -s http://localhost:8080/manager/html | grep "Tomcat Web Application Manager" >/dev/null 2>&1 + +t_CheckExitStatus $? diff --git a/tests/p_tomcat/tomcat_test.sh b/tests/p_tomcat/tomcat_test.sh new file mode 100755 index 0000000..6329255 --- /dev/null +++ b/tests/p_tomcat/tomcat_test.sh @@ -0,0 +1,8 @@ +#!/bin/sh +# Author: Athmane Madjoudj + +t_Log "Running $0 - Tomcat basic test." + +curl -s http://localhost:8080/ | grep "you've setup Tomcat successfully. Congratulations!" >/dev/null 2>&1 + +t_CheckExitStatus $? diff --git a/tests/p_tomcat5/0-install_tomcat5.sh b/tests/p_tomcat5/0-install_tomcat5.sh deleted file mode 100755 index a8f7301..0000000 --- a/tests/p_tomcat5/0-install_tomcat5.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -# Author: Athmane Madjoudj - -t_Log "$0 - installing Tomcat 5" -t_InstallPackage tomcat5 tomcat5-admin-webapps tomcat5-webapps -service tomcat5 start diff --git a/tests/p_tomcat5/1-config_tomcat5.sh b/tests/p_tomcat5/1-config_tomcat5.sh deleted file mode 100755 index be2ca5c..0000000 --- a/tests/p_tomcat5/1-config_tomcat5.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -# Author: Athmane Madjoudj - -t_Log "$0 - Configuring Tomcat 5" - -sed -i 's/<\/tomcat-users>/\n<\/tomcat-users>/' /etc/tomcat5/tomcat-users.xml - - -service tomcat5 restart diff --git a/tests/p_tomcat5/README b/tests/p_tomcat5/README deleted file mode 100644 index ccee81b..0000000 --- a/tests/p_tomcat5/README +++ /dev/null @@ -1 +0,0 @@ -This test is for CentOS 5.x only, CentOS 6.x will include Tomcat 6 (tomcat6 package) instead. diff --git a/tests/p_tomcat5/tomcat5_manager_test.sh b/tests/p_tomcat5/tomcat5_manager_test.sh deleted file mode 100755 index da6430e..0000000 --- a/tests/p_tomcat5/tomcat5_manager_test.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# Author: Athmane Madjoudj - -t_Log "Running $0 - Tomcat 5 Web Application Manager test." - -curl -u admin:admin -s http://localhost:8080/manager/html | grep "Tomcat Web Application Manager" >/dev/null 2>&1 - -t_CheckExitStatus $? diff --git a/tests/p_tomcat5/tomcat5_test.sh b/tests/p_tomcat5/tomcat5_test.sh deleted file mode 100755 index 24df696..0000000 --- a/tests/p_tomcat5/tomcat5_test.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# Author: Athmane Madjoudj - -t_Log "Running $0 - Tomcat 5 basic test." - -curl -s http://localhost:8080/ | grep "you've setup Tomcat successfully. Congratulations!" >/dev/null 2>&1 - -t_CheckExitStatus $? diff --git a/tests/p_webalizer/0-install_webalizer.sh b/tests/p_webalizer/0-install_webalizer.sh index 5709445..eaa03ab 100755 --- a/tests/p_webalizer/0-install_webalizer.sh +++ b/tests/p_webalizer/0-install_webalizer.sh @@ -2,4 +2,5 @@ # Author: Athmane Madjoudj t_InstallPackage webalizer -t_ServiceControl httpd reload +t_InstallPackage httpd +t_ServiceControl httpd restart