Skip to content

Commit

Permalink
Workflow scaling test infrastructure.
Browse files Browse the repository at this point in the history
 - Add script to hit the API with workflows requests.
 - Update testing Dockerfile to allow just booting up with a fixed master API key for this test to leverage.
 - WIP: on updating test Dockerfile to work with slurm, multiple handlers, uwsgi, etc...
  • Loading branch information
jmchilton committed Mar 25, 2015
1 parent 6d42d37 commit a357e2b
Show file tree
Hide file tree
Showing 10 changed files with 358 additions and 26 deletions.
66 changes: 66 additions & 0 deletions scripts/summarize_timings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
from __future__ import print_function

import os
import sys

script_dir = os.path.dirname(__file__)
galaxy_root = os.path.join(script_dir, os.path.pardir)
new_path = [ os.path.join( galaxy_root, "lib" ) ]
new_path.extend( sys.path[1:] )
sys.path = new_path

try:
from argparse import ArgumentParser
except ImportError:
ArgumentParser = None
import re

try:
from galaxy import eggs
eggs.require("numpy")
except ImportError:
pass
import numpy


DESCRIPTION = ""

TIMING_LINE_PATTERN = re.compile("\((\d+.\d+) ms\)")


def main(argv=None):
if ArgumentParser is None:
raise Exception("Test requires Python 2.7")
arg_parser = ArgumentParser(description=DESCRIPTION)
arg_parser.add_argument("--file", default="paster.log")
arg_parser.add_argument("--print_lines", default=False, action="store_true")
arg_parser.add_argument("--pattern")

args = arg_parser.parse_args(argv)
print_lines = args.print_lines
filter_pattern = re.compile(args.pattern)
times = []
for line in open(args.file, "r"):
if not filter_pattern.search(line):
continue

match = TIMING_LINE_PATTERN.search(line)
if not match:
continue

times.append(float(match.group(1)))
if print_lines:
print(line.strip())

template = "Summary (ms) - Mean: %f, Median: %f, Max: %f, Min: %f, StdDev: %f"
message = template % (
numpy.mean(times),
numpy.median(times),
numpy.max(times),
numpy.min(times),
numpy.std(times)
)
print(message)

if __name__ == "__main__":
main()
10 changes: 5 additions & 5 deletions test/api/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,15 @@ def create_workflow_response( self, workflow, **create_kwds ):
upload_response = self._post( "workflows/upload", data=data )
return upload_response

def wait_for_invocation( self, workflow_id, invocation_id ):
def wait_for_invocation( self, workflow_id, invocation_id, timeout=10 ):
url = "workflows/%s/usage/%s" % ( workflow_id, invocation_id )
return wait_on_state( lambda: self._get( url ) )
return wait_on_state( lambda: self._get( url ), timeout=timeout )

def wait_for_workflow( self, workflow_id, invocation_id, history_id, assert_ok=True ):
def wait_for_workflow( self, workflow_id, invocation_id, history_id, assert_ok=True, timeout=DEFAULT_HISTORY_TIMEOUT ):
""" Wait for a workflow invocation to completely schedule and then history
to be complete. """
self.wait_for_invocation( workflow_id, invocation_id )
self.dataset_populator.wait_for_history( history_id, assert_ok=assert_ok )
self.wait_for_invocation( workflow_id, invocation_id, timeout=timeout )
self.dataset_populator.wait_for_history( history_id, assert_ok=assert_ok, timeout=timeout )


class WorkflowPopulator( BaseWorkflowPopulator ):
Expand Down
5 changes: 4 additions & 1 deletion test/api/yaml_to_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
'input_collection': 'data_collection_input',
}


def yaml_to_workflow(has_yaml):
as_python = yaml.load(has_yaml)
return python_to_workflow(as_path)


def python_to_workflow(as_python):

if isinstance(as_python, list):
as_python = {"steps": as_python}
Expand Down
25 changes: 15 additions & 10 deletions test/docker/base/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
FROM toolshed/requirements
MAINTAINER John Chilton <jmchilton@gmail.com>

