0ff55f935245a0d6422ece154dfd9f1696da16a6 mary Tue Jul 27 16:32:34 2010 -0700 adding script to check functionality of genome-mysql diff --git src/utils/qa/checkGenomeMysql src/utils/qa/checkGenomeMysql new file mode 100755 index 0000000..182fc9e --- /dev/null +++ src/utils/qa/checkGenomeMysql @@ -0,0 +1,65 @@ +#!/bin/bash +# quit if something within the script fails +set -beEu -o pipefail +source `which qaConfig.bash` + +################################ +# +# 06/07/10 Mary Goldman +# +# Script to make sure that all expected tables in public genome-mysql +# server are there and that they are not corrupted. +# Does this by selecting * from table limit 2 (data from limit 1 is +# stored in metaDb table automatically made by mysql databases). +# +################################ + +if [ $# -ne 1 ] +then + echo -e " + checks genome-mysql for corrupted tables + for the database of the day\n + Note: If script finds a table that + doesn't exist, it will not check the + rest of the tables in a database. + usage: database\n" >&2 + exit 1 +else + db="$1" +fi + +# make sure this is a valid database name +if ! hgsql -Ne "show databases" | grep -qw $db +then + echo -e "\nERROR: database $db not found. Try running on hgwdev?\n" >&2 + exit 1 +fi + +allOk=true #keeping track of no errors vs errors +RRdumpFile=$(getRRdumpfile.csh $db) #location of RR dump file + +# only get the table name($1) where the row number($5) is greater than 0 +# Also dropping the column header. +# uses 'tawk' (program Mark wrote): uses tabs as delimiters +tableList=$(tawk 'NR>1 {if ($5>0) print $1}' $RRdumpFile) + +# for each table in list do a select * limit 5 and check for errors +for table in $tableList +do +# need to do it this way since if mysql has an error it exits zero (ie can't use status) + mysqlResult=$(mysql --user=genome --host=genome-mysql.cse.ucsc.edu -A -Ne "select * from $table \ + limit 5" $db| wc -l) + if [ $mysqlResult == 0 ] + then + echo "ERROR:Can't select * from $table limit 5 from $db." >&2 + allOk=false + fi +done + +if [ $allOk == false ] +then + exit 1 +else + exit 0 +fi +# cron will send an email if you exit non-zero.