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
Christoph Galuschka 8dfc95
t_ServiceControl mysqld restart
Christoph Galuschka 8dfc95
t_ServiceControl httpd restart
Karanbir Singh 43deec
Karanbir Singh 43deec
# Initializing a small MySQL db
Athmane Madjoudj 27fc06
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
Athmane Madjoudj 27fc06
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
Athmane Madjoudj 27fc06
curl -s  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 b16a15
service httpd stop
Athmane Madjoudj d110e2
Karanbir Singh 43deec
if [ "$content" = "mysqltest" ] ; then
Christoph Galuschka 2e276f
	ret_val=0;
Karanbir Singh 43deec
else
Christoph Galuschka 2e276f
	ret_val=1;
Karanbir Singh 43deec
fi
Christoph Galuschka 2e276f
Christoph Galuschka 2e276f
t_CheckExitStatus $ret_val