ENV MYSQL_MAJOR=5.7 \
MYSQL_VERSION=5.7.5-m15
ENV MYSQL_MAJOR=5.6

# Pre-install a bunch of packages to speed up ansible steps.
RUN apt-get update -y && apt-get install -y software-properties-common curl && \
apt-add-repository -y ppa:ansible/ansible && \
curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - && \
echo 'deb https://deb.nodesource.com/node trusty main' > /etc/apt/sources.list.d/nodesource.list && \
apt-key adv --keyserver pool.sks-keyservers.net --recv-keys A4A9406876FCBD3C456770C88C718D3B5072E1F5 && \
echo "deb http://repo.mysql.com/apt/ubuntu/ trusty mysql-${MYSQL_MAJOR}-dmr" > /etc/apt/sources.list.d/mysql.list && \
echo "deb http://repo.mysql.com/apt/ubuntu/ trusty mysql-${MYSQL_MAJOR}" > /etc/apt/sources.list.d/mysql.list && \
{ \
echo mysql-community-server mysql-community-server/data-dir select ''; \
echo mysql-community-server mysql-community-server/root-pass password ''; \
Expand All @@ -19,7 +18,8 @@ RUN apt-get update -y && apt-get install -y software-properties-common curl && \
} | debconf-set-selections && \
apt-get update -y && \
apt-get install -y libpq-dev postgresql postgresql-client postgresql-plpython-9.3 \
ansible postgresql-server-dev-9.3 wget mysql-server="${MYSQL_VERSION}"* \
ansible postgresql-server-dev-9.3 wget mysql-server="${MYSQL_MAJOR}"* \
slurm-llnl libmunge-dev slurm-drmaa-dev \
nodejs && \
npm install -g grunt-contrib-qunit grunt grunt-cli casperjs phantomjs && \
apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
Expand All @@ -34,16 +34,19 @@ ADD ansible_vars.yml /tmp/ansible/ansible_vars.yml
ADD provision.yml /tmp/ansible/provision.yml

ENV PYTHON_EGG_CACHE=/root/.python-eggs \
GALAXY_ROOT=/opt/galaxy/galaxy-app
GALAXY_ROOT=/galaxy

RUN cd /tmp/ansible && \
RUN mkdir /etc/galaxy && \
cd /tmp/ansible && \
mkdir roles && \
mkdir roles/galaxyprojectdotorg.galaxy-os && \
wget -qO- https://github.com/galaxyproject/ansible-galaxy-os/archive/master.tar.gz | tar -xzvf- --strip-components=1 -C roles/galaxyprojectdotorg.galaxy-os && \
wget -qO- https://github.com/galaxyproject/ansible-galaxy-os/archive/master.tar.gz | tar -xzvf- --strip-components=1 -C roles/galaxyprojectdotorg.galaxy-os && \
mkdir roles/galaxyprojectdotorg.cloudman-database && \
wget -qO- https://github.com/galaxyproject/ansible-cloudman-database/archive/master.tar.gz | tar -xzvf- --strip-components=1 -C roles/galaxyprojectdotorg.cloudman-database && \
mkdir roles/galaxyprojectdotorg.galaxy && \
wget -qO- https://github.com/galaxyproject/ansible-galaxy/archive/master.tar.gz | tar -xzvf- --strip-components=1 -C roles/galaxyprojectdotorg.galaxy && \
mkdir roles/galaxyprojectdotorg.galaxy-extras && \
wget -qO- https://github.com/galaxyproject/ansible-galaxy-extras/archive/dynamic_uwsgi_config.tar.gz | tar -xzvf- --strip-components=1 -C roles/galaxyprojectdotorg.galaxy-extras && \
ANSIBLE_FORCE_COLOR=1 PYTHONUNBUFFERED=1 ansible-playbook /tmp/ansible/provision.yml --tags=image -c local -e "@ansible_vars.yml" && \
ANSIBLE_FORCE_COLOR=1 PYTHONUNBUFFERED=1 ansible-playbook /tmp/ansible/provision.yml --tags=database -c local -e "@ansible_vars.yml" && \
ANSIBLE_FORCE_COLOR=1 PYTHONUNBUFFERED=1 ansible-playbook /tmp/ansible/provision.yml --tags=galaxy -c local -e "@ansible_vars.yml" && \
Expand All @@ -52,12 +55,14 @@ RUN cd /tmp/ansible && \
RUN cd $GALAXY_ROOT && \
echo "Prepopuating postgres database" && \
su -c '/usr/lib/postgresql/9.3/bin/pg_ctl -o "-F" start -D /opt/galaxy/db' postgres && \
GALAXY_CONFIG_DATABASE_CONNECTION="postgresql://galaxy@localhost:5930/galaxy" sh create_db.sh && \
sleep 3 && \
GALAXY_CONFIG_DATABASE_CONNECTION="postgresql://root@localhost:5930/galaxy" sh create_db.sh && \
echo "Prepopuating sqlite database" && \
GALAXY_CONFIG_DATABASE_CONNECTION="sqlite:////opt/galaxy/galaxy.sqlite" sh create_db.sh && \
sh /opt/galaxy/start_mysql.sh && \
sh /opt/galaxy/start_mysql.sh && \
GALAXY_CONFIG_DATABASE_CONNECTION="mysql://galaxy:galaxy@localhost/galaxy?unix_socket=/var/run/mysqld/mysqld.sock" sh create_db.sh

