diff --git a/Authors b/Authors new file mode 100644 index 0000000..46ee575 --- /dev/null +++ b/Authors @@ -0,0 +1,3 @@ +Please add your name to this list with your first commit request + +Karanbir Singh diff --git a/Readme b/Readme new file mode 100644 index 0000000..ed9ed1e --- /dev/null +++ b/Readme @@ -0,0 +1,42 @@ +This Git repo contains all the functional tests run for various packages and roles in the CentOS build + release process + +filesystem layout: + +tests/ : contains all test scripts + +tests/0_lib/ : contains all the common functions and shared code for + the tests all files in that directory are 'sourced' + before any of the tests are run, which also means it + can only contain bash code ( no subdir allowed ) + +tests/_common/ : Contain's testst that are run before any other test, + and immediately after the 0_lib/ code is sourced. + These should be tests that check system sanity and + environment. These tests should also not leave behind + any state or content residue that would impact package + and role specific tests that are run after + +tests/p_/ : Each of the p_ directories would contain tests + for that specific package. The needs to be - + rpm --qf "%{name}\n" for the srpm. + + All package tests are run on a machine which has a minimal + install. Its not possible, at this time, to have a kickstart + attached with the package tests. + +tests/r_ : Each of the r_ directories should contain the tests + specific to a role. eg: 'lamp'. The test harness looks at + a file called 'pacakge_deps' inside each of the role directories + and runs the role tests if any package listed in that file + has been changed / built etc. + + Role tests can be run with specific kickstarts. At the moment + each role can have 1 kickstart file. It must be called + ks_.cfg and it must be in the tests/r_/ directory + +notes... +- each of the directories are parsed in alphabetical order, so its possible + to set some sort of a run order by using _ + +- if tests are written in any language other than bash, its upto the test + to install the required environment ( including python, ruby, perl.. ) diff --git a/WritingTests b/WritingTests new file mode 100644 index 0000000..8aa69d2 --- /dev/null +++ b/WritingTests @@ -0,0 +1,7 @@ +Any and every script can be a test. The only 2 things that are important +are that + (a) the script needs to exit with a non zero exit level in + order to siginal a 'Fail' + + (b) the script needs to call yum install to install any + packages or libraries that it would need to run diff --git a/tests/0_common/00_qa_repo_config.sh b/tests/0_common/00_qa_repo_config.sh new file mode 100644 index 0000000..a73abfb --- /dev/null +++ b/tests/0_common/00_qa_repo_config.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +# Disable the normal repositories and points to the QA repo +mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.disabled +touch /etc/yum.repos.d/CentOS-Base.repo + +cat >> /etc/yum.repos.d/CentOS-QA.repo << EOF + +[QA-base] +name=CentOS-\$releasever - OS +baseurl=http://repo.centos.qa/srv/CentOS/\$releasever/os/\$basearch/ +gpgcheck=1 +enabled=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 + +[QA-updates] +name=CentOS-\$releasever - Updates +baseurl=http://repo.centos.qa/srv/CentOS/\$releasever/updates/\$basearch/ +gpgcheck=1 +enabled=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 + +[QA-extras] +name=CentOS-\$releasever - Extras +baseurl=http://repo.centos.qa/srv/CentOS/\$releasever/extras/\$basearch/ +gpgcheck=1 +enabled=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 + +[qa-centosplus] +name=CentOS-$releasever - CentOSPlus +baseurl=http://repo.centos.qa/srv/CentOS/\$releasever/centosplus/\$basearch/ +gpgcheck=1 +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 + +EOF + +yum clean all +echo "Modifying yum repositories for QA purposes ..." +yum repolist + +if [ $? -eq 0 ]; then + echo ' PASS' +else + echo ' Fail' + exit 1 +fi + diff --git a/tests/0_common/05_stop_yumupdatesd.sh b/tests/0_common/05_stop_yumupdatesd.sh new file mode 100644 index 0000000..a6c673f --- /dev/null +++ b/tests/0_common/05_stop_yumupdatesd.sh @@ -0,0 +1,3 @@ +#!/bin/sh +/sbin/service yum-updatesd stop +sleep 2 diff --git a/tests/0_common/10_remove_32bitpkgs.sh b/tests/0_common/10_remove_32bitpkgs.sh new file mode 100644 index 0000000..3d207f3 --- /dev/null +++ b/tests/0_common/10_remove_32bitpkgs.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +echo 'Test that all 32 rpms can be removed' + +# only run this test on x86_64 machines! +is64=$(uname -m|grep x86_64) +if [ "$?" -ne '0' ]; then + echo ' Skip' + exit 1 +fi + +yum -d0 -y erase *.i?86 +#yum -d0 -y erase *.i?86 > /dev/null 2>&1 +if [ $? -eq 0 ]; then + echo ' PASS' +else + echo ' Fail' + exit 1 +fi + +# note, this does not imply the machine is usable after the remove! need +# to test that independantly diff --git a/tests/0_common/20_upgrade_all.sh b/tests/0_common/20_upgrade_all.sh new file mode 100755 index 0000000..8021164 --- /dev/null +++ b/tests/0_common/20_upgrade_all.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +echo 'Test that all updates can be applied to this machine cleanly' + + +yum -d0 -y upgrade +# yum -d0 -y upgrade > /dev/null 2>&1 +if [ $? -eq 0 ]; then + echo ' PASS' +else + echo ' Fail' + exit 1 +fi diff --git a/tests/0_common/30_dns_works.sh b/tests/0_common/30_dns_works.sh new file mode 100644 index 0000000..ff4f80f --- /dev/null +++ b/tests/0_common/30_dns_works.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +echo 'Test to see if dns works' + +# test +# its important we dont hit a dns record with a wildcard like centos.org +ping -c 1 www.google.com > /dev/null 2>&1 +if [ $? -eq 0 ]; then + echo ' PASS' +else + echo ' Fail' + exit 1 +fi + + +# implied results: +# - network works +# - default route is really routeable +# - atleast one network link on the machine is working +# - kernel' ip stack is functional + + diff --git a/tests/0_common/readme b/tests/0_common/readme new file mode 100644 index 0000000..def2b6a --- /dev/null +++ b/tests/0_common/readme @@ -0,0 +1,5 @@ +These are tests that are run everytime a new machine instance comes up; +these tests are run before any package specific or role specific test is run; +these tests should : +- not leave behind any state or content residue that might impact the package/role tests that come after + diff --git a/tests/0_lib/readme b/tests/0_lib/readme new file mode 100644 index 0000000..94657a8 --- /dev/null +++ b/tests/0_lib/readme @@ -0,0 +1,5 @@ +Put everything that is shared across all tests here. +Every file in this directory will get 'sourced' before tests are run +( which also means we can only ever really use Bash for stuff in here ) + +this readme file is ignored diff --git a/tests/r_lamp/40_basic_lamp.sh b/tests/r_lamp/40_basic_lamp.sh new file mode 100644 index 0000000..b8f8d68 --- /dev/null +++ b/tests/r_lamp/40_basic_lamp.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +# purpose : install a minimal lamp stack, and test it + +# Installing required bits + +yum install -y httpd mysql mysql-server php php-mysql wget > /dev/null 2>&1 +service mysqld start +service httpd start + +# Initializing a small MySQL db +cat >>/tmp/mysql-QA.sql <>/var/www/html/mysql.php < +EOF + + + + +#################################################### +# testing +#################################################### + +wget http://localhost/mysql.php + +echo "Basic LAMP test ..." +content=`echo "select * from qatests.tests where name='mysqltest'"|mysql -B --skip-column-names` +if [ "$content" = "mysqltest" ] ; then + echo PASS; + exit 0; +else + echo Fail; + exit 1; +fi diff --git a/tests/r_lamp/package_deps b/tests/r_lamp/package_deps new file mode 100644 index 0000000..c9c2aed --- /dev/null +++ b/tests/r_lamp/package_deps @@ -0,0 +1,5 @@ +# list of package names that this role def depends on +# the tests here will only be triggered if one of these packages is built +php +mysql +httpd