Blame tests/r_lamp/40_basic_lamp.sh
|
Karanbir Singh |
43deec |
#!/bin/bash
|
|
Karanbir Singh |
43deec |
|
|
Karanbir Singh |
2dd0be |
t_Log "Running $0 - install a minimal lamp stack, and test it"
|
|
Karanbir Singh |
43deec |
|
|
Karanbir Singh |
2dd0be |
t_InstallPackage httpd mysql mysql-server php php-mysql wget
|
|
Steve Barnes |
464547 |
t_ServiceControl mysqld start
|
|
Steve Barnes |
464547 |
t_ServiceControl httpd start
|
|
Karanbir Singh |
43deec |
|
|
Karanbir Singh |
43deec |
# Initializing a small MySQL db
|
|
Karanbir Singh |
43deec |
cat >>/tmp/mysql-QA.sql <
|
|
Karanbir Singh |
43deec |
create database qatests;
|
|
Karanbir Singh |
43deec |
use qatests;
|
|
Karanbir Singh |
43deec |
create table tests (name varchar(20)) ;
|
|
Karanbir Singh |
43deec |
grant all on qatests.* to 'centos'@'localhost' identified by 'qa';
|
|
Karanbir Singh |
43deec |
flush privileges;
|
|
Karanbir Singh |
43deec |
EOF
|
|
Karanbir Singh |
43deec |
|
|
Karanbir Singh |
43deec |
mysql
|
|
Karanbir Singh |
43deec |
/bin/rm /tmp/mysql-QA.sql
|
|
Karanbir Singh |
43deec |
|
|
Karanbir Singh |
43deec |
# Creating a simple php query page to insert Data in the MySQL DB
|
|
Karanbir Singh |
43deec |
|
|
Karanbir Singh |
43deec |
cat >>/var/www/html/mysql.php <
|
|
Karanbir Singh |
43deec |
|
|
Karanbir Singh |
43deec |
\$dbconnect = mysql_connect("localhost","centos","qa");
|
|
Karanbir Singh |
43deec |
if (!\$dbconnect)
|
|
Karanbir Singh |
43deec |
{
|
|
Karanbir Singh |
43deec |
die('Could not connect: ' . mysql_error());
|
|
Karanbir Singh |
43deec |
}
|
|
Karanbir Singh |
43deec |
|
|
Karanbir Singh |
43deec |
mysql_select_db("qatests", \$dbconnect);
|
|
Karanbir Singh |
43deec |
|
|
Karanbir Singh |
43deec |
mysql_query("INSERT INTO tests (name)
|
|
Karanbir Singh |
43deec |
VALUES ('mysqltest')");
|
|
Karanbir Singh |
43deec |
|
|
Karanbir Singh |
43deec |
mysql_close(\$dbconnect);
|
|
Karanbir Singh |
43deec |
?>
|
|
Karanbir Singh |
43deec |
EOF
|
|
Karanbir Singh |
43deec |
|
|
Karanbir Singh |
43deec |
####################################################
|
|
Karanbir Singh |
43deec |
# testing
|
|
Karanbir Singh |
43deec |
####################################################
|
|
Karanbir Singh |
43deec |
|
|
Karanbir Singh |
43deec |
wget http://localhost/mysql.php
|
|
Karanbir Singh |
43deec |
|
|
Karanbir Singh |
2dd0be |
t_Log "Performing basic LAMP test"
|
|
Karanbir Singh |
43deec |
content=`echo "select * from qatests.tests where name='mysqltest'"|mysql -B --skip-column-names`
|
|
Athmane Madjoudj |
d110e2 |
|
|
Athmane Madjoudj |
d110e2 |
# Clean up
|
|
Athmane Madjoudj |
d110e2 |
mysql -u root -e 'drop database qatests;'
|
|
Athmane Madjoudj |
d110e2 |
|
|
Karanbir Singh |
43deec |
if [ "$content" = "mysqltest" ] ; then
|
|
Karanbir Singh |
2dd0be |
t_Log PASS;
|
|
Karanbir Singh |
43deec |
exit 0;
|
|
Karanbir Singh |
43deec |
else
|
|
Karanbir Singh |
2dd0be |
t_Log FAIL;
|
|
Karanbir Singh |
43deec |
exit 1;
|
|
Karanbir Singh |
43deec |
fi
|