[Python-modules-commits] [checkbox-ng] 01/06: Import checkbox-ng_0.22.orig.tar.gz
Sylvain Pineau
spineau-guest at moszumanska.debian.org
Mon Dec 7 13:29:53 UTC 2015
This is an automated email from the git hooks/post-receive script.
spineau-guest pushed a commit to tag debian/0.22-1
in repository checkbox-ng.
commit 5600bed911f559e611fdf68c3f082c2394190936
Author: Sylvain Pineau <sylvain.pineau at canonical.com>
Date: Mon Dec 7 14:15:12 2015 +0100
Import checkbox-ng_0.22.orig.tar.gz
---
PKG-INFO | 2 +-
checkbox_ng.egg-info/PKG-INFO | 2 +-
checkbox_ng.egg-info/SOURCES.txt | 6 -
checkbox_ng.egg-info/entry_points.txt | 11 +-
checkbox_ng.egg-info/requires.txt | 3 +-
checkbox_ng/__init__.py | 2 +-
checkbox_ng/certification.py | 5 +-
checkbox_ng/commands/cli.py | 8 +-
checkbox_ng/commands/newcli.py | 37 +-
checkbox_ng/commands/service.py | 132 ---
checkbox_ng/commands/sru.py | 333 +++----
checkbox_ng/commands/test_sru.py | 32 +-
checkbox_ng/config.py | 10 +
checkbox_ng/dbus_ex/__init__.py | 81 --
checkbox_ng/dbus_ex/decorators.py | 391 --------
checkbox_ng/dbus_ex/service.py | 689 --------------
checkbox_ng/dbus_ex/test_dbus.py | 47 -
checkbox_ng/launchpad.py | 5 +-
checkbox_ng/main.py | 8 -
checkbox_ng/misc.py | 228 ++++-
checkbox_ng/service.py | 1586 ---------------------------------
checkbox_ng/test_main.py | 7 +-
checkbox_ng/test_misc.py | 44 +-
checkbox_ng/tools.py | 22 -
docs/changelog.rst | 22 +-
setup.py | 4 +-
26 files changed, 454 insertions(+), 3263 deletions(-)
diff --git a/PKG-INFO b/PKG-INFO
index 411c0a3..b6860f6 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.0
Name: checkbox-ng
-Version: 0.20.1
+Version: 0.22
Summary: Checkbox - Command Line Test Runner
Home-page: https://launchpad.net/checkbox-ng/
Author: Zygmunt Krynicki
diff --git a/checkbox_ng.egg-info/PKG-INFO b/checkbox_ng.egg-info/PKG-INFO
index 411c0a3..b6860f6 100644
--- a/checkbox_ng.egg-info/PKG-INFO
+++ b/checkbox_ng.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.0
Name: checkbox-ng
-Version: 0.20.1
+Version: 0.22
Summary: Checkbox - Command Line Test Runner
Home-page: https://launchpad.net/checkbox-ng/
Author: Zygmunt Krynicki
diff --git a/checkbox_ng.egg-info/SOURCES.txt b/checkbox_ng.egg-info/SOURCES.txt
index cdb0549..8c32ab2 100644
--- a/checkbox_ng.egg-info/SOURCES.txt
+++ b/checkbox_ng.egg-info/SOURCES.txt
@@ -10,7 +10,6 @@ checkbox_ng/launcher.py
checkbox_ng/launchpad.py
checkbox_ng/main.py
checkbox_ng/misc.py
-checkbox_ng/service.py
checkbox_ng/test_certification.py
checkbox_ng/test_config.py
checkbox_ng/test_main.py
@@ -28,14 +27,9 @@ checkbox_ng/commands/__init__.py
checkbox_ng/commands/cli.py
checkbox_ng/commands/launcher.py
checkbox_ng/commands/newcli.py
-checkbox_ng/commands/service.py
checkbox_ng/commands/sru.py
checkbox_ng/commands/submit.py
checkbox_ng/commands/test_sru.py
-checkbox_ng/dbus_ex/__init__.py
-checkbox_ng/dbus_ex/decorators.py
-checkbox_ng/dbus_ex/service.py
-checkbox_ng/dbus_ex/test_dbus.py
contrib/checkbox-ci-installed-notifier.service
contrib/checkbox-ci-mailer.service
contrib/checkbox-sru.service
diff --git a/checkbox_ng.egg-info/entry_points.txt b/checkbox_ng.egg-info/entry_points.txt
index bb52eaf..255cc95 100644
--- a/checkbox_ng.egg-info/entry_points.txt
+++ b/checkbox_ng.egg-info/entry_points.txt
@@ -1,10 +1,9 @@
-[console_scripts]
-checkbox = checkbox_ng.main:main
-checkbox-gui-service = checkbox_ng.main:service
-checkbox-launcher = checkbox_ng.main:launcher
-checkbox-submit = checkbox_ng.main:submit
-
[plainbox.transport]
certification = checkbox_ng.certification:CertificationTransport
launchpad = checkbox_ng.launchpad:LaunchpadTransport
+[console_scripts]
+checkbox-launcher = checkbox_ng.main:launcher
+checkbox = checkbox_ng.main:main
+checkbox-submit = checkbox_ng.main:submit
+
diff --git a/checkbox_ng.egg-info/requires.txt b/checkbox_ng.egg-info/requires.txt
index 745778c..eda648c 100644
--- a/checkbox_ng.egg-info/requires.txt
+++ b/checkbox_ng.egg-info/requires.txt
@@ -1,3 +1,4 @@
checkbox-support >= 0.2
+guacamole >= 0.9
plainbox >= 0.5.3
-requests >= 1.0
+requests >= 1.0
\ No newline at end of file
diff --git a/checkbox_ng/__init__.py b/checkbox_ng/__init__.py
index f1e594f..dfa34d8 100644
--- a/checkbox_ng/__init__.py
+++ b/checkbox_ng/__init__.py
@@ -24,4 +24,4 @@
CheckBoxNG is a new version of CheckBox built on top of PlainBox
"""
-__version__ = (0, 20, 1, "final", 0)
+__version__ = (0, 22, 0, "final", 0)
diff --git a/checkbox_ng/certification.py b/checkbox_ng/certification.py
index 50b9c24..0d6accf 100644
--- a/checkbox_ng/certification.py
+++ b/checkbox_ng/certification.py
@@ -108,7 +108,7 @@ class CertificationTransport(TransportBase):
was successful. This should contain an 'id' key, however
the server response may change, so the only guarantee
we make is that this will be non-False if the server
- accepted the data.
+ accepted the data. Returns empty dictionary otherwise.
:raises requests.exceptions.Timeout:
If sending timed out.
:raises requests.exceptions.ConnectionError:
@@ -179,7 +179,8 @@ class CertificationTransport(TransportBase):
return response.json()
except Exception as exc:
raise TransportError(str(exc))
- # XXX: can response be None?
+
+ # ISessionStateTransport.send must return dictionary
return {}
def _validate_secure_id(self, secure_id):
diff --git a/checkbox_ng/commands/cli.py b/checkbox_ng/commands/cli.py
index 171ff3f..e7d6c45 100644
--- a/checkbox_ng/commands/cli.py
+++ b/checkbox_ng/commands/cli.py
@@ -28,7 +28,6 @@
from argparse import SUPPRESS
from gettext import gettext as _
from logging import getLogger
-import argparse
from plainbox.impl.commands import PlainBoxCommand
from plainbox.impl.commands.cmd_checkbox import CheckBoxCommandMixIn
@@ -64,12 +63,7 @@ class CliCommand(PlainBoxCommand, CheckBoxCommandMixIn):
parser = subparsers.add_parser(self.settings['subparser_name'],
help=self.settings['subparser_help'])
parser.set_defaults(command=self)
- parser.set_defaults(dry_run=False, new_ui=True)
- parser.add_argument(
- '--new-ui', help=argparse.SUPPRESS, action='store_true')
- parser.add_argument(
- '--old-ui', dest='new_ui', help=argparse.SUPPRESS,
- action='store_false')
+ parser.set_defaults(dry_run=False)
parser.add_argument(
"--check-config",
action="store_true",
diff --git a/checkbox_ng/commands/newcli.py b/checkbox_ng/commands/newcli.py
index 1df11d2..7546aa0 100644
--- a/checkbox_ng/commands/newcli.py
+++ b/checkbox_ng/commands/newcli.py
@@ -46,8 +46,9 @@ from plainbox.impl.secure.qualifiers import OperatorMatcher
from plainbox.impl.secure.qualifiers import RegExpJobQualifier
from plainbox.impl.secure.qualifiers import select_jobs
from plainbox.impl.session import SessionMetaData
-from plainbox.impl.transport import get_all_transports
+from plainbox.impl.session.jobs import InhibitionCause
from plainbox.impl.transport import TransportError
+from plainbox.impl.transport import get_all_transports
from plainbox.vendor.textland import get_display
from checkbox_ng.misc import SelectableJobTreeNode
@@ -203,7 +204,11 @@ class CliInvocation2(RunInvocation):
self.print_estimated_duration()
self.run_all_selected_jobs()
if self.is_interactive:
- self.maybe_rerun_jobs()
+ while True:
+ if self.maybe_rerun_jobs():
+ continue
+ else:
+ break
self.export_and_send_results()
if SessionMetaData.FLAG_INCOMPLETE in self.metadata.flags:
print(self.C.header("Session Complete!", "GREEN"))
@@ -314,7 +319,7 @@ class CliInvocation2(RunInvocation):
# NOTE: tree.selection is correct but ordered badly. To retain
# the original ordering we should just treat it as a mask and
# use it to filter jobs from desired_job_list.
- wanted_set = frozenset(tree.selection)
+ wanted_set = frozenset(tree.selection + tree.resource_jobs)
job_list = [job for job in self.manager.state.run_list
if job in wanted_set]
self._update_desired_job_list(job_list)
@@ -487,29 +492,41 @@ class CliInvocation2(RunInvocation):
print(str(exc))
def maybe_rerun_jobs(self):
- def rerun_predicate(job_state):
- return job_state.result.outcome in (
- IJobResult.OUTCOME_FAIL, IJobResult.OUTCOME_CRASH)
# create a list of jobs that qualify for rerunning
rerun_candidates = []
for job in self.manager.state.run_list:
- if rerun_predicate(self.manager.state.job_state_map[job.id]):
+ job_state = self.manager.state.job_state_map[job.id]
+ if job_state.result.outcome in (
+ IJobResult.OUTCOME_FAIL, IJobResult.OUTCOME_CRASH,
+ IJobResult.OUTCOME_NOT_SUPPORTED):
rerun_candidates.append(job)
+
# bail-out early if no job qualifies for rerunning
if not rerun_candidates:
- return
+ return False
tree = SelectableJobTreeNode.create_tree(
self.manager.state, rerun_candidates)
+ # nothing to select in root node and categories - bailing out
+ if not tree.jobs and not tree._categories:
+ return False
# deselect all by default
tree.set_descendants_state(False)
self.display.run(ShowRerun(tree, _("Select jobs to re-run")))
wanted_set = frozenset(tree.selection)
if not wanted_set:
# nothing selected - nothing to run
- return
- # reset outcome of jobs that are selected for re-running
+ return False
+ # include resource jobs that selected jobs depend on
+ resources_to_rerun = []
for job in wanted_set:
+ job_state = self.manager.state.job_state_map[job.id]
+ for inhibitor in job_state.readiness_inhibitor_list:
+ if inhibitor.cause == InhibitionCause.FAILED_DEP:
+ resources_to_rerun.append(inhibitor.related_job)
+ # reset outcome of jobs that are selected for re-running
+ for job in list(wanted_set) + resources_to_rerun:
from plainbox.impl.result import MemoryJobResult
self.manager.state.job_state_map[job.id].result = \
MemoryJobResult({})
self.run_all_selected_jobs()
+ return True
diff --git a/checkbox_ng/commands/service.py b/checkbox_ng/commands/service.py
deleted file mode 100644
index d01d206..0000000
--- a/checkbox_ng/commands/service.py
+++ /dev/null
@@ -1,132 +0,0 @@
-# This file is part of Checkbox.
-#
-# Copyright 2013-2014 Canonical Ltd.
-# Written by:
-# Zygmunt Krynicki <zygmunt.krynicki at canonical.com>
-#
-# Checkbox is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 3,
-# as published by the Free Software Foundation.
-#
-# Checkbox is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
-
-"""
-:mod:`checkbox_ng.commands.service` -- service sub-command
-==========================================================
-
-"""
-
-from gettext import gettext as _
-import logging
-import os
-
-from dbus import StarterBus, SessionBus
-from dbus.mainloop.glib import DBusGMainLoop, threads_init
-from dbus.service import BusName
-from gi.repository import GObject
-from plainbox.impl.highlevel import Service
-
-from checkbox_ng.commands import CheckboxCommand
-from checkbox_ng.service import ServiceWrapper
-
-
-logger = logging.getLogger("checkbox.ng.commands.service")
-
-
-def connect_to_session_bus():
- """
- Connect to the session bus properly.
-
- Returns a tuple (session_bus, loop) where loop is a GObject.MainLoop
- instance. The loop is there so that you can listen to signals.
- """
- # We'll need an event loop to observe signals. We will need the instance
- # later below so let's keep it. Note that we're not passing it directly
- # below as DBus needs specific API. The DBusGMainLoop class that we
- # instantiate and pass is going to work with this instance transparently.
- #
- # NOTE: DBus tutorial suggests that we should create the loop _before_
- # connecting to the bus.
- logger.debug("Setting up glib-based event loop")
- # Make sure gobject threads don't crash
- GObject.threads_init()
- threads_init()
- loop = GObject.MainLoop()
- # Let's get the system bus object.
- logger.debug("Connecting to DBus session bus")
- if os.getenv("DBUS_STARTER_ADDRESS"):
- session_bus = StarterBus(mainloop=DBusGMainLoop())
- else:
- session_bus = SessionBus(mainloop=DBusGMainLoop())
- return session_bus, loop
-
-
-class ServiceInvocation:
-
- def __init__(self, provider_loader, config_loader, ns):
- self.provider_loader = provider_loader
- self.config_loader = config_loader
- self.ns = ns
-
- def run(self):
- bus, loop = connect_to_session_bus()
- logger.info(_("Setting up DBus objects..."))
- session_list = [] # TODO: load sessions
- logger.debug(_("Constructing Service object"))
- service_obj = Service(
- self.provider_loader(), session_list, self.config_loader())
- logger.debug(_("Constructing ServiceWrapper"))
- service_wrp = ServiceWrapper(service_obj, on_exit=lambda: loop.quit())
- logger.info(_("Publishing all objects on DBus"))
- service_wrp.publish_related_objects(bus)
- logger.info(
- _("Publishing all managed objects (events should fire there)"))
- service_wrp.publish_managed_objects()
- logger.debug(_("Attempting to claim bus name: %s"), self.ns.bus_name)
- bus_name = BusName(self.ns.bus_name, bus)
- logger.info(
- _("PlainBox DBus service ready, claimed name: %s"),
- bus_name.get_name())
- try:
- loop.run()
- except KeyboardInterrupt:
- logger.warning(_(
- "Main loop interrupted!"
- " It is recommended to call the Exit() method on the"
- " exported service object instead"))
- finally:
- logger.debug(_("Releasing %s"), bus_name)
- # XXX: ugly but that's how one can reliably release a bus name
- del bus_name
- # Remove objects from the bus
- service_wrp.remove_from_connection()
- logger.debug(_("Closing %s"), bus)
- bus.close()
- logger.debug(_("Main loop terminated, exiting..."))
-
-
-class ServiceCommand(CheckboxCommand):
- """
- DBus service for PlainBox
- """
-
- def invoked(self, ns):
- return ServiceInvocation(
- self.provider_loader, self.config_loader, ns).run()
-
- def register_parser(self, subparsers):
- parser = subparsers.add_parser("service", help=_("spawn dbus service"))
- self.register_arguments(parser)
-
- def register_arguments(self, parser):
- parser.add_argument(
- '--bus-name', action="store",
- default="com.canonical.certification.PlainBox1",
- help=_("use the specified DBus bus name"))
- parser.set_defaults(command=self)
diff --git a/checkbox_ng/commands/sru.py b/checkbox_ng/commands/sru.py
index 55a93ad..77263d0 100644
--- a/checkbox_ng/commands/sru.py
+++ b/checkbox_ng/commands/sru.py
@@ -26,173 +26,125 @@
THIS MODULE DOES NOT HAVE STABLE PUBLIC API
"""
-import logging
import sys
-import tempfile
from gettext import gettext as _
-from plainbox.impl.applogic import get_matching_job_list
-from plainbox.impl.applogic import get_whitelist_by_name
-from plainbox.impl.applogic import run_job_if_possible
from plainbox.impl.commands import PlainBoxCommand
from plainbox.impl.commands.inv_check_config import CheckConfigInvocation
-from plainbox.impl.commands.cmd_checkbox import CheckBoxCommandMixIn
-from plainbox.impl.commands.inv_checkbox import CheckBoxInvocationMixIn
-from plainbox.impl.depmgr import DependencyDuplicateError
-from plainbox.impl.exporter import ByteStringStreamTranslator
-from plainbox.impl.runner import JobRunner
+from plainbox.impl.ingredients import CanonicalCommand
from plainbox.impl.secure.config import ValidationError, Unset
-from plainbox.impl.session import SessionStateLegacyAPI as SessionState
-from plainbox.impl.transport import TransportError
-from checkbox_ng.certification import CertificationTransport
+class sru(CanonicalCommand):
-logger = logging.getLogger("plainbox.commands.sru")
-
-
-class _SRUInvocation(CheckBoxInvocationMixIn):
"""
- Helper class instantiated to perform a particular invocation of the sru
- command. Unlike the SRU command itself, this class is instantiated each
- time.
- """
-
- def __init__(self, provider_loader, config_loader, ns):
- super().__init__(provider_loader, config_loader)
- self.ns = ns
- if self.ns.whitelist:
- self.whitelist = self.get_whitelist_from_file(
- self.ns.whitelist[0].name, self.ns.whitelist)
- elif self.config.whitelist is not Unset:
- self.whitelist = self.get_whitelist_from_file(
- self.config.whitelist)
- else:
- self.whitelist = get_whitelist_by_name(self.provider_list, 'sru')
- self.job_list = self.get_job_list(ns)
- self.session = None
- self.runner = None
-
- def run(self):
- # Compute the run list, this can give us notification about problems in
- # the selected jobs. Currently we just display each problem
- # Create a session that handles most of the stuff needed to run jobs
- try:
- unit_list = self.job_list
- # Add exporters to the list of units in order to get them from the
- # session manager exporter_map property.
- for provider in self.provider_list:
- for unit in provider.unit_list:
- if unit.Meta.name == 'exporter':
- unit_list.append(unit)
- self.session = SessionState(unit_list)
- except DependencyDuplicateError as exc:
- # Handle possible DependencyDuplicateError that can happen if
- # someone is using plainbox for job development.
- print(_("The job database you are currently using is broken"))
- print(_("At least two jobs contend for the name {0}").format(
- exc.job.id))
- print(_("Second job defined in: {0}").format(
- exc.duplicate_job.origin))
- raise SystemExit(exc)
- with self.session.open():
- self._set_job_selection()
- self.runner = JobRunner(
- self.session.session_dir, self.provider_list,
- self.session.jobs_io_log_dir, command_io_delegate=self,
- dry_run=self.ns.dry_run)
- # XXX: maybe allow specifying system_id from command line?
- self.exporter = self.session.manager.create_exporter(
- '2013.com.canonical.plainbox::hexr')
- self._run_all_jobs()
- if self.config.fallback_file is not Unset:
- self._save_results()
- self._submit_results()
- # FIXME: sensible return value
- return 0
-
- def _set_job_selection(self):
- desired_job_list = get_matching_job_list(self.job_list, self.whitelist)
- problem_list = self.session.update_desired_job_list(desired_job_list)
- if problem_list:
- logger.warning(
- _("There were some problems with the selected jobs"))
- for problem in problem_list:
- logger.warning("- %s", problem)
- logger.warning(_("Problematic jobs will not be considered"))
+ Run stable release update (sru) tests.
- def _save_results(self):
- print(_("Saving results to {0}").format(self.config.fallback_file))
- with open(self.config.fallback_file, "wt", encoding="UTF-8") as stream:
- translating_stream = ByteStringStreamTranslator(stream, "UTF-8")
- self.exporter.dump_from_session_manager(self.session.manager,
- translating_stream)
+ Stable release updates are periodic fixes for nominated bugs that land in
+ existing supported Ubuntu releases. To ensure a certain level of quality
+ all SRU updates affecting hardware enablement are automatically tested
+ on a pool of certified machines.
+ """
- def _submit_results(self):
- print(_("Submitting results to {0} for secure_id {1}").format(
- self.config.c3_url, self.config.secure_id))
- options_string = "secure_id={0}".format(self.config.secure_id)
- # Create the transport object
- transport = CertificationTransport(self.config.c3_url, options_string)
- # Prepare the data for submission
- with tempfile.NamedTemporaryFile(mode='w+b') as stream:
- # Dump the data to the temporary file
- self.exporter.dump_from_session_manager(self.session.manager,
- stream)
- # Flush and rewind
- stream.flush()
- stream.seek(0)
- try:
- # Send the data, reading from the temporary file
- result = transport.send(stream, self.config, self.session)
- if 'url' in result:
- print(_("Successfully sent, submission status at"
- " {0}").format(result['url']))
- else:
- print(_("Successfully sent, server response: {0}").format(
- result))
- except (ValueError, TransportError) as exc:
- print(str(exc))
- except IOError as exc:
- print(_("Problem reading a file: {0}").format(exc))
+ def __init__(self, config):
+ """Init method to store the config settings."""
+ self.config = config
+ if not self.config.test_plan:
+ self.config.test_plan = "2013.com.canonical.certification::sru"
- def _run_all_jobs(self):
- again = True
- while again:
- again = False
- for job in self.session.run_list:
- # Skip jobs that already have result, this is only needed when
- # we run over the list of jobs again, after discovering new
- # jobs via the local job output
- result = self.session.job_state_map[job.id].result
- if result.outcome is not None:
- continue
- self._run_single_job(job)
- self.session.persistent_save()
- if job.plugin == "local":
- # After each local job runs rebuild the list of matching
- # jobs and run everything again
- self._set_job_selection()
- again = True
- break
+ def register_arguments(self, parser):
+ """Method called to register command line arguments."""
+ parser.add_argument(
+ '--secure_id', metavar=_("SECURE-ID"),
+ # NOTE: --secure-id is optional only when set in a config file
+ required=self.config.secure_id is Unset,
+ help=_("Canonical hardware identifier"))
+ parser.add_argument(
+ '-T', '--test-plan',
+ action="store",
+ metavar=_("TEST-PLAN-ID"),
+ default=None,
+ # TRANSLATORS: this is in imperative form
+ help=_("load the specified test plan"))
+ parser.add_argument(
+ '--staging', action='store_true', default=False,
+ help=_("Send the data to non-production test server"))
+ parser.add_argument(
+ "--check-config",
+ action="store_true",
+ help=_("run check-config before starting"))
- def _run_single_job(self, job):
- print("- {}:".format(job.id), end=' ')
- sys.stdout.flush()
- job_state, job_result = run_job_if_possible(
- self.session, self.runner, self.config, job)
- print("{0}".format(job_result.outcome))
- sys.stdout.flush()
- if job_result.comments is not None:
- print(_("comments: {0}").format(job_result.comments))
- if job_state.readiness_inhibitor_list:
- print(_("inhibitors:"))
- for inhibitor in job_state.readiness_inhibitor_list:
- print(" * {}".format(inhibitor))
- self.session.update_job_result(job, job_result)
+ def invoked(self, ctx):
+ """Method called when the command is invoked."""
+ # Copy command-line arguments over configuration variables
+ try:
+ if ctx.args.secure_id:
+ self.config.secure_id = ctx.args.secure_id
+ if ctx.args.test_plan:
+ self.config.test_plan = ctx.args.test_plan
+ if ctx.args.staging:
+ self.config.staging = ctx.args.staging
+ except ValidationError as exc:
+ print(_("Configuration problems prevent running SRU tests"))
+ print(exc)
+ return 1
+ ctx.sa.use_alternate_configuration(self.config)
+ # Run check-config, if requested
+ if ctx.args.check_config:
+ retval = CheckConfigInvocation(lambda: self.config).run()
+ if retval != 0:
+ return retval
+ self.transport = self._create_transport(
+ ctx.sa, self.config.secure_id, self.config.staging)
+ self.ctx = ctx
+ try:
+ self._collect_info(ctx.rc, ctx.sa)
+ self._save_results(ctx.rc, ctx.sa)
+ self._send_results(
+ ctx.rc, ctx.sa, self.config.secure_id, self.config.staging)
+ except KeyboardInterrupt:
+ return 1
+ def _save_results(self, rc, sa):
+ rc.reset()
+ rc.padding = (1, 1, 0, 1)
+ path = sa.export_to_file(
+ "2013.com.canonical.plainbox::hexr", (), '/tmp')
+ rc.para(_("Results saved to {0}").format(path))
+
+ def _send_results(self, rc, sa, secure_id, staging):
+ rc.reset()
+ rc.padding = (1, 1, 0, 1)
+ rc.para(_("Sending hardware report to Canonical Certification"))
+ rc.para(_("Server URL is: {0}").format(self.transport.url))
+ result = sa.export_to_transport(
+ "2013.com.canonical.plainbox::hexr", self.transport)
+ if 'url' in result:
+ rc.para(result['url'])
+
+ def _create_transport(self, sa, secure_id, staging):
+ return sa.get_canonical_certification_transport(
+ secure_id, staging=staging)
+
+ def _collect_info(self, rc, sa):
+ sa.select_providers('*')
+ sa.start_new_session(_("Hardware Collection Session"))
+ sa.select_test_plan(self.config.test_plan)
+ sa.bootstrap()
+ for job_id in sa.get_static_todo_list():
+ job = sa.get_job(job_id)
+ builder = sa.run_job(job_id, 'silent', False)
+ result = builder.get_result()
+ sa.use_job_result(job_id, result)
+ rc.para("- {0}: {1}".format(job.id, result))
+ if result.comments:
+ rc.padding = (0, 0, 0, 2)
+ rc.para("{0}".format(result.comments))
+ rc.reset()
+
+
+class SRUCommand(PlainBoxCommand):
-class SRUCommand(PlainBoxCommand, CheckBoxCommandMixIn):
"""
Command for running Stable Release Update (SRU) tests.
@@ -200,10 +152,6 @@ class SRUCommand(PlainBoxCommand, CheckBoxCommandMixIn):
existing supported Ubuntu releases. To ensure a certain level of quality
all SRU updates affecting hardware enablement are automatically tested
on a pool of certified machines.
-
- This command is _temporary_ and will eventually migrate to the checkbox
- side. Its intended lifecycle is for the development and validation of
- plainbox core on realistic workloads.
"""
gettext_domain = "checkbox-ng"
@@ -215,79 +163,12 @@ class SRUCommand(PlainBoxCommand, CheckBoxCommandMixIn):
self.config = config_loader()
def invoked(self, ns):
- # Copy command-line arguments over configuration variables
- try:
- if ns.secure_id:
- self.config.secure_id = ns.secure_id
- if ns.fallback_file and ns.fallback_file is not Unset:
- self.config.fallback_file = ns.fallback_file
- if ns.c3_url:
- self.config.c3_url = ns.c3_url
- except ValidationError as exc:
- print(_("Configuration problems prevent running SRU tests"))
- print(exc)
- return 1
- # Run check-config, if requested
- if ns.check_config:
- retval = CheckConfigInvocation(lambda: self.config).run()
- if retval != 0:
- return retval
- # To maintain the illusion (aka API) the config loader we're presenting
- # to the invocation class is just a simple lambda that returns the
- # already loaded config.
- return _SRUInvocation(
- self.provider_loader, lambda: self.config, ns).run()
+ """Method called when the command is invoked."""
+ return sru(self.config).main(sys.argv[2:], exit=False)
def register_parser(self, subparsers):
+ """Method called to register command line arguments."""
parser = subparsers.add_parser(
"sru", help=_("run automated stable release update tests"))
parser.set_defaults(command=self)
- parser.add_argument(
- "--check-config",
- action="store_true",
- help=_("run check-config before starting"))
- group = parser.add_argument_group("sru-specific options")
- # Set defaults from based on values from the config file
- group.set_defaults(
- secure_id=self.config.secure_id,
- c3_url=self.config.c3_url,
- fallback_file=self.config.fallback_file)
- group.add_argument(
- '--secure-id', metavar=_("SECURE-ID"),
- action='store',
- # NOTE: --secure-id is optional only when set in a config file
- required=self.config.secure_id is Unset,
- # TRANSLATORS: Do not translate %(default)
- help=(_("associate submission with a machine using this SECURE-ID"
- " (%(default)s)")))
- group.add_argument(
- '--fallback', metavar=_("FILE"),
- dest='fallback_file',
- action='store',
- default=Unset,
- # TRANSLATORS: Do not translate %(default)s
- help=(_("if submission fails save the test report as FILE"
- " (%(default)s)")))
- group.add_argument(
- '--destination', metavar=_("URL"),
- dest='c3_url',
- action='store',
- # TRANSLATORS: Do not translate %(default)s
- help=(_("POST the test report XML to this URL"
- " (%(default)s)")))
- group.add_argument(
- '--staging',
- dest='c3_url',
- action='store_const',
- const='https://certification.staging.canonical.com/'
- 'submissions/submit/',
- help=_('override --destination to use the staging '
- 'certification website'))
- group = parser.add_argument_group(title="execution options")
- group.add_argument(
- '-n', '--dry-run',
- action='store_true',
- default=False,
- help=_("don't really run most jobs"))
- # Call enhance_parser from CheckBoxCommandMixIn
- self.enhance_parser(parser)
+ sru(self.config).register_arguments(parser)
diff --git a/checkbox_ng/commands/test_sru.py b/checkbox_ng/commands/test_sru.py
index f39e5a6..8d456ee 100644
--- a/checkbox_ng/commands/test_sru.py
+++ b/checkbox_ng/commands/test_sru.py
@@ -41,36 +41,16 @@ class TestSru(TestCase):
self.assertEqual(call.exception.args, (0,))
self.maxDiff = None
expected = """
- usage: checkbox sru [-h] [--check-config] --secure-id SECURE-ID
- [--fallback FILE] [--destination URL] [--staging] [-n]
- [-T TEST-PLAN-ID] [-i PATTERN] [-x PATTERN] [-w WHITELIST]
+ usage: checkbox sru [-h] --secure_id SECURE-ID [-T TEST-PLAN-ID] [--staging]
+ [--check-config]
optional arguments:
-h, --help show this help message and exit
- --check-config run check-config before starting
-
- sru-specific options:
- --secure-id SECURE-ID
- associate submission with a machine using this SECURE-
- ID (unset)
- --fallback FILE if submission fails save the test report as FILE
- (unset)
- --destination URL POST the test report XML to this URL (https://certific
- ation.canonical.com/submissions/submit/)
- --staging override --destination to use the staging
- certification website
-
- execution options:
- -n, --dry-run don't really run most jobs
-
- test selection options:
+ --secure_id SECURE-ID
+ Canonical hardware identifier
-T TEST-PLAN-ID, --test-plan TEST-PLAN-ID
load the specified test plan
- -i PATTERN, --include-pattern PATTERN
- include jobs matching the given regular expression
- -x PATTERN, --exclude-pattern PATTERN
- exclude jobs matching the given regular expression
- -w WHITELIST, --whitelist WHITELIST
- load whitelist containing run patterns
+ --staging Send the data to non-production test server
+ --check-config run check-config before starting
"""
self.assertEqual(io.combined, cleandoc(expected) + "\n")
diff --git a/checkbox_ng/config.py b/checkbox_ng/config.py
index 39bbe70..437387f 100644
--- a/checkbox_ng/config.py
+++ b/checkbox_ng/config.py
@@ -77,6 +77,16 @@ class CheckBoxConfig(PlainBoxConfig):
section="sru",
help_text=_("Optional whitelist with which to run SRU testing"))
+ test_plan = config.Variable(
+ section="sru",
+ help_text=_("Optional test plan with which to run SRU testing"))
+
+ staging = config.Variable(
+ section="sru",
+ kind=bool,
+ default=False,
+ help_text=_("Send the data to non-production test server"))
+
class Meta(PlainBoxConfig.Meta):
# TODO: properly depend on xdg and use real code that also handles
# XDG_CONFIG_HOME.
diff --git a/checkbox_ng/dbus_ex/__init__.py b/checkbox_ng/dbus_ex/__init__.py
deleted file mode 100644
index e941616..0000000
--- a/checkbox_ng/dbus_ex/__init__.py
+++ /dev/null
@@ -1,81 +0,0 @@
-# This file is part of Checkbox.
-#
-# Copyright 2013 Canonical Ltd.
-# Written by:
-# Zygmunt Krynicki <zygmunt.krynicki at canonical.com>
-#
-# Checkbox is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 3,
-# as published by the Free Software Foundation.
-
-#
-# Checkbox is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
-
-"""
-:mod:`checkbox_ng.dbus_ex` -- DBus Extensions
-=============================================
-"""
-
-__all__ = [
- 'service',
- 'exceptions',
- 'Signature',
- 'Struct',
- 'types',
- 'INTROSPECTABLE_IFACE',
- 'PEER_IFACE',
- 'PROPERTIES_IFACE',
- 'OBJECT_MANAGER_IFACE',
-]
-
-import re
-import os
-
-if os.getenv("MOCK_DBUS") == "yes":
- import sys
- from plainbox.vendor import mock
- for name in (
- '_dbus_bindings',
- 'dbus',
- 'dbus._compat',
- 'dbus.exceptions',
- 'dbus.lowlevel',
- 'dbus.mainloop',
- 'dbus.mainloop.glib',
- 'dbus.service',
- 'gi',
- 'gi.repository',
- ):
- sys.modules[name] = mock.MagicMock(name=name)
- sys.modules['dbus'].service.Object = object
- sys.modules['dbus'].service.Interface = object
- sys.modules['dbus'].service.InterfaceType = type
-
-
-from dbus import INTROSPECTABLE_IFACE
-from dbus import PEER_IFACE
-from dbus import PROPERTIES_IFACE
-from dbus import Signature
-from dbus import Struct
-from dbus import exceptions
-from dbus import types
-
-OBJECT_MANAGER_IFACE = "org.freedesktop.DBus.ObjectManager"
-
-from checkbox_ng.dbus_ex import service
-
-
-def mangle_object_path(path):
- """
- "Mangles" the provided candidate dbus object path to ensure it complies
- with the dbus specification. Returns the mangled path.
- """
- # TODO: It just enforces the valid characters rule, not the rest of the
- # DBus path construction rules
- return re.sub(r"[^a-zA-Z0-9_/]", "_", path)
diff --git a/checkbox_ng/dbus_ex/decorators.py b/checkbox_ng/dbus_ex/decorators.py
deleted file mode 100644
index 7b0b54d..0000000
--- a/checkbox_ng/dbus_ex/decorators.py
+++ /dev/null
@@ -1,391 +0,0 @@
-"""Service-side D-Bus decorators."""
-
-# Copyright (C) 2003, 2004, 2005, 2006 Red Hat Inc. <http://www.redhat.com/>
-# Copyright (C) 2003 David Zeuthen
-# Copyright (C) 2004 Rob Taylor
-# Copyright (C) 2005, 2006 Collabora Ltd. <http://www.collabora.co.uk/>
-#
-# Permission is hereby granted, free of charge, to any person
-# obtaining a copy of this software and associated documentation
-# files (the "Software"), to deal in the Software without
-# restriction, including without limitation the rights to use, copy,
-# modify, merge, publish, distribute, sublicense, and/or sell copies
-# of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-
-__all__ = ('method', 'signal')
-__docformat__ = 'restructuredtext'
-
-import functools
-import inspect
-import logging
-import os
-
-from dbus import validate_interface_name, Signature, validate_member_name
-from dbus.lowlevel import SignalMessage
-from dbus.exceptions import DBusException
-from dbus._compat import is_py2
-
-
-_logger = logging.getLogger('checkbox.ng.dbus_ex.decorators')
-
-
-def method(dbus_interface, in_signature=None, out_signature=None,
- async_callbacks=None,
- sender_keyword=None, path_keyword=None, destination_keyword=None,
- message_keyword=None, connection_keyword=None,
- byte_arrays=False,
- rel_path_keyword=None, **kwargs):
- """Factory for decorators used to mark methods of a `dbus.service.Object`
- to be exported on the D-Bus.
-
- The decorated method will be exported over D-Bus as the method of the
- same name on the given D-Bus interface.
-
- :Parameters:
- `dbus_interface` : str
- Name of a D-Bus interface
- `in_signature` : str or None
- If not None, the signature of the method parameters in the usual
- D-Bus notation
- `out_signature` : str or None
- If not None, the signature of the return value in the usual
... 3175 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/checkbox-ng.git
More information about the Python-modules-commits
mailing list