commit/galaxy-central: Dave Bouvier: Functional tests for tool dependency XML verification. Functional tests for detecting missing env.sh files due to tool dependency installation errors.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/253f888144aa/ Changeset: 253f888144aa User: Dave Bouvier Date: 2013-11-21 17:12:13 Summary: Functional tests for tool dependency XML verification. Functional tests for detecting missing env.sh files due to tool dependency installation errors. Affected #: 6 files diff -r d448ed76962c8b36fde83e5cd8dec91e97c9d812 -r 253f888144aaa4ae4eadaf15de493b3144fc5cd3 test/tool_shed/base/twilltestcase.py --- a/test/tool_shed/base/twilltestcase.py +++ b/test/tool_shed/base/twilltestcase.py @@ -1,6 +1,15 @@ +import common +import string +import os +import re +import test_db_util +import simplejson +import logging +import time +import tempfile +import tarfile import galaxy.webapps.tool_shed.util.hgweb_config import galaxy.model as galaxy_model -import common, string, os, re, test_db_util, simplejson, logging, time import galaxy.util as util from tool_shed.util import shed_util_common as suc from base.twilltestcase import tc, from_json_string, TwillTestCase, security, urllib @@ -44,7 +53,7 @@ url = '/repository_review/create_component?operation=create' self.visit_url( url ) self.submit_form( 1, 'create_component_button', **kwd ) - + def browse_category( self, category, strings_displayed=[], strings_not_displayed=[] ): url = '/repository/browse_valid_categories?sort=name&operation=valid_repositories_by_category&id=%s' % \ self.security.encode_id( category.id ) @@ -479,7 +488,17 @@ else: string = string.replace( character, replacement ) return string - + + def export_capsule( self, repository ): + url = '/repository/export?repository_id=%s&changeset_revision=%s' % \ + ( self.security.encode_id( repository.id ), self.get_repository_tip( repository ) ) + self.visit_url( url ) + self.submit_form( 'export_repository', 'export_repository_button' ) + fd, capsule_filename = tempfile.mkstemp() + os.close( fd ) + file( capsule_filename, 'w' ).write( self.last_page() ) + return capsule_filename + def fill_review_form( self, review_contents_dict, strings_displayed=[], strings_not_displayed=[] ): kwd = dict() changed = False @@ -727,7 +746,17 @@ tc.fv( "user_access", "allow_push", '+%s' % username ) tc.submit( 'user_access_button' ) self.check_for_strings( post_submit_strings_displayed, post_submit_strings_not_displayed ) - + + def import_capsule( self, filename, strings_displayed=[], strings_not_displayed=[], + strings_displayed_after_submit=[], strings_not_displayed_after_submit=[] ): + url = '/repository/upload_capsule' + self.visit_url( url ) + tc.formfile( 'upload_capsule', 'file_data', filename ) + tc.submit( 'upload_capsule_button' ) + self.check_for_strings( strings_displayed, strings_not_displayed ) + self.submit_form( 'import_capsule', 'import_capsule_button' ) + self.check_for_strings( strings_displayed_after_submit, strings_not_displayed_after_submit ) + def import_workflow( self, repository, workflow_name, strings_displayed=[], strings_not_displayed=[] ): url = '/admin_toolshed/import_workflow?repository_id=%s&workflow_name=%s' % \ ( self.security.encode_id( repository.id ), tool_shed_encode( workflow_name ) ) diff -r d448ed76962c8b36fde83e5cd8dec91e97c9d812 -r 253f888144aaa4ae4eadaf15de493b3144fc5cd3 test/tool_shed/functional/test_0480_tool_dependency_xml_verification.py --- /dev/null +++ b/test/tool_shed/functional/test_0480_tool_dependency_xml_verification.py @@ -0,0 +1,75 @@ +from tool_shed.base.twilltestcase import ShedTwillTestCase, common, os +import tool_shed.base.test_db_util as test_db_util + +import logging +log = logging.getLogger( __name__ ) + +category_name = 'Test 0480 Tool dependency definition validation' +category_description = 'Test script 0480 for validating tool dependency definitions.' +repository_name = 'package_invalid_tool_dependency_xml_1_0_0' +repository_description = "Contains a tool dependency definition that should return an error." +repository_long_description = "This repository is in the test suite 0480" + +''' + +1. Create a repository package_invalid_tool_dependency_xml_1_0_0 +2. Upload a tool_dependencies.xml file to the repository with no <actions> tags around the <action> tags. +3. Verify error message is displayed. + +''' + +class TestDependencyDefinitionValidation( ShedTwillTestCase ): + '''Test the tool shed's tool dependency XML validation.''' + + def test_0000_initiate_users_and_category( self ): + """Create necessary user accounts and login as an admin user.""" + self.logout() + self.login( email=common.admin_email, username=common.admin_username ) + admin_user = test_db_util.get_user( common.admin_email ) + assert admin_user is not None, 'Problem retrieving user with email %s from the database' % common.admin_email + admin_user_private_role = test_db_util.get_private_role( admin_user ) + self.create_category( name=category_name, description=category_description ) + self.logout() + self.login( email=common.test_user_2_email, username=common.test_user_2_name ) + test_user_2 = test_db_util.get_user( common.test_user_2_email ) + assert test_user_2 is not None, 'Problem retrieving user with email %s from the database' % common.test_user_2_email + test_user_2_private_role = test_db_util.get_private_role( test_user_2 ) + self.logout() + self.login( email=common.test_user_1_email, username=common.test_user_1_name ) + test_user_1 = test_db_util.get_user( common.test_user_1_email ) + assert test_user_1 is not None, 'Problem retrieving user with email %s from the database' % common.test_user_1_email + test_user_1_private_role = test_db_util.get_private_role( test_user_1 ) + + def test_0005_create_tool_dependency_repository( self ): + '''Create and populate package_invalid_tool_dependency_xml_1_0_0.''' + ''' + This is step 1 - Create a repository package_invalid_tool_dependency_xml_1_0_0. + + Create a repository named package_invalid_tool_dependency_xml_1_0_0 that will contain only a single file named tool_dependencies.xml. + ''' + category = test_db_util.get_category_by_name( category_name ) + repository = self.get_or_create_repository( name=repository_name, + description=repository_description, + long_description=repository_long_description, + owner=common.test_user_1_name, + category_id=self.security.encode_id( category.id ), + strings_displayed=[] ) + self.upload_file( repository, + filename='0480_files/tool_dependencies.xml', + filepath=None, + valid_tools_only=False, + uncompress_file=False, + remove_repo_files_not_in_tar=False, + commit_message='Populate package_invalid_tool_dependency_xml_1_0_0 with an improperly defined tool dependency.', + strings_displayed=[ 'package cannot be installed because', 'missing either an <actions> tag set' ], + strings_not_displayed=[] ) + + def test_0010_populate_tool_dependency_repository( self ): + '''Verify package_invalid_tool_dependency_xml_1_0_0.''' + ''' + This is step 3 - Verify repository. The uploaded tool dependency XML should not have resulted in a new changeset. + ''' + repository = test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name ) + assert self.repository_is_new( repository ), 'Uploading an incorrectly defined tool_dependencies.xml resulted in a changeset being generated.' + + \ No newline at end of file diff -r d448ed76962c8b36fde83e5cd8dec91e97c9d812 -r 253f888144aaa4ae4eadaf15de493b3144fc5cd3 test/tool_shed/functional/test_1440_missing_env_sh_files.py --- /dev/null +++ b/test/tool_shed/functional/test_1440_missing_env_sh_files.py @@ -0,0 +1,130 @@ +from tool_shed.base.twilltestcase import ShedTwillTestCase, common, os +import tool_shed.base.test_db_util as test_db_util + +import logging +log = logging.getLogger( __name__ ) + +category_name = 'Test 1440 Tool dependency missing env.sh' +category_description = 'Test script 1440 for detection of missing environment settings.' +package_repository_name = 'package_env_sh_1_0_1440' +tool_repository_name = 'filter_1440' +package_repository_description = 'Repository that should result in an env.sh file, but does not.' +tool_repository_description = 'Galaxy filtering tool.' +package_repository_long_description = '%s: %s' % ( package_repository_name, package_repository_description ) +tool_repository_long_description = '%s: %s' % ( tool_repository_name, tool_repository_description ) + +''' +1. Create a tool dependency type repository that reliably fails to install successfully. This repository should define + an action that would have created an env.sh file on success, resulting in an env.sh file that should exist, but is missing. + +2. Create a repository that defines a complex repository dependency in the repository created in step 1, with prior_install_required + and set_environment_for_install. + +3. Attempt to install the second repository into a galaxy instance, verify that it is installed but missing tool dependencies. + +''' + + +class TestMissingEnvSh( ShedTwillTestCase ): + '''Test installing a repository that should create an env.sh file, but does not.''' + + def test_0000_initiate_users_and_category( self ): + """Create necessary user accounts and login as an admin user.""" + self.logout() + self.login( email=common.admin_email, username=common.admin_username ) + admin_user = test_db_util.get_user( common.admin_email ) + assert admin_user is not None, 'Problem retrieving user with email %s from the database' % common.admin_email + admin_user_private_role = test_db_util.get_private_role( admin_user ) + self.create_category( name=category_name, description=category_description ) + self.logout() + self.login( email=common.test_user_2_email, username=common.test_user_2_name ) + test_user_2 = test_db_util.get_user( common.test_user_2_email ) + assert test_user_2 is not None, 'Problem retrieving user with email %s from the database' % common.test_user_2_email + test_user_2_private_role = test_db_util.get_private_role( test_user_2 ) + self.logout() + self.login( email=common.test_user_1_email, username=common.test_user_1_name ) + test_user_1 = test_db_util.get_user( common.test_user_1_email ) + assert test_user_1 is not None, 'Problem retrieving user with email %s from the database' % common.test_user_1_email + test_user_1_private_role = test_db_util.get_private_role( test_user_1 ) + + def test_0005_create_package_repository( self ): + '''Create and populate package_env_sh_1_0_1440.''' + ''' + This is step 1 - Create repository package_env_sh_1_0_1440. + + Create and populate a repository that is designed to fail a tool dependency installation. This tool dependency should + also define one or more environment variables. + ''' + category = test_db_util.get_category_by_name( category_name ) + repository = self.get_or_create_repository( name=package_repository_name, + description=package_repository_description, + long_description=package_repository_long_description, + owner=common.test_user_1_name, + category_id=self.security.encode_id( category.id ), + strings_displayed=[] ) + # Upload the edited tool dependency definition to the package_lapack_3_4_1440 repository. + self.upload_file( repository, + filename='1440_files/dependency_definition/tool_dependencies.xml', + filepath=None, + valid_tools_only=True, + uncompress_file=False, + remove_repo_files_not_in_tar=False, + commit_message='Populate package_env_sh_1_0_1440 with a broken tool dependency definition.', + strings_displayed=[], + strings_not_displayed=[] ) + + def test_0010_create_filter_repository( self ): + '''Create and populate filter_1440.''' + ''' + This is step 2 - Create a repository that defines a complex repository dependency on the repository created in + step 1, with prior_install_required and set_environment_for_install. + ''' + category = test_db_util.get_category_by_name( category_name ) + repository = self.get_or_create_repository( name=tool_repository_name, + description=tool_repository_description, + long_description=tool_repository_long_description, + owner=common.test_user_1_name, + category_id=self.security.encode_id( category.id ), + strings_displayed=[] ) + # Upload the edited tool dependency definition to the package_lapack_3_4_1440 repository. + self.upload_file( repository, + filename='filtering/filtering_2.2.0.tar', + filepath=None, + valid_tools_only=True, + uncompress_file=False, + remove_repo_files_not_in_tar=False, + commit_message='Populate filter_1440 with the filtering tool.', + strings_displayed=[], + strings_not_displayed=[] ) + self.upload_file( repository, + filename='1440_files/complex_dependency/tool_dependencies.xml', + filepath=None, + valid_tools_only=True, + uncompress_file=False, + remove_repo_files_not_in_tar=False, + commit_message='Populate filter_1440 with a dependency on package_env_sh_1_0_1440.', + strings_displayed=[], + strings_not_displayed=[] ) + + def test_0015_install_filter_repository( self ): + '''Install the filter_1440 repository to galaxy.''' + ''' + This is step 3 - Attempt to install the second repository into a galaxy instance, verify that it is installed but + missing tool dependencies. + ''' + self.galaxy_logout() + self.galaxy_login( email=common.admin_email, username=common.admin_username ) + post_submit_strings_displayed = [ 'filter_1440', 'package_env_sh_1_0_1440' ] + self.install_repository( 'filter_1440', + common.test_user_1_name, + category_name, + install_tool_dependencies=True, + post_submit_strings_displayed=post_submit_strings_displayed ) + + def test_0020_verify_missing_tool_dependency( self ): + '''Verify that the filter_1440 repository is installed and missing tool dependencies.''' + repository = test_db_util.get_installed_repository_by_name_owner( 'filter_1440', common.test_user_1_name ) + strings_displayed = [ 'Missing tool dependencies' ] + self.display_installed_repository_manage_page( repository, strings_displayed=strings_displayed ) + assert len( repository.missing_tool_dependencies ) == 1, 'filter_1440 should have a missing tool dependency, but does not.' + diff -r d448ed76962c8b36fde83e5cd8dec91e97c9d812 -r 253f888144aaa4ae4eadaf15de493b3144fc5cd3 test/tool_shed/test_data/0480_files/tool_dependencies.xml --- /dev/null +++ b/test/tool_shed/test_data/0480_files/tool_dependencies.xml @@ -0,0 +1,14 @@ +<?xml version="1.0"?> +<tool_dependency> + <package name="invalid_tool_dependency_xml" version="1.0.0"> + <install version="1.0"> + <action type="download_file">file://./</action> + <action type="shell_command">/bin/true</action> + <action type="set_environment"> + <environment_variable action="set_to" name="INSTALL_DIR">$INSTALL_DIR</environment_variable> + </action> + </install> + <readme> + </readme> + </package> +</tool_dependency> \ No newline at end of file diff -r d448ed76962c8b36fde83e5cd8dec91e97c9d812 -r 253f888144aaa4ae4eadaf15de493b3144fc5cd3 test/tool_shed/test_data/1440_files/complex_dependency/tool_dependencies.xml --- /dev/null +++ b/test/tool_shed/test_data/1440_files/complex_dependency/tool_dependencies.xml @@ -0,0 +1,6 @@ +<?xml version='1.0' encoding='utf-8'?> +<tool_dependency> + <package name="failure" version="1.0.0"> + <repository name="package_env_sh_1_0_1440" owner="user1" /> + </package> +</tool_dependency> \ No newline at end of file diff -r d448ed76962c8b36fde83e5cd8dec91e97c9d812 -r 253f888144aaa4ae4eadaf15de493b3144fc5cd3 test/tool_shed/test_data/1440_files/dependency_definition/tool_dependencies.xml --- /dev/null +++ b/test/tool_shed/test_data/1440_files/dependency_definition/tool_dependencies.xml @@ -0,0 +1,14 @@ +<?xml version='1.0' encoding='utf-8'?> +<tool_dependency> + <package name="failure" version="1.0.0"> + <install version="1.0"> + <actions> + <action type="shell_command">false</action> + <action type="set_environment"> + <environment_variable name="TEST_SUCCEEDED" action="prepend_to">true</environment_variable> + </action> + </actions> + </install> + <readme></readme> + </package> +</tool_dependency> \ No newline at end of file Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org