ADD run_test_wrapper.sh /usr/local/bin/run_test_wrapper.sh

EXPOSE :8080
EXPOSE :80
ENTRYPOINT ["/bin/bash", "/usr/local/bin/run_test_wrapper.sh"]
25 changes: 22 additions & 3 deletions test/docker/base/ansible_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
add_system_users: no
galaxyFS_base_dir: /opt/galaxy
# TODO: use GALAXY_ROOT via cmd line instead
galaxy_server_dir: "{{ galaxyFS_base_dir }}/galaxy-app"
galaxy_venv_dir: "{{ galaxy_server_dir }}/.venv"
galxy_egg_cache: "/home/{{ galaxy_user_name }}/.python-eggs"
galaxy_server_dir: "/galaxy"
galaxy_venv_dir: "{{ galaxyFS_base_dir }}/.venv"
galxy_egg_cache: "/root/.python-eggs"
galaxy_repo: https://bitbucket.org/galaxy/galaxy-central
galaxy_changeset_id: stable
galaxy_manage_clone: no
Expand All @@ -19,3 +19,22 @@ configure_docker: no
postgresql_bin_dir: /usr/lib/postgresql/9.3/bin
galaxy_manage_database: no

galaxy_user_name: "root"
galaxy_extras_install_packages: true
galaxy_job_conf_path: "/etc/galaxy/job_conf.xml"
galxy_config_file: "/galaxy/config/galaxy.ini.sample"

galaxy_web_processes: 1
galaxy_handler_processes: 2
galaxy_log_dir: "/root"

supervisor_nodaemon: true
supervisor_postgres_database_path: "{{ galaxy_db_dir }}"

galaxy_extras_config_nginx: true
galaxy_extras_config_proftpd: false
galaxy_extras_config_slurm: true
galaxy_extras_config_supervisor: true
galaxy_extras_config_galaxy_root: false
galaxy_extras_config_galaxy_job_metrics: false
galaxy_extras_config_uwsgi: true
49 changes: 42 additions & 7 deletions test/docker/base/run_test_wrapper.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,58 @@
#!/bin/bash
set -e

