def install_and_test_repositories(app, galaxy_shed_tools_dict_file, galaxy_shed_tool_conf_file, galaxy_shed_tool_path): # Initialize a dictionary for the summary that will be printed to stdout. install_and_test_statistics_dict = install_and_test_base_util.initialize_install_and_test_statistics_dict( ) error_message = '' repositories_to_install, error_message = \ install_and_test_base_util.get_repositories_to_install( install_and_test_base_util.galaxy_tool_shed_url, test_framework ) if error_message: return None, error_message print 'The exclude list file is defined as %s' % exclude_list_file if os.path.exists(exclude_list_file): print 'Loading the list of repositories excluded from testing from the file %s...' % exclude_list_file # The following exclude_list will look something like this: # [{ 'reason': The default reason or the reason specified in this section, # 'repositories': [( name, owner, changeset_revision if changeset_revision else None ), # ( name, owner, changeset_revision if changeset_revision else None )]}] exclude_list_dicts = install_and_test_base_util.parse_exclude_list( exclude_list_file) else: print 'The exclude list file %s does not exist, so no repositories will be excluded from testing.' % exclude_list_file exclude_list_dicts = [] # Generate a test method that will use Twill to install each repository into the embedded Galaxy application that was # started up, installing repository and tool dependencies. Upon successful installation, generate a test case for each # functional test defined for each tool in the repository and execute the test cases. Record the result of the tests. # The traceback and captured output of the tool that was run will be recored for test failures. After all tests have # completed, the repository is uninstalled, so test cases don't interfere with the next repository's functional tests. for repository_dict in repositories_to_install: encoded_repository_metadata_id = repository_dict.get('id', None) # Add the URL for the tool shed we're installing from, so the automated installation methods go to the right place. repository_dict[ 'tool_shed_url'] = install_and_test_base_util.galaxy_tool_shed_url # Get the name and owner out of the repository info dict. name = str(repository_dict.get('name', '')) owner = str(repository_dict.get('owner', '')) changeset_revision = str(repository_dict.get('changeset_revision', '')) print "Processing revision %s of repository %s owned by %s..." % ( changeset_revision, name, owner) repository_identifier_tup = (name, owner, changeset_revision) install_and_test_statistics_dict['total_repositories_processed'] += 1 # Retrieve the stored list of tool_test_results_dicts. tool_test_results_dicts, error_message = \ install_and_test_base_util.get_tool_test_results_dicts( install_and_test_base_util.galaxy_tool_shed_url, encoded_repository_metadata_id ) if error_message: print 'Cannot install version %s of repository %s owned by %s due to the following error getting tool_test_results:\n%s' % \ ( changeset_revision, name, owner, str( error_message ) ) else: tool_test_results_dict = install_and_test_base_util.get_tool_test_results_dict( tool_test_results_dicts) is_excluded, reason = install_and_test_base_util.is_excluded( exclude_list_dicts, name, owner, changeset_revision, encoded_repository_metadata_id) if is_excluded: # If this repository is being skipped, register the reason. print "Not testing revision %s of repository %s owned by %s because it is in the exclude list for this test run." % \ ( changeset_revision, name, owner ) tool_test_results_dict['not_tested'] = dict(reason=reason) params = dict(do_not_test=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) else: # See if the repository was installed in a previous test. repository = install_and_test_base_util.get_repository( name, owner, changeset_revision) if repository is None: # The repository was not previously installed, so install it now. start_time = time.time() tool_test_results_dict = install_and_test_base_util.initialize_tool_tests_results_dict( app, tool_test_results_dict) repository, error_message = install_and_test_base_util.install_repository( app, repository_dict) if error_message: # The repository installation failed. print 'Installation failed for revision %s of repository %s owned by %s.' % ( changeset_revision, name, owner) processed_repositories_with_installation_error = \ install_and_test_statistics_dict.get( 'repositories_with_installation_error', [] ) if repository_identifier_tup not in processed_repositories_with_installation_error: install_and_test_statistics_dict[ 'repositories_with_installation_error'].append( repository_identifier_tup) current_repository_installation_error_dict = dict( tool_shed=install_and_test_base_util. galaxy_tool_shed_url, name=name, owner=owner, changeset_revision=changeset_revision, error_message=error_message) tool_test_results_dict['installation_errors'][ 'current_repository'].append( current_repository_installation_error_dict) params = dict(test_install_error=True, do_not_test=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) else: # The repository was successfully installed. print 'Installation succeeded for revision %s of repository %s owned by %s.' % \ ( changeset_revision, name, owner ) # 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 = \ install_and_test_base_util.populate_dependency_install_containers( app, repository, repository_identifier_tup, install_and_test_statistics_dict, tool_test_results_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) # 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, encoded_repository_metadata_id, install_and_test_statistics_dict, can_update_tool_shed) print '\nAttempting to install revision %s of repository %s owned by %s took %s seconds.\n' % \ ( changeset_revision, name, owner, str( time.time() - start_time ) ) else: print 'Skipped attempt to install revision %s of repository %s owned by %s because ' % \ ( changeset_revision, name, owner ) print 'it was previously installed and currently has status %s' % repository.status return install_and_test_statistics_dict, error_message
def install_and_test_repositories( app, galaxy_shed_tools_dict_file, galaxy_shed_tool_conf_file, galaxy_shed_tool_path ): # Initialize a dictionary for the summary that will be printed to stdout. install_and_test_statistics_dict = install_and_test_base_util.initialize_install_and_test_statistics_dict() error_message = '' repositories_to_install, error_message = \ install_and_test_base_util.get_repositories_to_install( install_and_test_base_util.galaxy_tool_shed_url, test_framework ) if error_message: return None, error_message print 'The exclude list file is defined as %s' % exclude_list_file if os.path.exists( exclude_list_file ): print 'Loading the list of repositories excluded from testing from the file %s...' % exclude_list_file # The following exclude_list will look something like this: # [{ 'reason': The default reason or the reason specified in this section, # 'repositories': [( name, owner, changeset_revision if changeset_revision else None ), # ( name, owner, changeset_revision if changeset_revision else None )]}] exclude_list_dicts = install_and_test_base_util.parse_exclude_list( exclude_list_file ) else: print 'The exclude list file %s does not exist, so no repositories will be excluded from testing.' % exclude_list_file exclude_list_dicts = [] # Generate a test method that will use Twill to install each repository into the embedded Galaxy application that was # started up, installing repository and tool dependencies. Upon successful installation, generate a test case for each # functional test defined for each tool in the repository and execute the test cases. Record the result of the tests. # The traceback and captured output of the tool that was run will be recored for test failures. After all tests have # completed, the repository is uninstalled, so test cases don't interfere with the next repository's functional tests. for repository_dict in repositories_to_install: encoded_repository_metadata_id = repository_dict.get( 'id', None ) # Add the URL for the tool shed we're installing from, so the automated installation methods go to the right place. repository_dict[ 'tool_shed_url' ] = install_and_test_base_util.galaxy_tool_shed_url # Get the name and owner out of the repository info dict. name = str( repository_dict.get( 'name', '' ) ) owner = str( repository_dict.get( 'owner', '' ) ) changeset_revision = str( repository_dict.get( 'changeset_revision', '' ) ) print "Processing revision %s of repository %s owned by %s..." % ( changeset_revision, name, owner ) repository_identifier_tup = ( name, owner, changeset_revision ) install_and_test_statistics_dict[ 'total_repositories_processed' ] += 1 # Retrieve the stored list of tool_test_results_dicts. tool_test_results_dicts, error_message = \ install_and_test_base_util.get_tool_test_results_dicts( install_and_test_base_util.galaxy_tool_shed_url, encoded_repository_metadata_id ) if error_message: print 'Cannot install version %s of repository %s owned by %s due to the following error getting tool_test_results:\n%s' % \ ( changeset_revision, name, owner, str( error_message ) ) else: tool_test_results_dict = install_and_test_base_util.get_tool_test_results_dict( tool_test_results_dicts ) is_excluded, reason = install_and_test_base_util.is_excluded( exclude_list_dicts, name, owner, changeset_revision, encoded_repository_metadata_id ) if is_excluded: # If this repository is being skipped, register the reason. print "Not testing revision %s of repository %s owned by %s because it is in the exclude list for this test run." % \ ( changeset_revision, name, owner ) tool_test_results_dict[ 'not_tested' ] = dict( reason=reason ) params = dict( do_not_test=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 ) else: # See if the repository was installed in a previous test. repository = install_and_test_base_util.get_repository( name, owner, changeset_revision ) if repository is None: # The repository was not previously installed, so install it now. start_time = time.time() tool_test_results_dict = install_and_test_base_util.initialize_tool_tests_results_dict( app, tool_test_results_dict ) repository, error_message = install_and_test_base_util.install_repository( app, repository_dict ) if error_message: # The repository installation failed. print 'Installation failed for revision %s of repository %s owned by %s.' % ( changeset_revision, name, owner ) processed_repositories_with_installation_error = \ install_and_test_statistics_dict.get( 'repositories_with_installation_error', [] ) if repository_identifier_tup not in processed_repositories_with_installation_error: install_and_test_statistics_dict[ 'repositories_with_installation_error' ].append( repository_identifier_tup ) current_repository_installation_error_dict = dict( tool_shed=install_and_test_base_util.galaxy_tool_shed_url, name=name, owner=owner, changeset_revision=changeset_revision, error_message=error_message ) tool_test_results_dict[ 'installation_errors' ][ 'current_repository' ].append( current_repository_installation_error_dict ) params = dict( test_install_error=True, do_not_test=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 ) else: # The repository was successfully installed. print 'Installation succeeded for revision %s of repository %s owned by %s.' % \ ( changeset_revision, name, owner ) # 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 = \ install_and_test_base_util.populate_dependency_install_containers( app, repository, repository_identifier_tup, install_and_test_statistics_dict, tool_test_results_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 ) # 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, encoded_repository_metadata_id, install_and_test_statistics_dict, can_update_tool_shed ) print '\nAttempting to install revision %s of repository %s owned by %s took %s seconds.\n' % \ ( changeset_revision, name, owner, str( time.time() - start_time ) ) else: print 'Skipped attempt to install revision %s of repository %s owned by %s because ' % \ ( changeset_revision, name, owner ) print 'it was previously installed and currently has status %s' % repository.status return install_and_test_statistics_dict, error_message