bstinson / centos / t_functional

Forked from centos/t_functional 4 years ago
Clone

Blame tests/p_python/25-python-mysql55-test.sh

Christoph Galuschka 63756a
#!/bin/sh
Christoph Galuschka 63756a
# Author: Athmane Madjoudj <athmanem@gmail.com>
Christoph Galuschka 63756a
# Author: Christoph Galuschka <christoph.galuschka@chello.at>
Christoph Galuschka 63756a
Christoph Galuschka 63756a
t_Log "Running $0 - python can retrieve mysql55-mysql-server version information."
Christoph Galuschka 63756a
Christoph Galuschka 63756a
# we need a working and running mysql server
Christoph Galuschka 63756a
# starting with 5.10, we have to differ between mysql55 and mysql
e848a7
Christoph Galuschka 63756a
if [ $centos_ver = 5 ]
Christoph Galuschka 63756a
then
Christoph Galuschka 63756a
  t_ServiceControl mysqld stop
Christoph Galuschka 63756a
  t_ServiceControl mysql55-mysqld start
Christoph Galuschka 63756a
fi
Christoph Galuschka 63756a
Christoph Galuschka 63756a
# Installing additional python/mysql module
Christoph Galuschka 63756a
t_InstallPackage MySQL-python
Christoph Galuschka 63756a
Christoph Galuschka 63756a
# create python Scrip
Christoph Galuschka 63756a
SCRIPT='/var/tmp/test.py'
Christoph Galuschka 63756a
Christoph Galuschka 63756a
cat >$SCRIPT <
Christoph Galuschka 63756a
import MySQLdb
Christoph Galuschka 63756a
Christoph Galuschka 63756a
conn = MySQLdb.connect (host = "localhost",
Christoph Galuschka 63756a
                           user = "",
Christoph Galuschka 63756a
                           passwd = "",
Christoph Galuschka 63756a
                           db = "test")
Christoph Galuschka 63756a
cursor = conn.cursor ()
Christoph Galuschka 63756a
cursor.execute ("SELECT VERSION()")
Christoph Galuschka 63756a
row = cursor.fetchone ()
Christoph Galuschka 63756a
print "server version:", row[0]
Christoph Galuschka 63756a
cursor.close ()
Christoph Galuschka 63756a
conn.close ()
Christoph Galuschka 63756a
EOF
Christoph Galuschka 63756a
Christoph Galuschka 63756a
# If we execute the script and get the version it works
Christoph Galuschka 63756a
python $SCRIPT |grep -q 'server version'
Christoph Galuschka 63756a
Christoph Galuschka 63756a
t_CheckExitStatus $?
Christoph Galuschka 63756a
Christoph Galuschka 63756a
# cleaning up
Christoph Galuschka 63756a
/bin/rm $SCRIPT