diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/genenetwork2 | 110 | ||||
-rwxr-xr-x | bin/test-website | 49 |
2 files changed, 123 insertions, 36 deletions
diff --git a/bin/genenetwork2 b/bin/genenetwork2 index d3bf3299..52d3155c 100755 --- a/bin/genenetwork2 +++ b/bin/genenetwork2 @@ -1,44 +1,112 @@ #! /bin/bash # -# This will run the GN2 server (with default settings if none supplied). +# This will run the GN2 server (with default settings if none +# supplied). Pass in your own settings file, e.g. +# +# ./bin/genenetwork2 ~/my_settings.py +# +# But better is to retain the defaults and override them with +# JSON file (see the deploy docs). +# +# ./bin/genenetwork2 ~/my_overrides.json +# +# To run a maintenance script with settings (instead of the webserver) add that with +# a -c switch, e.g. +# +# ./bin/genenetwork2 ~/my_overrides.json -c ./wqflask/maintenance/gen_select_dataset.py # # Environment settings can be used to preconfigure as well as a # settings.py file. +# +# GN2_BASE_PATH is base directory of wqflask source code +# -# Absolute path to this script, e.g. /home/user/bin/foo.sh SCRIPT=$(readlink -f "$0") -# Absolute path this script is in, thus /home/user/bin -GN2_BASE_PATH=$(dirname $(dirname "$SCRIPT")) +GN2_BASE_DIR=$(dirname $(dirname "$SCRIPT")) -GN2_GUIX_PATH=$GN2_BASE_PATH/lib/python2.7/site-packages/genenetwork2-2.0-py2.7.egg -if [ -d $GN2_GUIX_PATH ]; then - GN2_BASE_PATH=$GN2_GUIX_PATH -fi -echo $GN2_BASE_PATH +echo GN2_BASE_DIR=$GN2_BASE_DIR + +GIT_HASH=$(git rev-parse HEAD) +GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD) +export GN_VERSION=$(cat $GN2_BASE_DIR/VERSION)-$GIT_BRANCH-${GIT_HASH:0:9} +echo GN_VERSION=$GN_VERSION -# Handle settings parameter +# Handle settings parameter (can be .py or .json) settings=$1 -if [ -z $settings ]; then settings=$GN2_BASE_PATH/etc/default_settings.py ; fi +ext="${settings##*.}" +if [ -z "$settings" -o "$ext" = "json" -o "$ext" = "JSON" ]; then + overrides=$settings + settings=$GN2_BASE_DIR/etc/default_settings.py +else + shift +fi if [ ! -e $settings ]; then - echo "ERROR: can not locate settings file - pass it in the command line" - exit 1 + GUIX_ETC=$GN2_BASE_DIR/lib/python2.7/site-packages/genenetwork2-2.0-py2.7.egg + if [ -d $GUIX_ETC ]; then + echo INFO: GN2 is actually running from GNU Guix + else + echo "ERROR: can not locate settings file - pass it in the command line" + exit 1 + fi +fi +export WQFLASK_SETTINGS=$settings # Python +export WQFLASK_OVERRIDES=$overrides # JSON + +echo WQFLASK_SETTINGS=$settings +echo WQFLASK_OVERRIDES=$overrides + +# ---- Checks and balances +if [ -z $GUIX_ETC ]; then + if [ -z $GN2_PROFILE ] ; then + echo "WARNING: GN2_PROFILE has not been set - I hope you know what you are doing!" + else + export PATH=$GN2_PROFILE/bin:$PATH + export PYTHONPATH=$GN2_PROFILE/lib/python2.7/site-packages + export R_LIBS_SITE=$GN2_PROFILE/site-library + export GUIX_GTK3_PATH="$GN2_PROFILE/lib/gtk-3.0" + export GI_TYPELIB_PATH="$GN2_PROFILE/lib/girepository-1.0" + export XDG_DATA_DIRS="$GN2_PROFILE/share" + export GIO_EXTRA_MODULES="$GN2_PROFILE/lib/gio/modules" + export LC_ALL=C + fi + if [ -z $PYTHONPATH ] ; then + echo "WARNING PYTHONPATH has not been set - use GN2_PROFILE!" + fi + if [ ! -d $R_LIBS_SITE ] ; then + echo "ERROR: R_LIBS_SITE has not been set correctly (we only allow one path) - use GN2_PROFILE!" + echo "Paste into your shell the output of (for example)" + echo "guix package -p \$GN2_PROFILE --search-paths" + exit 1 + fi fi -export WQFLASK_SETTINGS=$settings # We may change this one: -export PYTHONPATH=$GN2_BASE_PATH/wqflask:$PYTHONPATH +export PYTHONPATH=$GN2_BASE_DIR/wqflask:$PYTHONPATH -# TEMPDIR defaults to /tmp if nothing else -if [ -z $TEMPDIR ]; then - TEMPDIR="/tmp" +# Our UNIX TMPDIR defaults to /tmp - change this on a shared server +if [ -z $TMPDIR ]; then + TMPDIR="/tmp" fi - + +set|grep $GN2_PROFILE +set|grep TMPDIR + +# Now handle command parameter -c +if [ "$1" = '-c' ] ; then + cd $GN2_BASE_DIR/wqflask + cmd=${2#wqflask/} + echo PYTHONPATH=$PYTHONPATH + echo RUNNING COMMAND $cmd + /usr/bin/env python $cmd + exit 0 +fi + echo "Starting the redis server:" -echo -n "dir $TEMPDIR +echo -n "dir $TMPDIR dbfilename gn2.rdb " | redis-server - & # Start the flask server running GN2 -cd $GN2_BASE_PATH/wqflask +cd $GN2_BASE_DIR/wqflask echo "Starting with $settings" /usr/bin/env python runserver.py diff --git a/bin/test-website b/bin/test-website index 2e91f364..be223d94 100755 --- a/bin/test-website +++ b/bin/test-website @@ -2,9 +2,9 @@ USAGE = <<EOT -This is Mechanical-Rob - an automated web server tester for - Genenetwork.org that uses the brilliant - mechanize gem. +This is Mechanical-Rob - an automated web server tester for + Genenetwork.org that uses the brilliant + mechanize gem with minitest. To use this software you need to install mechanize. Run it from the root of the genenetwork2 source tree as, for example, @@ -15,8 +15,16 @@ If you are using the small deployment database you can use ./bin/test-website --skip -n +To run all tests + + ./bin/test-website --all + +To run individual tests on localhost you can do + + ruby -Itest -Itest/lib test/lib/mapping.rb --name="/Mapping/" + For more information see http://genenetwork.org/ - + EOT $stderr.print USAGE @@ -25,7 +33,7 @@ require 'optparse' options = { database: :small, link_checker: false} opts = OptionParser.new do |o| o.banner = "Usage: #{File.basename($0)} [options] URL" - + o.on('-d','--database', String, 'Use database (default db_webqtl_s)') do |s| options[:database] = case s @@ -36,12 +44,20 @@ opts = OptionParser.new do |o| end end + o.on('--all', 'Run all tests') do + options[:all] = true + end + o.on('-l','--link-checker', 'Check for dead links') do options[:link_checker] = true end - - o.on('-n','--navigation-test', 'Check for navigation test results') do - options[:navigation_test] = true + + o.on('--navigation', 'Check for navigation') do + options[:navigation] = true + end + + o.on('--mapping', 'Check for mapping') do + options[:mapping] = true end o.on('--skip-broken', 'Skip tests that are known to be broken') do @@ -62,7 +78,7 @@ if options[:show_help] end $options = options # we are using a global here -$host = +$host = if ARGV.size>0 ARGV.shift else @@ -80,13 +96,16 @@ require 'minitest/autorun' libpath = File.dirname(File.dirname(__FILE__)) $: << File.join(libpath,'test/lib') -if options[:link_checker] +require 'main_web_functionality' + +if options[:all] or options[:mapping] + require 'mapping' +end + +if options[:all] or options[:link_checker] require 'link_checker' -else - require 'main_web_functionality' end - -if options[:navigation_test] + +if options[:all] or options[:navigation] require 'navigation' end - |