=== modified file 'doc/changes.rst'
@@ -8,6 +8,11 @@
* Omit the commands we send to the board from the log (as this output is
invariably echoed back and so was ending up in the output twice)
+* Convert the dispatcher to LAVA commnand. It can now be called from the shell
+ by running ``lava dispatch``. The old command line interface
+ ``lava-dispatch`` is now deprecated and will be removed in the 0.8 release in
+ three months.
+
.. _version_0_5_9:
Version 0.5.9
=== added directory 'lava'
=== added file 'lava/__init__.py'
@@ -0,0 +1,3 @@
+__import__('pkg_resources').declare_namespace(__name__)
+# DO NOT ADD ANYTHING TO THIS FILE!
+# IT MUST STAY AS IS (empty apart from the two lines above)
=== added directory 'lava/dispatcher'
=== added file 'lava/dispatcher/__init__.py'
=== added file 'lava/dispatcher/commands.py'
@@ -0,0 +1,89 @@
+import logging
+import os
+import sys
+
+from json_schema_validator.errors import ValidationError
+from lava.tool.command import Command
+
+from lava_dispatcher.config import get_config
+from lava_dispatcher.job import LavaTestJob, validate_job_data
+
+
+class dispatch(Command):
+ """
+ Run test scenarios on virtual and physical hardware
+ """
+
+ @classmethod
+ def register_arguments(self, parser):
+ # When we're working inside a virtual environment use venv-relative
+ # configuration directory. This works well with lava-deployment-tool
+ # and the directory layout it currently provides but will need to be
+ # changed for codeline support.
+ if "VIRTUAL_ENV" in os.environ:
+ default_config_dir = os.path.join(
+ os.environ["VIRTUAL_ENV"], "etc", "lava-dispatcher")
+ else:
+ default_config_dir = None
+
+ parser.add_argument(
+ "--oob-fd",
+ default=None,
+ type=int,
+ help="Used internally by LAVA scheduler.")
+ parser.add_argument(
+ "--config-dir",
+ default=default_config_dir,
+ help="Configuration directory override (currently %(default)s")
+ parser.add_argument(
+ "--validate", action='store_true',
+ help="Just validate the job file, do not execute any steps.")
+ parser.add_argument(
+ "--job-id", action='store', default=None,
+ help=("Set the scheduler job identifier. "
+ "This alters process name for easier debugging"))
+ parser.add_argument(
+ "job-file",
+ metavar="JOB",
+ help="Test scenario file")
+
+ def invoke(self):
+ if self.args.oob_fd:
+ oob_file = os.fdopen(self.args.oob_fd, 'w')
+ else:
+ oob_file = sys.stderr
+
+ # config the python logging
+ # FIXME: move to lava-tool
+ FORMAT = '<LAVA_DISPATCHER>%(asctime)s %(levelname)s: %(message)s'
+ DATEFMT= '%Y-%m-%d %I:%M:%S %p'
+ logging.basicConfig(format=FORMAT,datefmt=DATEFMT)
+ config = get_config("lava-dispatcher", self.args.config_dir)
+ logging_level = config.get("LOGGING_LEVEL")
+ logging.root.setLevel(int(logging_level))
+
+ # Set process id if job-id was passed to dispatcher
+ if self.args.job_id:
+ try:
+ from setproctitle import getproctitle, setproctitle
+ except ImportError:
+ logging.warning(
+ ("Unable to set import 'setproctitle', "
+ "process name cannot be changed"))
+ else:
+ setproctitle("%s [job: %s]" % (
+ getproctitle(), self.args.job_id))
+
+ # Load the scenario file
+ with open(args[0]) as stream:
+ jobdata = stream.read()
+ job = LavaTestJob(jobdata, oob_file, config)
+
+ #FIXME Return status
+ if self.args.validate:
+ try:
+ validate_job_data(job.job_data)
+ except ValidationError as e:
+ print e
+ else:
+ job.run()
=== modified file 'lava_dispatcher/actions/__init__.py'
@@ -45,6 +45,7 @@
class BaseAction(object):
+
def __init__(self, context):
self.context = context
@@ -81,12 +82,13 @@
cmds[cls.command_name] = cls
return cmds
+
def get_all_cmds():
import pkg_resources
cmds = {}
cmd_path = os.path.dirname(os.path.realpath(__file__))
- for f in glob(os.path.join(cmd_path,"*.py")):
- module = imp.load_source("module", os.path.join(cmd_path,f))
+ for f in glob(os.path.join(cmd_path, "*.py")):
+ module = imp.load_source("module", os.path.join(cmd_path, f))
cmds.update(_find_commands(module))
for ep in pkg_resources.iter_entry_points(group="lava_dispatcher.actions"):
plugin = ep.load()
=== modified file 'lava_dispatcher/utils.py'
@@ -48,7 +48,8 @@
raise RuntimeError("Could not retrieve %s" % url)
return filename
-
+# XXX: duplication, we have similar code in lava-test, we need to move that to
+# lava.utils -> namespace as standalone package
def download_with_cache(url, path="", cachedir=""):
cache_loc = url_to_cache(url, cachedir)
if os.path.exists(cache_loc):
@@ -132,6 +133,7 @@
return super(logging_spawn, self).expect(*args, **kw)
+# XXX Duplication: we should reuse lava-test TestArtifacts
def generate_bundle_file_name(test_name):
return ("{test_id}.{time.tm_year:04}-{time.tm_mon:02}-{time.tm_mday:02}T"
"{time.tm_hour:02}:{time.tm_min:02}:{time.tm_sec:02}Z").format(
=== modified file 'setup.py'
@@ -10,6 +10,11 @@
description="Part of the LAVA framework for dispatching test jobs",
author='Linaro Validation Team',
author_email='linaro-dev@lists.linaro.org',
+ namespace_packages=['lava'],
+ entry_points="""
+ [lava.commands]
+ dispatch = lava.dispatcher.commands:dispatch
+ """,
packages=find_packages(),
package_data= {
'lava_dispatcher': [
@@ -21,9 +26,10 @@
],
},
install_requires=[
+ "json-schema-validator",
+ "lava-tool >= 0.4",
+ "lava-utils-interface",
"pexpect >= 2.3",
- "lava-tool",
- "json-schema-validator",
],
setup_requires=[
'versiontools >= 1.8',