2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/f957eec387a0/ Changeset: f957eec387a0 Branch: next-stable User: greg Date: 2014-02-10 17:33:51 Summary: Fixes for the tool shed's install and test framework. Affected #: 3 files diff -r aea2ff5acd6805ad10db0442cc159f7e4e67a541 -r f957eec387a07f5dc7acceff2124a8ef2edac6f8 test/install_and_test_tool_shed_repositories/base/util.py --- a/test/install_and_test_tool_shed_repositories/base/util.py +++ b/test/install_and_test_tool_shed_repositories/base/util.py @@ -285,15 +285,17 @@ break return version -def get_missing_repository_dependencies( repository ): +def get_missing_repository_dependencies( repository, all_missing_repository_dependencies=None ): """ Return the entire list of missing repository dependencies for the received repository. The entire dependency tree will be inspected. """ + if all_missing_repository_dependencies is None: + all_missing_repository_dependencies = [] print 'Checking revision %s of repository %s owned by %s for missing repository dependencies.' % \ ( repository.changeset_revision, repository.name, repository.owner ) - missing_repository_dependencies = repository.missing_repository_dependencies - for missing_required_repository in missing_repository_dependencies: + all_missing_repository_dependencies.extend( repository.missing_repository_dependencies ) + for missing_required_repository in repository.missing_repository_dependencies: print 'Revision %s of required repository %s owned by %s has status %s.' % \ ( missing_required_repository.changeset_revision, missing_required_repository.name, @@ -301,24 +303,28 @@ missing_required_repository.status ) for repository_dependency in repository.repository_dependencies: if repository_dependency.missing_repository_dependencies: - missing_repository_dependencies.extend( get_missing_repository_dependencies( repository_dependency ) ) - return missing_repository_dependencies + all_missing_repository_dependencies.extend( get_missing_repository_dependencies( repository_dependency, + all_missing_repository_dependencies ) ) + return all_missing_repository_dependencies -def get_missing_tool_dependencies( repository ): +def get_missing_tool_dependencies( repository, all_missing_tool_dependencies=None ): """ Return the entire list of missing tool dependencies for the received repository. The entire dependency tree will be inspected. """ + if all_missing_tool_dependencies is None: + all_missing_tool_dependencies = [] print 'Checking revision %s of repository %s owned by %s for missing tool dependencies.' % \ ( repository.changeset_revision, repository.name, repository.owner ) - missing_tool_dependencies = repository.missing_tool_dependencies - for missing_tool_dependency in missing_tool_dependencies: + all_missing_tool_dependencies.extend( repository.missing_tool_dependencies ) + for missing_tool_dependency in repository.missing_tool_dependencies: print 'Tool dependency %s version %s has status %s.' % \ ( missing_tool_dependency.name, missing_tool_dependency.version, missing_tool_dependency.status ) for repository_dependency in repository.repository_dependencies: - if repository_dependency.includes_tool_dependencies: - missing_tool_dependencies.extend( get_missing_tool_dependencies( repository_dependency ) ) - return missing_tool_dependencies + if repository_dependency.missing_tool_dependencies: + all_missing_tool_dependencies.extend( get_missing_tool_dependencies( repository_dependency, + all_missing_tool_dependencies ) ) + return all_missing_tool_dependencies def get_repositories_to_install( tool_shed_url, test_framework ): """ @@ -950,29 +956,23 @@ repository_identifier_tup, install_and_test_statistics_dict, tool_test_results_dict ) - response_dict = save_test_results_for_changeset_revision( galaxy_tool_shed_url, - tool_test_results_dicts, - tool_test_results_dict, - repository_dependencies_dict, - params, - can_update_tool_shed ) - print 'Result of inserting tool_test_results for revision %s of repository %s owned by %s:\n%s' % \ - ( changeset_revision, name, owner, str( response_dict ) ) - print'\n=============================================================' + save_test_results_for_changeset_revision( galaxy_tool_shed_url, + tool_test_results_dicts, + tool_test_results_dict, + repository_dependencies_dict, + params, + can_update_tool_shed ) else: # The required repository's installation failed. tool_test_results_dict[ 'installation_errors' ][ 'current_repository' ] = str( required_repository.error_message ) params = dict( test_install_error=True, do_not_test=False ) - response_dict = save_test_results_for_changeset_revision( galaxy_tool_shed_url, - tool_test_results_dicts, - tool_test_results_dict, - repository_dependencies_dict, - params, - can_update_tool_shed ) - print 'Result of inserting tool_test_results for revision %s of repository %s owned by %s:\n%s' % \ - ( changeset_revision, name, owner, str( response_dict ) ) - print'\n=============================================================' + save_test_results_for_changeset_revision( galaxy_tool_shed_url, + tool_test_results_dicts, + tool_test_results_dict, + repository_dependencies_dict, + params, + can_update_tool_shed ) else: print 'Cannot retrieve revision %s of required repository %s owned by %s from the database ' % \ ( changeset_revision, name, owner ) @@ -1059,26 +1059,26 @@ changeset_revision = repository_dict.get( 'changeset_revision', None ) if name is None or owner is None or changeset_revision is None: print 'Entries for name, owner or changeset_revision missing from repository_dict %s' % repository_dict - return {} - name = str( name ) - owner = str( owner ) - changeset_revision = str( changeset_revision ) - print '\n=============================================================' - print 'Inserting the following into tool_test_results for revision %s of repository %s owned by %s:\n%s' % \ - ( changeset_revision, name, owner, str( tool_test_results_dict ) ) - print 'Updating tool_test_results for repository_metadata id %s.' % metadata_revision_id - tool_test_results_dicts.insert( 0, tool_test_results_dict ) - params[ 'tool_test_results' ] = tool_test_results_dicts - # Set the time_last_tested entry so that the repository_metadata.time_last_tested will be set in the tool shed. - params[ 'time_last_tested' ] = 'This entry will result in this value being set via the Tool Shed API.' - url = '%s' % ( suc.url_join( galaxy_tool_shed_url,'api', 'repository_revisions', str( metadata_revision_id ) ) ) - print 'url: ', url - print 'params: ', params - try: - return update( tool_shed_api_key, url, params, return_formatted=False ) - except Exception, e: - log.exception( 'Error updating tool_test_results for repository_metadata id %s:\n%s' % \ - ( str( metadata_revision_id ), str( e ) ) ) - return {} - else: - return {} + else: + name = str( name ) + owner = str( owner ) + changeset_revision = str( changeset_revision ) + print '\n=============================================================\n' + print 'Inserting the following into tool_test_results for revision %s of repository %s owned by %s:\n%s' % \ + ( changeset_revision, name, owner, str( tool_test_results_dict ) ) + print 'Updating tool_test_results for repository_metadata id %s.' % metadata_revision_id + tool_test_results_dicts.insert( 0, tool_test_results_dict ) + params[ 'tool_test_results' ] = tool_test_results_dicts + # Set the time_last_tested entry so that the repository_metadata.time_last_tested will be set in the tool shed. + params[ 'time_last_tested' ] = 'This entry will result in this value being set via the Tool Shed API.' + url = '%s' % ( suc.url_join( galaxy_tool_shed_url,'api', 'repository_revisions', str( metadata_revision_id ) ) ) + print 'url: ', url + print 'params: ', params + try: + response_from_update = update( tool_shed_api_key, url, params, return_formatted=False ) + print 'Result of inserting tool_test_results for revision %s of repository %s owned by %s:\n%s' % \ + ( changeset_revision, name, owner, str( response_from_update ) ) + print '\n=============================================================\n' + except Exception, e: + log.exception( 'Error updating tool_test_results for repository_metadata id %s:\n%s' % \ + ( str( metadata_revision_id ), str( e ) ) ) diff -r aea2ff5acd6805ad10db0442cc159f7e4e67a541 -r f957eec387a07f5dc7acceff2124a8ef2edac6f8 test/install_and_test_tool_shed_repositories/repositories_with_tools/functional_tests.py --- a/test/install_and_test_tool_shed_repositories/repositories_with_tools/functional_tests.py +++ b/test/install_and_test_tool_shed_repositories/repositories_with_tools/functional_tests.py @@ -195,16 +195,12 @@ # If this repository is being skipped, register the reason. tool_test_results_dict[ 'not_tested' ] = dict( reason=reason ) params = dict( do_not_test=False ) - response_dict = \ - install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, - tool_test_results_dicts, - tool_test_results_dict, - repository_dict, - params, - can_update_tool_shed ) - print 'Result of inserting tool_test_results for revision %s of repository %s owned by %s:\n%s' % \ - ( changeset_revision, name, owner, str( response_dict ) ) - print '=============================================================' + install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, + tool_test_results_dicts, + tool_test_results_dict, + repository_dict, + params, + can_update_tool_shed ) else: # See if the repository was installed in a previous test. repository = install_and_test_base_util.get_repository( name, owner, changeset_revision ) @@ -223,16 +219,12 @@ tool_test_results_dict[ 'installation_errors' ][ 'current_repository' ] = error_message params = dict( test_install_error=True, do_not_test=False ) - response_dict = \ - install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, - tool_test_results_dicts, - tool_test_results_dict, - repository_dict, - params, - can_update_tool_shed ) - print 'Result of inserting tool_test_results for revision %s of repository %s owned by %s:\n%s' % \ - ( changeset_revision, name, owner, str( response_dict ) ) - print '=============================================================' + install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, + tool_test_results_dicts, + tool_test_results_dict, + repository_dict, + params, + can_update_tool_shed ) else: # The repository was successfully installed. print 'Installation succeeded for revision %s of repository %s owned by %s.' % \ @@ -243,6 +235,9 @@ # missing test components. if 'missing_test_components' not in tool_test_results_dict: tool_test_results_dict[ 'missing_test_components' ] = [] + # Hopefully we'll be able to run functional tests defined for tools contained in the repository - we'll + # assume so as the default. + can_run_functional_tests = True # Populate the installation containers (success and error) for the repository's immediate dependencies # (the entire dependency tree is not handled here). params, install_and_test_statistics_dict, tool_test_results_dict = \ @@ -254,16 +249,18 @@ if params.get( 'test_install_error', False ): # The repository was successfully installed, but one or more dependencies had installation errors, # so we'll populate the test result containers since we cannot execute any tests. - response_dict = \ - install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, - tool_test_results_dicts, - tool_test_results_dict, - repository_dict, - params, - can_update_tool_shed ) - print 'Result of inserting tool_test_results for revision %s of repository %s owned by %s:\n%s' % \ - ( changeset_revision, name, owner, str( response_dict ) ) - print'\n=============================================================' + install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, + tool_test_results_dicts, + tool_test_results_dict, + repository_dict, + params, + can_update_tool_shed ) + # We cannot run functional tests for contained tools due to dependency installation errors. + print 'Cannot execute tests for tools in revision %s of repository %s owned by %s ' % \ + ( changeset_revision, name, owner ) + print 'because one or more dependencies has installation errors.' + can_run_functional_tests = False + remove_tests( app ) # Populate the installation containers (success or error) for the repository's immediate repository # dependencies whose containers are not yet populated. install_and_test_base_util.populate_install_containers_for_repository_dependencies( app, @@ -271,63 +268,67 @@ encoded_repository_metadata_id, install_and_test_statistics_dict, can_update_tool_shed ) - # Execute the contained tool's functional tests only if the repository's entire dependency - # tree is successfully installed. - missing_repository_dependencies = install_and_test_base_util.get_missing_repository_dependencies( repository ) - missing_tool_dependencies = install_and_test_base_util.get_missing_tool_dependencies( repository ) - if missing_repository_dependencies or missing_tool_dependencies: - print 'Cannot execute tests for tools in revision %s of repository %s owned by %s ' % \ - ( changeset_revision, name, owner ) - print 'because one or more dependencies has installation errors.' - # The repository was installed successfully, but one or more dependencies had installation errors. Since - # we cannot test the tools due to these errors, we'll remove tests and tools were created during the repository - # installation process so nose will not discover them and attempt to execute them. - remove_tests( app ) - else: - print 'Revision %s of repository %s owned by %s installed successfully, so running tool tests.' % \ - ( changeset_revision, name, owner ) - # Generate the shed_tools_dict that specifies the location of test data contained within this repository. - # and configure and run functional tests for this repository. This is equivalent to - # sh run_functional_tests.sh -installed - file( galaxy_shed_tools_dict, 'w' ).write( to_json_string( {} ) ) - # Find the path to the test-data directory within the installed repository. - has_test_data, shed_tools_dict = \ - parse_tool_panel_config( galaxy_shed_tool_conf_file, - from_json_string( file( galaxy_shed_tools_dict, 'r' ).read() ) ) - # If the repository has a test-data directory we write the generated shed_tools_dict to a temporary - # file so the functional test framework can find it. - # TODO: Eliminate the need for this shed_tools_dict since it grows large over the course of each test run. - # If it cannot be eliminated altogether, reinitialize it with each new repository install so at this point - # it contains only entries for the current repository dependency hierarchy being tested. - file( galaxy_shed_tools_dict, 'w' ).write( to_json_string( shed_tools_dict ) ) - print 'Saved generated shed_tools_dict to %s\nContents: %s' % ( galaxy_shed_tools_dict, shed_tools_dict ) - try: - install_and_test_statistics_dict = test_repository_tools( app, - repository, - repository_dict, - tool_test_results_dicts, - tool_test_results_dict, - install_and_test_statistics_dict ) - except Exception, e: - exception_message = 'Error executing tests for repository %s: %s' % ( name, str( e ) ) - log.exception( exception_message ) - tool_test_results_dict[ 'failed_tests' ].append( exception_message ) - processed_at_least_one_test_failed = \ - install_and_test_statistics_dict.get( 'at_least_one_test_failed', [] ) - if repository_identifier_tup not in processed_at_least_one_test_failed: - install_and_test_statistics_dict[ 'at_least_one_test_failed' ].append( repository_identifier_tup ) - # Record the status of this repository in the tool shed. - params[ 'tools_functionally_correct' ] = False - response_dict = \ + if can_run_functional_tests: + # Execute the contained tool's functional tests only if the repository's entire dependency + # tree is successfully installed. The following checks should discover missing dependencies + # at any level of the dependency hierarchy. + missing_repository_dependencies = \ + install_and_test_base_util.get_missing_repository_dependencies( repository, + all_missing_repository_dependencies=None ) + print 'Missing repository dependencies:\n%s' % str( missing_repository_dependencies ) + missing_tool_dependencies = \ + install_and_test_base_util.get_missing_tool_dependencies( repository, + all_missing_tool_dependencies=None ) + print 'Missing tool dependencies:\n%s' % str( missing_tool_dependencies ) + if missing_repository_dependencies or missing_tool_dependencies: + print 'Cannot execute tests for tools in revision %s of repository %s owned by %s ' % \ + ( changeset_revision, name, owner ) + print 'because one or more dependencies has installation errors.' + # The repository was installed successfully, but one or more dependencies had installation errors. Since + # we cannot test the tools due to these errors, we'll remove tests and tools were created during the repository + # installation process so nose will not discover them and attempt to execute them. + remove_tests( app ) + else: + print 'Revision %s of repository %s owned by %s installed successfully, so running tool tests.' % \ + ( changeset_revision, name, owner ) + # Generate the shed_tools_dict that specifies the location of test data contained within this repository. + # and configure and run functional tests for this repository. This is equivalent to + # sh run_functional_tests.sh -installed + file( galaxy_shed_tools_dict, 'w' ).write( to_json_string( {} ) ) + # Find the path to the test-data directory within the installed repository. + has_test_data, shed_tools_dict = \ + parse_tool_panel_config( galaxy_shed_tool_conf_file, + from_json_string( file( galaxy_shed_tools_dict, 'r' ).read() ) ) + # If the repository has a test-data directory we write the generated shed_tools_dict to a temporary + # file so the functional test framework can find it. + # TODO: Eliminate the need for this shed_tools_dict since it grows large over the course of each test run. + # If it cannot be eliminated altogether, reinitialize it with each new repository install so at this point + # it contains only entries for the current repository dependency hierarchy being tested. + file( galaxy_shed_tools_dict, 'w' ).write( to_json_string( shed_tools_dict ) ) + print 'Saved generated shed_tools_dict to %s\nContents: %s' % ( galaxy_shed_tools_dict, shed_tools_dict ) + try: + install_and_test_statistics_dict = test_repository_tools( app, + repository, + repository_dict, + tool_test_results_dicts, + tool_test_results_dict, + install_and_test_statistics_dict ) + except Exception, e: + exception_message = 'Error executing tests for repository %s: %s' % ( name, str( e ) ) + log.exception( exception_message ) + tool_test_results_dict[ 'failed_tests' ].append( exception_message ) + processed_at_least_one_test_failed = \ + install_and_test_statistics_dict.get( 'at_least_one_test_failed', [] ) + if repository_identifier_tup not in processed_at_least_one_test_failed: + install_and_test_statistics_dict[ 'at_least_one_test_failed' ].append( repository_identifier_tup ) + # Record the status of this repository in the tool shed. + params[ 'tools_functionally_correct' ] = False install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, tool_test_results_dicts, tool_test_results_dict, repository_dict, params, can_update_tool_shed ) - print 'Result of inserting tool_test_results for revision %s of repository %s owned by %s:\n%s' % \ - ( changeset_revision, name, owner, str( response_dict ) ) - print '=============================================================' else: print 'Skipped attempt to install revision %s of repository %s owned by %s because ' % \ ( changeset_revision, name, owner ) @@ -663,16 +664,12 @@ # Call the save_test_results_for_changeset_revision() method to execute a PUT request to the # repository_revisions API controller with the status of the test. This also sets the do_not_test # and tools_functionally correct flags and updates the time_last_tested field to today's date. - response_dict = \ - install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, - tool_test_results_dicts, - tool_test_results_dict, - repository_dict, - params, - can_update_tool_shed ) - print 'Result of inserting tool_test_results for revision %s of repository %s owned by %s:\n%s' % \ - ( changeset_revision, name, owner, str( response_dict ) ) - print '=============================================================' + install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, + tool_test_results_dicts, + tool_test_results_dict, + repository_dict, + params, + can_update_tool_shed ) else: # The get_failed_test_dicts() method returns a list. print 'Revision %s of repository %s owned by %s installed successfully but did not pass functional tests.' % \ @@ -695,16 +692,12 @@ params = dict( tools_functionally_correct=False, test_install_error=False, do_not_test=set_do_not_test ) - response_dict = \ - install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, - tool_test_results_dicts, - tool_test_results_dict, - repository_dict, - params, - can_update_tool_shed ) - print 'Result of inserting tool_test_results for revision %s of repository %s owned by %s:\n%s' % \ - ( changeset_revision, name, owner, str( response_dict ) ) - print '=============================================================' + install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, + tool_test_results_dicts, + tool_test_results_dict, + repository_dict, + params, + can_update_tool_shed ) # Remove the just-executed tests so twill will not find and re-test them along with the tools # contained in the next repository. remove_tests( app ) diff -r aea2ff5acd6805ad10db0442cc159f7e4e67a541 -r f957eec387a07f5dc7acceff2124a8ef2edac6f8 test/install_and_test_tool_shed_repositories/tool_dependency_definitions/functional_tests.py --- a/test/install_and_test_tool_shed_repositories/tool_dependency_definitions/functional_tests.py +++ b/test/install_and_test_tool_shed_repositories/tool_dependency_definitions/functional_tests.py @@ -129,16 +129,12 @@ ( changeset_revision, name, owner ) tool_test_results_dict[ 'not_tested' ] = dict( reason=reason ) params = dict( do_not_test=False ) - response_dict = \ - install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, - tool_test_results_dicts, - tool_test_results_dict, - repository_dict, - params, - can_update_tool_shed ) - print 'Result of inserting tool_test_results for revision %s of repository %s owned by %s:\n%s' % \ - ( changeset_revision, name, owner, str( response_dict ) ) - print '=============================================================' + install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, + tool_test_results_dicts, + tool_test_results_dict, + repository_dict, + params, + can_update_tool_shed ) else: # See if the repository was installed in a previous test. repository = install_and_test_base_util.get_repository( name, owner, changeset_revision ) @@ -157,16 +153,12 @@ tool_test_results_dict[ 'installation_errors' ][ 'current_repository' ] = error_message params = dict( test_install_error=True, do_not_test=False ) - response_dict = \ - install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, - tool_test_results_dicts, - tool_test_results_dict, - repository_dict, - params, - can_update_tool_shed ) - print 'Result of inserting tool_test_results for revision %s of repository %s owned by %s:\n%s' % \ - ( changeset_revision, name, owner, str( response_dict ) ) - print '=============================================================' + install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, + tool_test_results_dicts, + tool_test_results_dict, + repository_dict, + params, + can_update_tool_shed ) else: # The repository was successfully installed. print 'Installation succeeded for revision %s of repository %s owned by %s.' % \ @@ -179,16 +171,12 @@ repository_identifier_tup, install_and_test_statistics_dict, tool_test_results_dict ) - response_dict = \ - install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, - tool_test_results_dicts, - tool_test_results_dict, - repository_dict, - params, - can_update_tool_shed ) - print 'Result of inserting tool_test_results for revision %s of repository %s owned by %s:\n%s' % \ - ( changeset_revision, name, owner, str( response_dict ) ) - print '=============================================================' + install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, + tool_test_results_dicts, + tool_test_results_dict, + repository_dict, + params, + can_update_tool_shed ) # Populate the installation containers (success or error) for the repository's immediate repository # dependencies whose containers are not yet populated. install_and_test_base_util.populate_install_containers_for_repository_dependencies( app, https://bitbucket.org/galaxy/galaxy-central/commits/1c14b0cdba15/ Changeset: 1c14b0cdba15 User: greg Date: 2014-02-10 17:34:23 Summary: merged from next-stable Affected #: 3 files diff -r 7ca065784d58e7aa77e5092952eacd963853df65 -r 1c14b0cdba15d8ffc2474a82aa3ca535e728f941 test/install_and_test_tool_shed_repositories/base/util.py --- a/test/install_and_test_tool_shed_repositories/base/util.py +++ b/test/install_and_test_tool_shed_repositories/base/util.py @@ -285,15 +285,17 @@ break return version -def get_missing_repository_dependencies( repository ): +def get_missing_repository_dependencies( repository, all_missing_repository_dependencies=None ): """ Return the entire list of missing repository dependencies for the received repository. The entire dependency tree will be inspected. """ + if all_missing_repository_dependencies is None: + all_missing_repository_dependencies = [] print 'Checking revision %s of repository %s owned by %s for missing repository dependencies.' % \ ( repository.changeset_revision, repository.name, repository.owner ) - missing_repository_dependencies = repository.missing_repository_dependencies - for missing_required_repository in missing_repository_dependencies: + all_missing_repository_dependencies.extend( repository.missing_repository_dependencies ) + for missing_required_repository in repository.missing_repository_dependencies: print 'Revision %s of required repository %s owned by %s has status %s.' % \ ( missing_required_repository.changeset_revision, missing_required_repository.name, @@ -301,24 +303,28 @@ missing_required_repository.status ) for repository_dependency in repository.repository_dependencies: if repository_dependency.missing_repository_dependencies: - missing_repository_dependencies.extend( get_missing_repository_dependencies( repository_dependency ) ) - return missing_repository_dependencies + all_missing_repository_dependencies.extend( get_missing_repository_dependencies( repository_dependency, + all_missing_repository_dependencies ) ) + return all_missing_repository_dependencies -def get_missing_tool_dependencies( repository ): +def get_missing_tool_dependencies( repository, all_missing_tool_dependencies=None ): """ Return the entire list of missing tool dependencies for the received repository. The entire dependency tree will be inspected. """ + if all_missing_tool_dependencies is None: + all_missing_tool_dependencies = [] print 'Checking revision %s of repository %s owned by %s for missing tool dependencies.' % \ ( repository.changeset_revision, repository.name, repository.owner ) - missing_tool_dependencies = repository.missing_tool_dependencies - for missing_tool_dependency in missing_tool_dependencies: + all_missing_tool_dependencies.extend( repository.missing_tool_dependencies ) + for missing_tool_dependency in repository.missing_tool_dependencies: print 'Tool dependency %s version %s has status %s.' % \ ( missing_tool_dependency.name, missing_tool_dependency.version, missing_tool_dependency.status ) for repository_dependency in repository.repository_dependencies: - if repository_dependency.includes_tool_dependencies: - missing_tool_dependencies.extend( get_missing_tool_dependencies( repository_dependency ) ) - return missing_tool_dependencies + if repository_dependency.missing_tool_dependencies: + all_missing_tool_dependencies.extend( get_missing_tool_dependencies( repository_dependency, + all_missing_tool_dependencies ) ) + return all_missing_tool_dependencies def get_repositories_to_install( tool_shed_url, test_framework ): """ @@ -950,29 +956,23 @@ repository_identifier_tup, install_and_test_statistics_dict, tool_test_results_dict ) - response_dict = save_test_results_for_changeset_revision( galaxy_tool_shed_url, - tool_test_results_dicts, - tool_test_results_dict, - repository_dependencies_dict, - params, - can_update_tool_shed ) - print 'Result of inserting tool_test_results for revision %s of repository %s owned by %s:\n%s' % \ - ( changeset_revision, name, owner, str( response_dict ) ) - print'\n=============================================================' + save_test_results_for_changeset_revision( galaxy_tool_shed_url, + tool_test_results_dicts, + tool_test_results_dict, + repository_dependencies_dict, + params, + can_update_tool_shed ) else: # The required repository's installation failed. tool_test_results_dict[ 'installation_errors' ][ 'current_repository' ] = str( required_repository.error_message ) params = dict( test_install_error=True, do_not_test=False ) - response_dict = save_test_results_for_changeset_revision( galaxy_tool_shed_url, - tool_test_results_dicts, - tool_test_results_dict, - repository_dependencies_dict, - params, - can_update_tool_shed ) - print 'Result of inserting tool_test_results for revision %s of repository %s owned by %s:\n%s' % \ - ( changeset_revision, name, owner, str( response_dict ) ) - print'\n=============================================================' + save_test_results_for_changeset_revision( galaxy_tool_shed_url, + tool_test_results_dicts, + tool_test_results_dict, + repository_dependencies_dict, + params, + can_update_tool_shed ) else: print 'Cannot retrieve revision %s of required repository %s owned by %s from the database ' % \ ( changeset_revision, name, owner ) @@ -1059,26 +1059,26 @@ changeset_revision = repository_dict.get( 'changeset_revision', None ) if name is None or owner is None or changeset_revision is None: print 'Entries for name, owner or changeset_revision missing from repository_dict %s' % repository_dict - return {} - name = str( name ) - owner = str( owner ) - changeset_revision = str( changeset_revision ) - print '\n=============================================================' - print 'Inserting the following into tool_test_results for revision %s of repository %s owned by %s:\n%s' % \ - ( changeset_revision, name, owner, str( tool_test_results_dict ) ) - print 'Updating tool_test_results for repository_metadata id %s.' % metadata_revision_id - tool_test_results_dicts.insert( 0, tool_test_results_dict ) - params[ 'tool_test_results' ] = tool_test_results_dicts - # Set the time_last_tested entry so that the repository_metadata.time_last_tested will be set in the tool shed. - params[ 'time_last_tested' ] = 'This entry will result in this value being set via the Tool Shed API.' - url = '%s' % ( suc.url_join( galaxy_tool_shed_url,'api', 'repository_revisions', str( metadata_revision_id ) ) ) - print 'url: ', url - print 'params: ', params - try: - return update( tool_shed_api_key, url, params, return_formatted=False ) - except Exception, e: - log.exception( 'Error updating tool_test_results for repository_metadata id %s:\n%s' % \ - ( str( metadata_revision_id ), str( e ) ) ) - return {} - else: - return {} + else: + name = str( name ) + owner = str( owner ) + changeset_revision = str( changeset_revision ) + print '\n=============================================================\n' + print 'Inserting the following into tool_test_results for revision %s of repository %s owned by %s:\n%s' % \ + ( changeset_revision, name, owner, str( tool_test_results_dict ) ) + print 'Updating tool_test_results for repository_metadata id %s.' % metadata_revision_id + tool_test_results_dicts.insert( 0, tool_test_results_dict ) + params[ 'tool_test_results' ] = tool_test_results_dicts + # Set the time_last_tested entry so that the repository_metadata.time_last_tested will be set in the tool shed. + params[ 'time_last_tested' ] = 'This entry will result in this value being set via the Tool Shed API.' + url = '%s' % ( suc.url_join( galaxy_tool_shed_url,'api', 'repository_revisions', str( metadata_revision_id ) ) ) + print 'url: ', url + print 'params: ', params + try: + response_from_update = update( tool_shed_api_key, url, params, return_formatted=False ) + print 'Result of inserting tool_test_results for revision %s of repository %s owned by %s:\n%s' % \ + ( changeset_revision, name, owner, str( response_from_update ) ) + print '\n=============================================================\n' + except Exception, e: + log.exception( 'Error updating tool_test_results for repository_metadata id %s:\n%s' % \ + ( str( metadata_revision_id ), str( e ) ) ) diff -r 7ca065784d58e7aa77e5092952eacd963853df65 -r 1c14b0cdba15d8ffc2474a82aa3ca535e728f941 test/install_and_test_tool_shed_repositories/repositories_with_tools/functional_tests.py --- a/test/install_and_test_tool_shed_repositories/repositories_with_tools/functional_tests.py +++ b/test/install_and_test_tool_shed_repositories/repositories_with_tools/functional_tests.py @@ -195,16 +195,12 @@ # If this repository is being skipped, register the reason. tool_test_results_dict[ 'not_tested' ] = dict( reason=reason ) params = dict( do_not_test=False ) - response_dict = \ - install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, - tool_test_results_dicts, - tool_test_results_dict, - repository_dict, - params, - can_update_tool_shed ) - print 'Result of inserting tool_test_results for revision %s of repository %s owned by %s:\n%s' % \ - ( changeset_revision, name, owner, str( response_dict ) ) - print '=============================================================' + install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, + tool_test_results_dicts, + tool_test_results_dict, + repository_dict, + params, + can_update_tool_shed ) else: # See if the repository was installed in a previous test. repository = install_and_test_base_util.get_repository( name, owner, changeset_revision ) @@ -223,16 +219,12 @@ tool_test_results_dict[ 'installation_errors' ][ 'current_repository' ] = error_message params = dict( test_install_error=True, do_not_test=False ) - response_dict = \ - install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, - tool_test_results_dicts, - tool_test_results_dict, - repository_dict, - params, - can_update_tool_shed ) - print 'Result of inserting tool_test_results for revision %s of repository %s owned by %s:\n%s' % \ - ( changeset_revision, name, owner, str( response_dict ) ) - print '=============================================================' + install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, + tool_test_results_dicts, + tool_test_results_dict, + repository_dict, + params, + can_update_tool_shed ) else: # The repository was successfully installed. print 'Installation succeeded for revision %s of repository %s owned by %s.' % \ @@ -243,6 +235,9 @@ # missing test components. if 'missing_test_components' not in tool_test_results_dict: tool_test_results_dict[ 'missing_test_components' ] = [] + # Hopefully we'll be able to run functional tests defined for tools contained in the repository - we'll + # assume so as the default. + can_run_functional_tests = True # Populate the installation containers (success and error) for the repository's immediate dependencies # (the entire dependency tree is not handled here). params, install_and_test_statistics_dict, tool_test_results_dict = \ @@ -254,16 +249,18 @@ if params.get( 'test_install_error', False ): # The repository was successfully installed, but one or more dependencies had installation errors, # so we'll populate the test result containers since we cannot execute any tests. - response_dict = \ - install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, - tool_test_results_dicts, - tool_test_results_dict, - repository_dict, - params, - can_update_tool_shed ) - print 'Result of inserting tool_test_results for revision %s of repository %s owned by %s:\n%s' % \ - ( changeset_revision, name, owner, str( response_dict ) ) - print'\n=============================================================' + install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, + tool_test_results_dicts, + tool_test_results_dict, + repository_dict, + params, + can_update_tool_shed ) + # We cannot run functional tests for contained tools due to dependency installation errors. + print 'Cannot execute tests for tools in revision %s of repository %s owned by %s ' % \ + ( changeset_revision, name, owner ) + print 'because one or more dependencies has installation errors.' + can_run_functional_tests = False + remove_tests( app ) # Populate the installation containers (success or error) for the repository's immediate repository # dependencies whose containers are not yet populated. install_and_test_base_util.populate_install_containers_for_repository_dependencies( app, @@ -271,63 +268,67 @@ encoded_repository_metadata_id, install_and_test_statistics_dict, can_update_tool_shed ) - # Execute the contained tool's functional tests only if the repository's entire dependency - # tree is successfully installed. - missing_repository_dependencies = install_and_test_base_util.get_missing_repository_dependencies( repository ) - missing_tool_dependencies = install_and_test_base_util.get_missing_tool_dependencies( repository ) - if missing_repository_dependencies or missing_tool_dependencies: - print 'Cannot execute tests for tools in revision %s of repository %s owned by %s ' % \ - ( changeset_revision, name, owner ) - print 'because one or more dependencies has installation errors.' - # The repository was installed successfully, but one or more dependencies had installation errors. Since - # we cannot test the tools due to these errors, we'll remove tests and tools were created during the repository - # installation process so nose will not discover them and attempt to execute them. - remove_tests( app ) - else: - print 'Revision %s of repository %s owned by %s installed successfully, so running tool tests.' % \ - ( changeset_revision, name, owner ) - # Generate the shed_tools_dict that specifies the location of test data contained within this repository. - # and configure and run functional tests for this repository. This is equivalent to - # sh run_functional_tests.sh -installed - file( galaxy_shed_tools_dict, 'w' ).write( to_json_string( {} ) ) - # Find the path to the test-data directory within the installed repository. - has_test_data, shed_tools_dict = \ - parse_tool_panel_config( galaxy_shed_tool_conf_file, - from_json_string( file( galaxy_shed_tools_dict, 'r' ).read() ) ) - # If the repository has a test-data directory we write the generated shed_tools_dict to a temporary - # file so the functional test framework can find it. - # TODO: Eliminate the need for this shed_tools_dict since it grows large over the course of each test run. - # If it cannot be eliminated altogether, reinitialize it with each new repository install so at this point - # it contains only entries for the current repository dependency hierarchy being tested. - file( galaxy_shed_tools_dict, 'w' ).write( to_json_string( shed_tools_dict ) ) - print 'Saved generated shed_tools_dict to %s\nContents: %s' % ( galaxy_shed_tools_dict, shed_tools_dict ) - try: - install_and_test_statistics_dict = test_repository_tools( app, - repository, - repository_dict, - tool_test_results_dicts, - tool_test_results_dict, - install_and_test_statistics_dict ) - except Exception, e: - exception_message = 'Error executing tests for repository %s: %s' % ( name, str( e ) ) - log.exception( exception_message ) - tool_test_results_dict[ 'failed_tests' ].append( exception_message ) - processed_at_least_one_test_failed = \ - install_and_test_statistics_dict.get( 'at_least_one_test_failed', [] ) - if repository_identifier_tup not in processed_at_least_one_test_failed: - install_and_test_statistics_dict[ 'at_least_one_test_failed' ].append( repository_identifier_tup ) - # Record the status of this repository in the tool shed. - params[ 'tools_functionally_correct' ] = False - response_dict = \ + if can_run_functional_tests: + # Execute the contained tool's functional tests only if the repository's entire dependency + # tree is successfully installed. The following checks should discover missing dependencies + # at any level of the dependency hierarchy. + missing_repository_dependencies = \ + install_and_test_base_util.get_missing_repository_dependencies( repository, + all_missing_repository_dependencies=None ) + print 'Missing repository dependencies:\n%s' % str( missing_repository_dependencies ) + missing_tool_dependencies = \ + install_and_test_base_util.get_missing_tool_dependencies( repository, + all_missing_tool_dependencies=None ) + print 'Missing tool dependencies:\n%s' % str( missing_tool_dependencies ) + if missing_repository_dependencies or missing_tool_dependencies: + print 'Cannot execute tests for tools in revision %s of repository %s owned by %s ' % \ + ( changeset_revision, name, owner ) + print 'because one or more dependencies has installation errors.' + # The repository was installed successfully, but one or more dependencies had installation errors. Since + # we cannot test the tools due to these errors, we'll remove tests and tools were created during the repository + # installation process so nose will not discover them and attempt to execute them. + remove_tests( app ) + else: + print 'Revision %s of repository %s owned by %s installed successfully, so running tool tests.' % \ + ( changeset_revision, name, owner ) + # Generate the shed_tools_dict that specifies the location of test data contained within this repository. + # and configure and run functional tests for this repository. This is equivalent to + # sh run_functional_tests.sh -installed + file( galaxy_shed_tools_dict, 'w' ).write( to_json_string( {} ) ) + # Find the path to the test-data directory within the installed repository. + has_test_data, shed_tools_dict = \ + parse_tool_panel_config( galaxy_shed_tool_conf_file, + from_json_string( file( galaxy_shed_tools_dict, 'r' ).read() ) ) + # If the repository has a test-data directory we write the generated shed_tools_dict to a temporary + # file so the functional test framework can find it. + # TODO: Eliminate the need for this shed_tools_dict since it grows large over the course of each test run. + # If it cannot be eliminated altogether, reinitialize it with each new repository install so at this point + # it contains only entries for the current repository dependency hierarchy being tested. + file( galaxy_shed_tools_dict, 'w' ).write( to_json_string( shed_tools_dict ) ) + print 'Saved generated shed_tools_dict to %s\nContents: %s' % ( galaxy_shed_tools_dict, shed_tools_dict ) + try: + install_and_test_statistics_dict = test_repository_tools( app, + repository, + repository_dict, + tool_test_results_dicts, + tool_test_results_dict, + install_and_test_statistics_dict ) + except Exception, e: + exception_message = 'Error executing tests for repository %s: %s' % ( name, str( e ) ) + log.exception( exception_message ) + tool_test_results_dict[ 'failed_tests' ].append( exception_message ) + processed_at_least_one_test_failed = \ + install_and_test_statistics_dict.get( 'at_least_one_test_failed', [] ) + if repository_identifier_tup not in processed_at_least_one_test_failed: + install_and_test_statistics_dict[ 'at_least_one_test_failed' ].append( repository_identifier_tup ) + # Record the status of this repository in the tool shed. + params[ 'tools_functionally_correct' ] = False install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, tool_test_results_dicts, tool_test_results_dict, repository_dict, params, can_update_tool_shed ) - print 'Result of inserting tool_test_results for revision %s of repository %s owned by %s:\n%s' % \ - ( changeset_revision, name, owner, str( response_dict ) ) - print '=============================================================' else: print 'Skipped attempt to install revision %s of repository %s owned by %s because ' % \ ( changeset_revision, name, owner ) @@ -663,16 +664,12 @@ # Call the save_test_results_for_changeset_revision() method to execute a PUT request to the # repository_revisions API controller with the status of the test. This also sets the do_not_test # and tools_functionally correct flags and updates the time_last_tested field to today's date. - response_dict = \ - install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, - tool_test_results_dicts, - tool_test_results_dict, - repository_dict, - params, - can_update_tool_shed ) - print 'Result of inserting tool_test_results for revision %s of repository %s owned by %s:\n%s' % \ - ( changeset_revision, name, owner, str( response_dict ) ) - print '=============================================================' + install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, + tool_test_results_dicts, + tool_test_results_dict, + repository_dict, + params, + can_update_tool_shed ) else: # The get_failed_test_dicts() method returns a list. print 'Revision %s of repository %s owned by %s installed successfully but did not pass functional tests.' % \ @@ -695,16 +692,12 @@ params = dict( tools_functionally_correct=False, test_install_error=False, do_not_test=set_do_not_test ) - response_dict = \ - install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, - tool_test_results_dicts, - tool_test_results_dict, - repository_dict, - params, - can_update_tool_shed ) - print 'Result of inserting tool_test_results for revision %s of repository %s owned by %s:\n%s' % \ - ( changeset_revision, name, owner, str( response_dict ) ) - print '=============================================================' + install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, + tool_test_results_dicts, + tool_test_results_dict, + repository_dict, + params, + can_update_tool_shed ) # Remove the just-executed tests so twill will not find and re-test them along with the tools # contained in the next repository. remove_tests( app ) diff -r 7ca065784d58e7aa77e5092952eacd963853df65 -r 1c14b0cdba15d8ffc2474a82aa3ca535e728f941 test/install_and_test_tool_shed_repositories/tool_dependency_definitions/functional_tests.py --- a/test/install_and_test_tool_shed_repositories/tool_dependency_definitions/functional_tests.py +++ b/test/install_and_test_tool_shed_repositories/tool_dependency_definitions/functional_tests.py @@ -129,16 +129,12 @@ ( changeset_revision, name, owner ) tool_test_results_dict[ 'not_tested' ] = dict( reason=reason ) params = dict( do_not_test=False ) - response_dict = \ - install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, - tool_test_results_dicts, - tool_test_results_dict, - repository_dict, - params, - can_update_tool_shed ) - print 'Result of inserting tool_test_results for revision %s of repository %s owned by %s:\n%s' % \ - ( changeset_revision, name, owner, str( response_dict ) ) - print '=============================================================' + install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, + tool_test_results_dicts, + tool_test_results_dict, + repository_dict, + params, + can_update_tool_shed ) else: # See if the repository was installed in a previous test. repository = install_and_test_base_util.get_repository( name, owner, changeset_revision ) @@ -157,16 +153,12 @@ tool_test_results_dict[ 'installation_errors' ][ 'current_repository' ] = error_message params = dict( test_install_error=True, do_not_test=False ) - response_dict = \ - install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, - tool_test_results_dicts, - tool_test_results_dict, - repository_dict, - params, - can_update_tool_shed ) - print 'Result of inserting tool_test_results for revision %s of repository %s owned by %s:\n%s' % \ - ( changeset_revision, name, owner, str( response_dict ) ) - print '=============================================================' + install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, + tool_test_results_dicts, + tool_test_results_dict, + repository_dict, + params, + can_update_tool_shed ) else: # The repository was successfully installed. print 'Installation succeeded for revision %s of repository %s owned by %s.' % \ @@ -179,16 +171,12 @@ repository_identifier_tup, install_and_test_statistics_dict, tool_test_results_dict ) - response_dict = \ - install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, - tool_test_results_dicts, - tool_test_results_dict, - repository_dict, - params, - can_update_tool_shed ) - print 'Result of inserting tool_test_results for revision %s of repository %s owned by %s:\n%s' % \ - ( changeset_revision, name, owner, str( response_dict ) ) - print '=============================================================' + install_and_test_base_util.save_test_results_for_changeset_revision( install_and_test_base_util.galaxy_tool_shed_url, + tool_test_results_dicts, + tool_test_results_dict, + repository_dict, + params, + can_update_tool_shed ) # Populate the installation containers (success or error) for the repository's immediate repository # dependencies whose containers are not yet populated. install_and_test_base_util.populate_install_containers_for_repository_dependencies( app, 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.