Skip to content

Commit 271426d

Browse files
committed
implement serve flag for planemo test
1 parent 7ae0dc6 commit 271426d

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

planemo/commands/cmd_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
"instances to limit generated traffic.",
3333
default="0",
3434
)
35-
@options.galaxy_target_options()
35+
@options.serve_option()
36+
@options.galaxy_run_options()
3637
@options.galaxy_config_options()
3738
@options.test_options()
3839
@options.engine_options()
@@ -65,6 +66,7 @@ def cli(ctx, uris, **kwds):
6566
against that same Galaxy root - but this may not be bullet proof yet so
6667
please careful and do not try this against production Galaxy instances.
6768
"""
69+
print(kwds)
6870
with temp_directory(dir=ctx.planemo_directory) as temp_path:
6971
# Create temp dir(s) outside of temp, docker can't mount $TEMPDIR on OSX
7072
runnables = for_runnable_identifiers(ctx, uris, kwds, temp_path=temp_path)

planemo/engine/test.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1+
import os
2+
13
from planemo.engine import (
24
engine_context,
35
)
46
from planemo.galaxy import galaxy_config
7+
from planemo.galaxy import galaxy_serve
8+
from planemo.galaxy.api import (
9+
DEFAULT_ADMIN_API_KEY
10+
)
511
from planemo.galaxy.config import _find_test_data
12+
from planemo.galaxy.ephemeris_sleep import sleep
613
from planemo.galaxy.test import (
714
handle_reports_and_summary,
815
run_in_config,
@@ -15,6 +22,16 @@
1522

1623
def test_runnables(ctx, runnables, original_paths=None, **kwds):
1724
"""Return exit code indicating test or failure."""
25+
if kwds.get("serve"):
26+
kwds["engine"] = "external_galaxy"
27+
kwds["galaxy_url"] = ''.join(("http://", kwds["host"], ":", kwds["port"]))
28+
kwds["galaxy_admin_key"] = DEFAULT_ADMIN_API_KEY
29+
pid = os.fork()
30+
if pid == 0:
31+
sleep(kwds["galaxy_url"], verbose=ctx.verbose, timeout=500)
32+
else:
33+
galaxy_serve(ctx, runnables, **kwds)
34+
1835
engine_type = kwds["engine"]
1936
test_engine_testable = {RunnableType.galaxy_tool, RunnableType.galaxy_datamanager, RunnableType.directory}
2037
enable_test_engines = any(r.type not in test_engine_testable for r in runnables)

planemo/options.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,15 @@ def no_cleanup_option():
881881
)
882882

883883

884+
def serve_option():
885+
return planemo_option(
886+
"--serve",
887+
is_flag=True,
888+
default=False,
889+
help=("Continue serving Galaxy instance after testing.")
890+
)
891+
892+
884893
def docker_enable_option():
885894
return planemo_option(
886895
"--docker/--no_docker",

0 commit comments

Comments
 (0)