Skip to content

Commit

Permalink
implement serve flag for planemo test
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbray committed Aug 13, 2021
1 parent 7ae0dc6 commit 271426d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
4 changes: 3 additions & 1 deletion planemo/commands/cmd_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"instances to limit generated traffic.",
default="0",
)
@options.galaxy_target_options()
@options.serve_option()
@options.galaxy_run_options()
@options.galaxy_config_options()
@options.test_options()
@options.engine_options()
Expand Down Expand Up @@ -65,6 +66,7 @@ def cli(ctx, uris, **kwds):
against that same Galaxy root - but this may not be bullet proof yet so
please careful and do not try this against production Galaxy instances.
"""
print(kwds)
with temp_directory(dir=ctx.planemo_directory) as temp_path:
# Create temp dir(s) outside of temp, docker can't mount $TEMPDIR on OSX
runnables = for_runnable_identifiers(ctx, uris, kwds, temp_path=temp_path)
Expand Down
17 changes: 17 additions & 0 deletions planemo/engine/test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import os

from planemo.engine import (
engine_context,
)
from planemo.galaxy import galaxy_config
from planemo.galaxy import galaxy_serve
from planemo.galaxy.api import (
DEFAULT_ADMIN_API_KEY
)
from planemo.galaxy.config import _find_test_data
from planemo.galaxy.ephemeris_sleep import sleep
from planemo.galaxy.test import (
handle_reports_and_summary,
run_in_config,
Expand All @@ -15,6 +22,16 @@

def test_runnables(ctx, runnables, original_paths=None, **kwds):
"""Return exit code indicating test or failure."""
if kwds.get("serve"):
kwds["engine"] = "external_galaxy"
kwds["galaxy_url"] = ''.join(("http://", kwds["host"], ":", kwds["port"]))
kwds["galaxy_admin_key"] = DEFAULT_ADMIN_API_KEY
pid = os.fork()
if pid == 0:
sleep(kwds["galaxy_url"], verbose=ctx.verbose, timeout=500)
else:
galaxy_serve(ctx, runnables, **kwds)

engine_type = kwds["engine"]
test_engine_testable = {RunnableType.galaxy_tool, RunnableType.galaxy_datamanager, RunnableType.directory}
enable_test_engines = any(r.type not in test_engine_testable for r in runnables)
Expand Down
9 changes: 9 additions & 0 deletions planemo/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,15 @@ def no_cleanup_option():
)


def serve_option():
return planemo_option(
"--serve",
is_flag=True,
default=False,
help=("Continue serving Galaxy instance after testing.")
)


def docker_enable_option():
return planemo_option(
"--docker/--no_docker",
Expand Down

0 comments on commit 271426d

Please sign in to comment.