예제 #1
0
def test_run_helloworld_in_env(tmpdir):
    """Run the hello world workflow in the test environment."""
    basedir = os.path.join(tmpdir, 'flowserv')
    db = Flowserv(basedir=basedir, open_access=True, clear=True)
    # -- Install and run the workflow -----------------------------------------
    app_id = db.install(source=BENCHMARK_DIR,
                        specfile=BENCHMARK_FILE,
                        ignore_postproc=True)
    wf = db.open(app_id)
    run = wf.start_run({
        'names': StringIO('Alice\nBob\nClaire'),
        'greeting': 'Hey',
        'sleeptime': 0.1
    })
    assert run.is_success()
    assert not run.is_active()
    assert str(run) == st.STATE_SUCCESS
    assert len(run.files()) == 2
    text = run.get_file('greetings').text()
    assert 'Hey Alice' in text
    assert 'Hey Bob' in text
    assert 'Hey Claire' in text
    # There should no by any post-processing results
    assert wf.get_postproc_results() is None
    # -- Polling the run should return a valid result -------------------------
    run = wf.poll_run(run.run_id)
    assert run.is_success()
    assert not run.is_active()
    assert str(run) == st.STATE_SUCCESS
    assert len(run.files()) == 2
    file_handles = dict()
    for f in run.files():
        file_handles[f.name] = f
    assert file_handles['greetings'].name == 'greetings'
    assert file_handles['greetings'].format == {'type': 'plaintext'}
    assert file_handles[
        'results/analytics.json'].name == 'results/analytics.json'
    assert file_handles['results/analytics.json'].caption is None
    assert file_handles['results/analytics.json'].format == {'type': 'json'}
    # -- Cancelling a finished run raises an error ----------------------------
    with pytest.raises(err.InvalidRunStateError):
        wf.cancel_run(run.run_id)
    # -- Uninstall workflow ---------------------------------------------------
    db.uninstall(wf.identifier)
    # Running the workflow again will raise an error.
    with pytest.raises(err.UnknownWorkflowGroupError):
        run = wf.start_run({'names': StringIO('Alice')})
    # Erase the workflow folser.
    db.erase()
    assert not os.path.exists(os.path.join(tmpdir, 'flowserv'))
예제 #2
0
def test_install_app(tmpdir):
    """Install and uninstall a workflow application via the app client."""
    basedir = os.path.join(tmpdir, 'test')
    env = {config.FLOWSERV_BASEDIR: basedir}
    client = Flowserv(env=env)
    # Install workflow as application.
    app_id = client.install(source=TEMPLATE_DIR)
    # Get the application object.
    app = client.open(app_id)
    assert app.name() == 'Hello World'
    assert app.workflow_id == app.group_id
    # Use the open_app function to get a fresh instance of the workflow.
    app = open_app(env=app.service, identifier=app_id)
    assert app.name() == 'Hello World'
    assert app.workflow_id == app.group_id
    # Uninstall the app.
    client.uninstall(app_id)
    # Erase the nase directory.
    client.erase()
    assert not os.path.isdir(basedir)
예제 #3
0
def test_install_app(tmpdir):
    """Install and uninstall a workflow application via the app client."""
    basedir = os.path.join(tmpdir, 'test')
    env = Config()\
        .basedir(tmpdir)\
        .volume(FStore(basedir=str(tmpdir)))
    client = Flowserv(env=env)
    # Install workflow as application.
    app_id = client.install(source=BENCHMARK_DIR)
    # Get the application object.
    app = client.open(app_id)
    assert app.name() == 'Hello World'
    assert app.workflow_id == app.group_id
    # Use the open function to get a fresh instance of the workflow.
    app = Flowserv(env=app.service).open(identifier=app_id)
    assert app.name() == 'Hello World'
    assert app.workflow_id == app.group_id
    # Uninstall the app.
    client.uninstall(app_id)
    # Erase the nase directory.
    client.erase()
    assert not os.path.isdir(basedir)