# TODO: switch on environment to boot mysql here...
GALAXY_TEST_DATABASE_TYPE=${GALAXY_TEST_DATABASE_TYPE:-"postgres"}
if [ "$GALAXY_TEST_DATABASE_TYPE" = "postgres" ];
then
su -c '/usr/lib/postgresql/9.3/bin/pg_ctl -o "-F" start -D /opt/galaxy/db' postgres
sleep 3
export GALAXY_TEST_DBURI="postgres://galaxy@localhost:5930/galaxy"
sleep 3
GALAXY_TEST_DBURI="postgres://root@localhost:5930/galaxy"
elif [ "$GALAXY_TEST_DATABASE_TYPE" = "mysql" ];
then
sh /opt/galaxy/start_mysql.sh
export GALAXY_TEST_DBURI="mysql://galaxy:galaxy@localhost/galaxy?unix_socket=/var/run/mysqld/mysqld.sock"
GALAXY_TEST_DBURI="mysql://galaxy:galaxy@localhost/galaxy?unix_socket=/var/run/mysqld/mysqld.sock"
elif [ "$GALAXY_TEST_DATABASE_TYPE" = "sqlite" ];
then
export GALAXY_TEST_DBURI="sqlite:////opt/galaxy/galaxy.sqlite"
GALAXY_TEST_DBURI="sqlite:////opt/galaxy/galaxy.sqlite"
else
echo "Unknown database type"
exit 1
fi
export GALAXY_TEST_DBURI

cd /galaxy
GALAXY_CONFIG_OVERRIDE_DATABASE_CONNECTION="$GALAXY_TEST_DBURI" sh manage_db.sh upgrade
sh run_tests.sh $@
GALAXY_CONFIG_OVERRIDE_DATABASE_CONNECTION="$GALAXY_TEST_DBURI";
export GALAXY_CONFIG_OVERRIDE_DATABASE_CONNECTION

sh manage_db.sh upgrade

if [ -z "$GALAXY_NO_TESTS" ];
then
sh run_tests.sh $@
else
GALAXY_CONFIG_MASTER_API_KEY=${GALAXY_CONFIG_MASTER_API_KEY:-"testmasterapikey"}
GALAXY_CONFIG_FILE=${GALAXY_CONFIG_FILE:-config/galaxy.ini.sample}
GALAXY_CONFIG_CHECK_MIGRATE_TOOLS=false
if [ -z "$GALAXY_MULTI_PROCESS" ];
then
GALAXY_CONFIG_JOB_CONFIG_FILE=${GALAXY_CONFIG_JOB_CONFIG_FILE:-config/job_conf.xml.sample}
else
GALAXY_CONFIG_JOB_CONFIG_FILE=/etc/galaxy/job_conf.xml
fi
GALAXY_CONFIG_FILE_PATH=${GALAXY_CONFIG_FILE_PATH:-/tmp/gx1}
GALAXY_CONFIG_NEW_FILE_PATH=${GALAXY_CONFIG_NEW_FILE_PATH:-/tmp/gxtmp}

export GALAXY_CONFIG_MASTER_API_KEY
export GALAXY_CONFIG_FILE
export GALAXY_CONFIG_CHECK_MIGRATE_TOOLS
export GALAXY_CONFIG_JOB_CONFIG_FILE
export GALAXY_CONFIG_FILE_PATH
export GALAXY_CONFIG_NEW_FILE_PATH

if [ -z "$GALAXY_MULTI_PROCESS" ];
then
sh run.sh $@
else
/usr/bin/supervisord
fi
fi
18 changes: 18 additions & 0 deletions test/functional/tools/for_workflows/cat_interleave.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<tool id="cat_interleave" name="Interleave two inputs (for test workflows)">
<command>
cat $input1 $input2 > $out_file1;
cat $input2 $input1 > $out_file2;
</command>
<inputs>
<param name="input1" type="data" label="Input 1"/>
<param name="input2" type="data" label="Input 2"/>
</inputs>
<outputs>
<data name="out_file1" format="input" metadata_source="input1"/>
<data name="out_file2" format="input" metadata_source="input2"/>
</outputs>
<tests>
</tests>
<help>
</help>
</tool>
1 change: 1 addition & 0 deletions test/functional/tools/samples_tool_conf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<tool file="for_workflows/cat_list.xml" />
<tool file="for_workflows/cat_collection.xml" />
<tool file="for_workflows/head.xml" />
<tool file="for_workflows/cat_interleave.xml" />

<tool file="simple_constructs.yml" />

Expand Down
Empty file added test/manual/__init__.py
Empty file.

0 comments on commit a357e2b

Please sign in to comment.