Beispiel #1
0
def test_persistence():
    """
    Tests persistence of a managers jobs.
    """
    staging_directory = tempfile.mkdtemp()
    try:
        app = Bunch(
            staging_directory=staging_directory,
            persistence_directory=staging_directory,
            authorizer=get_authorizer(None),
            dependency_manager=TestDependencyManager(),
            job_metrics=Bunch(default_job_instrumenter=NULL_JOB_INSTRUMENTER),
        )
        assert not exists(join(staging_directory, "queued_jobs"))
        queue1 = StatefulManagerProxy(
            QueueManager('test', app, num_concurrent_jobs=0))
        job_id = queue1.setup_job('4', 'tool1', '1.0.0')
        touch_file = join(staging_directory, 'ran')
        queue1.launch(job_id, 'touch %s' % touch_file)
        time.sleep(.4)
        assert (not (exists(touch_file)))
        queue1.shutdown()
        queue2 = StatefulManagerProxy(
            QueueManager('test', app, num_concurrent_jobs=1))
        time.sleep(1)
        assert exists(touch_file)
    finally:
        shutil.rmtree(staging_directory)
        try:
            queue2.shutdown()
        except:
            pass
Beispiel #2
0
def test_persistence():
    """
    Tests persistence of a managers jobs.
    """
    staging_directory = tempfile.mkdtemp()
    try:
        app = Bunch(staging_directory=staging_directory,
                    persistence_directory=staging_directory,
                    authorizer=get_authorizer(None),
                    dependency_manager=TestDependencyManager(),
                    job_metrics=Bunch(default_job_instrumenter=NULL_JOB_INSTRUMENTER),
                    )
        assert not exists(join(staging_directory, "queued_jobs"))
        queue1 = StatefulManagerProxy(QueueManager('test', app, num_concurrent_jobs=0))
        job_id = queue1.setup_job('4', 'tool1', '1.0.0')
        touch_file = join(staging_directory, 'ran')
        queue1.launch(job_id, 'touch %s' % touch_file)
        time.sleep(.4)
        assert (not(exists(touch_file)))
        queue1.shutdown()
        queue2 = StatefulManagerProxy(QueueManager('test', app, num_concurrent_jobs=1))
        queue2.recover_active_jobs()
        time.sleep(1)
        assert exists(touch_file)
    finally:
        shutil.rmtree(staging_directory)
        try:
            queue2.shutdown()
        except:
            pass
Beispiel #3
0
def _app():
    with temp_directory() as staging_directory:
        app = Bunch(
            staging_directory=staging_directory,
            persistence_directory=staging_directory,
            authorizer=get_authorizer(None),
            dependency_manager=TestDependencyManager(),
            job_metrics=Bunch(default_job_instrumenter=NULL_JOB_INSTRUMENTER),
        )
        yield app
Beispiel #4
0
def _app():
    with temp_directory() as staging_directory:
        app = Bunch(
            staging_directory=staging_directory,
            persistence_directory=staging_directory,
            authorizer=get_authorizer(None),
            dependency_manager=TestDependencyManager(),
            job_metrics=Bunch(default_job_instrumenter=NULL_JOB_INSTRUMENTER),
        )
        yield app
Beispiel #5
0
 def __setup_tool_config(self, conf):
     """
     Setups toolbox object and authorization mechanism based
     on supplied toolbox_path.
     """
     tool_config_files = conf.get("tool_config_files", None)
     if not tool_config_files:
         # For compatibity with Galaxy, allow tool_config_file
         # option name.
         tool_config_files = conf.get("tool_config_file", None)
     toolbox = None
     if tool_config_files:
         toolbox = ToolBox(tool_config_files)
     else:
         log.info(NOT_WHITELIST_WARNING)
     self.toolbox = toolbox
     self.authorizer = get_authorizer(toolbox)
Beispiel #6
0
 def __setup_tool_config(self, conf):
     """
     Setups toolbox object and authorization mechanism based
     on supplied toolbox_path.
     """
     tool_config_files = conf.get("tool_config_files", None)
     if not tool_config_files:
         # For compatibity with Galaxy, allow tool_config_file
         # option name.
         tool_config_files = conf.get("tool_config_file", None)
     toolbox = None
     if tool_config_files:
         toolbox = ToolBox(tool_config_files)
     else:
         log.info(NOT_WHITELIST_WARNING)
     self.toolbox = toolbox
     self.authorizer = get_authorizer(toolbox)
Beispiel #7
0
def test_allow_any_authorization():
    authorizer = get_authorizer(None)
    authorization = authorizer.get_authorization('tool1')
    authorization.authorize_setup()
    authorization.authorize_tool_file('cow',
                                      '#!/bin/bash\necho "Hello World!"')
Beispiel #8
0
 def setUp(self):
     self.toolbox = get_test_toolbox()
     self.authorizer = get_authorizer(self.toolbox)
def test_allow_any_authorization():
    authorizer = get_authorizer(None)
    authorization = authorizer.get_authorization('tool1')
    authorization.authorize_setup()
    authorization.authorize_tool_file('cow', '#!/bin/bash\necho "Hello World!"')
Beispiel #10
0
 def setUp(self):
     self.toolbox = get_test_toolbox()
     self.authorizer = get_authorizer(self.toolbox)