From 6863dc70a471fb68c5a8aba713c5957573c83e97 Mon Sep 17 00:00:00 2001 From: Fabian Arrotin Date: Dec 01 2011 13:44:40 +0000 Subject: Merge branch 'master' of gitorious.org:testautomation/t_functional --- diff --git a/doc/WritingTests b/doc/WritingTests index 479df53..a07d376 100644 --- a/doc/WritingTests +++ b/doc/WritingTests @@ -136,6 +136,20 @@ Start your tests with a comment block which includes your name and e-mail addres t_Log "Running $0 - Postfix SMTP socket connect + 220 banner response test." +Make the comment relevant to what you are really testing. Some good examples are : +- php: testing mysql connection +- mysql: create database, load sample schema, drop database +- sshd: local connections over ssh work +- sshd: testing key based access is functional + +Examples of not so good comments: +- php test +- does this work +- another test + +If you are writing a test to satisfy or check for a regression or issue reported at bugs.centos.org, make sure you include reference to that issue number. One way to achieve that is in the test comment above. eg: to test if the issue reported in bugs.centos.org/view.php?id=4955 is being satisfied : + + t_Log "Running $0 - NTP should use the CentOS pool (#4955)" === A Practical Example === diff --git a/tests/p_bind/bind_test.sh b/tests/p_bind/bind_test.sh index 2c82266..dac06e7 100755 --- a/tests/p_bind/bind_test.sh +++ b/tests/p_bind/bind_test.sh @@ -1,7 +1,7 @@ #!/bin/sh # Author: Athmane Madjoudj -t_Log "Running $0 - bind test." +t_Log "Running $0 - bind: local resolver can qualify 127.0.0.1" dig +timeout=1 +short @127.0.0.1 localhost | grep -q '127.0.0.1' diff --git a/tests/p_centos-release/centos-release_centos_gpg.sh b/tests/p_centos-release/centos-release_centos_gpg.sh index 99ad864..4e7da4b 100755 --- a/tests/p_centos-release/centos-release_centos_gpg.sh +++ b/tests/p_centos-release/centos-release_centos_gpg.sh @@ -1,7 +1,7 @@ #!/bin/sh # Author: Athmane Madjoudj -t_Log "Running $0 - CentOS RPM GPG Keys test." +t_Log "Running $0 - CentOS RPM GPG Keys exist." file /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS* >/dev/null 2>&1 && \ file /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Security* >/dev/null 2>&1 diff --git a/tests/p_centos-release/centos-release_issue.sh b/tests/p_centos-release/centos-release_issue.sh index 2746a67..90dea46 100755 --- a/tests/p_centos-release/centos-release_issue.sh +++ b/tests/p_centos-release/centos-release_issue.sh @@ -1,7 +1,7 @@ #!/bin/sh # Author: Athmane Madjoudj -t_Log "Running $0 - /etc/issue* has correct info test." +t_Log "Running $0 - /etc/issue* has correct branding" (grep "CentOS" /etc/issue >/dev/null 2>&1) && \ (grep "CentOS" /etc/issue.net >/dev/null 2>&1) diff --git a/tests/p_centos-release/centos-release_system_release.sh b/tests/p_centos-release/centos-release_system_release.sh index ed93397..380779e 100755 --- a/tests/p_centos-release/centos-release_system_release.sh +++ b/tests/p_centos-release/centos-release_system_release.sh @@ -1,7 +1,7 @@ #!/bin/sh # Author: Athmane Madjoudj -t_Log "Running $0 - /etc/centos-release has correct info test." +t_Log "Running $0 - /etc/centos-release has correct branding" if (t_GetPkgRel basesystem | grep -q el6) then grep "CentOS" /etc/centos-release >/dev/null 2>&1 diff --git a/tests/p_cron/cron_crontab_daily_test.sh b/tests/p_cron/cron_crontab_daily_test.sh index 6d1f648..58741c5 100755 --- a/tests/p_cron/cron_crontab_daily_test.sh +++ b/tests/p_cron/cron_crontab_daily_test.sh @@ -1,7 +1,7 @@ #!/bin/sh # Author: Athmane Madjoudj -t_Log "Running $0 - crontab test." +t_Log "Running $0 - crontab will run daily jobs." # Add a test cron cat > /etc/cron.daily/test.sh< -t_Log "Running $0 - crontab test." +t_Log "Running $0 - crontab will run hourly jobs." # Add a test cron cat > /etc/cron.hourly/test.sh< -t_Log "Running $0 - crontab test." +t_Log "Running $0 - crontab will run weekly jobs" # Add a test cron cat > /etc/cron.weekly/test.sh< # Install gcc +t_Log "Running $0 - installing gcc." t_InstallPackage gcc diff --git a/tests/p_gcc/test_gcc.sh b/tests/p_gcc/test_gcc.sh index 730c19a..24a19b4 100755 --- a/tests/p_gcc/test_gcc.sh +++ b/tests/p_gcc/test_gcc.sh @@ -2,7 +2,7 @@ # Author: Christoph Galuschka # Athmane Madjodj -t_Log "Running $0 - simple gcc compilation test" +t_Log "Running $0 - gcc can build a hello world .c" # creating source code FILE='/var/tmp/gcc-test.c' diff --git a/tests/p_httpd/0-install_httpd.sh b/tests/p_httpd/0-install_httpd.sh index e7a75d0..f420702 100755 --- a/tests/p_httpd/0-install_httpd.sh +++ b/tests/p_httpd/0-install_httpd.sh @@ -2,9 +2,11 @@ # Author: Athmane Madjoudj # Install tests deps +t_Log "Running $0 - httpd: installing curl, http, php and mysql" + t_InstallPackage curl # HTTPD / PHP t_InstallPackage httpd mod_ssl php php-mysql chkconfig httpd on -t_ServiceControl httpd start +t_ServiceControl httpd start \ No newline at end of file diff --git a/tests/p_httpd/httpd_basic_auth.sh b/tests/p_httpd/httpd_basic_auth.sh index 873795d..f7c7ae1 100755 --- a/tests/p_httpd/httpd_basic_auth.sh +++ b/tests/p_httpd/httpd_basic_auth.sh @@ -1,7 +1,7 @@ #!/bin/sh # Author: Athmane Madjoudj -t_Log "Running $0 - httpd basic authentication test." +t_Log "Running $0 - httpd: basic authentication" cat > /etc/httpd/conf.d/dir-test-basic-auth.conf < -t_Log "Running $0 - httpd centos branding / Server tokens value test." +t_Log "Running $0 - httpd: centos branding / Server tokens value " curl -sI http://localhost/ | grep "Server:\ Apache.*\ (CentOS)" > /dev/null 2>&1 diff --git a/tests/p_httpd/httpd_centos_brand_welcome.sh b/tests/p_httpd/httpd_centos_brand_welcome.sh index 5fc43c8..6b42804 100755 --- a/tests/p_httpd/httpd_centos_brand_welcome.sh +++ b/tests/p_httpd/httpd_centos_brand_welcome.sh @@ -1,7 +1,7 @@ #!/bin/sh # Author: Athmane Madjoudj -t_Log "Running $0 - httpd centos branding / the default welcome page test." +t_Log "Running $0 - httpd: Welcome page has CentOS Branding." curl -s http://localhost/ | grep 'CentOS' > /dev/null 2>&1 diff --git a/tests/p_httpd/httpd_php.sh b/tests/p_httpd/httpd_php.sh index 13fc58e..3624ce5 100755 --- a/tests/p_httpd/httpd_php.sh +++ b/tests/p_httpd/httpd_php.sh @@ -1,9 +1,9 @@ #!/bin/sh # Author: Athmane Madjoudj -echo "" > /var/www/html/test.php +t_Log "Running $0 - httpd: can parse a phpinfo/PHP page" -t_Log "Running $0 - httpd handle PHP test" +echo "" > /var/www/html/test.php curl -s http://localhost/test.php | grep 'PHP Version' > /dev/null 2>&1 diff --git a/tests/p_httpd/httpd_servehtml.sh b/tests/p_httpd/httpd_servehtml.sh index 6dcc076..a429900 100755 --- a/tests/p_httpd/httpd_servehtml.sh +++ b/tests/p_httpd/httpd_servehtml.sh @@ -1,7 +1,7 @@ #!/bin/sh # Author: Athmane Madjoudj -t_Log "Running $0 - httpd serve html page test." +t_Log "Running $0 - httpd: serve html page" curl -s http://localhost/ | grep 'Test Page' > /dev/null 2>&1 diff --git a/tests/p_httpd/httpd_servehtml_ssl.sh b/tests/p_httpd/httpd_servehtml_ssl.sh index 9ac08fa..97ac530 100755 --- a/tests/p_httpd/httpd_servehtml_ssl.sh +++ b/tests/p_httpd/httpd_servehtml_ssl.sh @@ -1,7 +1,7 @@ #!/bin/sh # Author: Athmane Madjoudj -t_Log "Running $0 - httpd serve html page over SSL test." +t_Log "Running $0 - httpd: serve html page over SSL " curl -ks https://localhost/ | grep 'Test Page' > /dev/null 2>&1 diff --git a/tests/p_httpd/httpd_vhost.sh b/tests/p_httpd/httpd_vhost.sh index 6200880..252c8ac 100755 --- a/tests/p_httpd/httpd_vhost.sh +++ b/tests/p_httpd/httpd_vhost.sh @@ -1,7 +1,7 @@ #!/bin/sh # Author: Athmane Madjoudj -t_Log "Running $0 - httpd virtual host test." +t_Log "Running $0 - httpd: NameVirtualHost is functional" echo "127.0.0.1 test" >> /etc/hosts cat > /etc/httpd/conf.d/vhost-test.conf < -t_Log "Running $0 - initscripts CentOS branding test." +t_Log "Running $0 - initscripts CentOS branding " if (t_GetPkgRel basesystem | grep -q el6) then diff --git a/tests/p_iptraf/0-install_iptraf.sh b/tests/p_iptraf/0-install_iptraf.sh index a0f341f..b4f30f4 100755 --- a/tests/p_iptraf/0-install_iptraf.sh +++ b/tests/p_iptraf/0-install_iptraf.sh @@ -1,6 +1,8 @@ #!/bin/bash # Author: Steve Barnes (steve@echo.id.au) +t_Log "Running $0 - iptraf: install iptraf and which" + # IPTraf traffic monitoring package t_InstallPackage iptraf diff --git a/tests/p_libvirt/0-install_libvirt.sh b/tests/p_libvirt/0-install_libvirt.sh index 14eb684..73acba1 100755 --- a/tests/p_libvirt/0-install_libvirt.sh +++ b/tests/p_libvirt/0-install_libvirt.sh @@ -1,6 +1,6 @@ #!/bin/bash # Author: Athmane Madjoudj -t_Log "$0 - installing libvirt" +t_Log "Running $0 - installing libvirt" t_InstallPackage libvirt service libvirtd restart diff --git a/tests/p_libvirt/libvirt_virsh_test.sh b/tests/p_libvirt/libvirt_virsh_test.sh index 3c09640..dada2c6 100755 --- a/tests/p_libvirt/libvirt_virsh_test.sh +++ b/tests/p_libvirt/libvirt_virsh_test.sh @@ -1,7 +1,7 @@ #!/bin/sh # Author: Athmane Madjoudj -t_Log "Running $0 - Virsh test." +t_Log "Running $0 - libvirt: Virsh can talk to local hypervisor." virsh -c test:///default list > /dev/null diff --git a/tests/p_logrotate/0-install_logrotate.sh b/tests/p_logrotate/0-install_logrotate.sh index 035764c..271a10b 100755 --- a/tests/p_logrotate/0-install_logrotate.sh +++ b/tests/p_logrotate/0-install_logrotate.sh @@ -1,6 +1,6 @@ #!/bin/bash # Author: Athmane Madjoudj -t_Log "$0 - Installing logrotate" +t_Log "Running $0 - Installing logrotate" t_InstallPackage logrotate diff --git a/tests/p_logrotate/logrotate_test.sh b/tests/p_logrotate/logrotate_test.sh index c2004e0..9e0e92c 100755 --- a/tests/p_logrotate/logrotate_test.sh +++ b/tests/p_logrotate/logrotate_test.sh @@ -1,7 +1,7 @@ #!/bin/sh # Author: Athmane Madjoudj -t_Log "Running $0 - logrotate test." +t_Log "Running $0 - logrotate: is happy with all configs" /usr/sbin/logrotate /etc/logrotate.conf diff --git a/tests/p_php/10-php-test.sh b/tests/p_php/10-php-test.sh new file mode 100755 index 0000000..af909e4 --- /dev/null +++ b/tests/p_php/10-php-test.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# Author: Athmane Madjoudj +# Author: Christoph Galuschka + +t_Log "Running $0 - php phpinfo() function test." + +# Comparing hostname with output of phpinfo() +FILE='/var/tmp/php-test.php' + +cat > $FILE < +EOF + +# setting timezone for phpinfo +sed -i 's/\;date\.timezone\ \=/date\.timezone = \"Europe\/Berlin\"/' /etc/php.ini + +php $FILE | grep -q 'Zend Engine' + +t_CheckExitStatus $? + +#reversing changes +/bin/rm $FILE +sed -i 's/\date\.timezone\ \=\ \"Europe\/Berlin\"/\;date\.timezone\ \=/' /etc/php.ini diff --git a/tests/p_php/20-php-mysql-test.sh b/tests/p_php/20-php-mysql-test.sh new file mode 100755 index 0000000..cd2a92b --- /dev/null +++ b/tests/p_php/20-php-mysql-test.sh @@ -0,0 +1,75 @@ +#!/bin/sh +# Author: Athmane Madjoudj +# Author: Christoph Galuschka +# reusing the script from LAMP-Tests + +t_Log "Running $0 - php-cli basic interaction with mysql test." + +# Install php-mysql-module +t_InstallPackage php-mysql + +# we need a working and running mysql server +t_InstallPackage mysql-server +t_ServiceControl mysqld start >/dev/null 2>&1 + +#create a little DB to use +CREATE='/var/tmp/mysql-php-QA.sql' + +cat >$CREATE <$INSERT < +EOF + +php $INSERT +if [ $? -ne 0 ] + then + t_Log FAIL + exit 1 +fi + +# create PHP script to read from DB +READ='/var/tmp/read.php' +cat >$READ < +EOF + +# If we execute the script and get '1' it works (1 entry should be in the DB) +php $READ | grep -q '1' + +t_CheckExitStatus $? + diff --git a/tests/p_php/php-test.sh b/tests/p_php/php-test.sh deleted file mode 100755 index cdcad18..0000000 --- a/tests/p_php/php-test.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -# Author: Athmane Madjoudj -# Author: Christoph Galuschka - -t_Log "Running $0 - php phpinfo() function test." - -# Comparing hostname with output of phpinfo() -#HOST=$(hostname) -FILE='/var/tmp/php-test.php' - -cat > $FILE < -EOF - -# setting timezone for phpinfo -sed -i 's/\;date\.timezone\ \=/date\.timezone = \"Europe\/Berlin\"/' /etc/php.ini - -php $FILE | grep -q 'Zend Engine' - -t_CheckExitStatus $? - -#reversing changes -/bin/rm $FILE -sed -i 's/\date\.timezone\ \=\ \"Europe\/Berlin\"/\;date\.timezone\ \=/' /etc/php.ini