未验证 提交 9c732dc5 编写于 作者: C Cleber Rosa

Merge branch 'result_upload-plugin-V5'

Signed-off-by: NCleber Rosa <crosa@redhat.com>
......@@ -30,6 +30,50 @@ specify a custom location via --html . Last but not least
the job finishes.
Results Upload Plugin
=====================
This optional plugin is intended to upload the Avocado Job results to
a dedicated sever.
To install the Result Upload plugin from pip, use::
pip install avocado-framework-plugin-result-upload
Usage::
avocado run passtest.py --result-upload-url www@avocadologs.example.com:/var/www/html
Avocado logs will be available at following URL:
- ssh ::
www@avocadologs.example.com:/var/www/html/job-2017-04-21T12.54-1cefe11
- html (If web server is enabled) ::
http://avocadologs.example.com/job-2017-04-21T12.54-1cefe11/
Such links may be refered by other plugins, such as the ResultsDB plugin
By default upload will be handled by following command ::
rsync -arz -e 'ssh -o LogLevel=error -o stricthostkeychecking=no -o userknownhostsfile=/dev/null -o batchmode=yes -o passwordauthentication=no'
Optionally, you can customize uploader command, for example following command upload logs to Google storage: ::
avocado run passtest.py --result-upload-url='gs://avocadolog' --result-upload-cmd='gsutil -m cp -r'
You can also set the ResultUpload URL and command using a config file::
[plugins.result_upload]
url = www@avocadologs.example.com:/var/www/htmlavocado/job-results
command='rsync -arzq'
And then run the Avocado command without the explicit cmd options. Notice
that the command line options will have precedence over the
configuration file.
ResultsDB Plugin
================
......
[plugins.result_upload]
#URL where results will be upload to
#url = www@avocadologs.example.com:/var/www/htmlavocado/job-results
#command to be invoked on upload, $command $job_logdir $url
#command='rsync -arz'
#
## Examples: gcloud storage
#url=gs://avocadolog/
#command='gsutil -m cp -r '
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 LICENSE for more details.
#
# Copyright: Virtuozzo Inc. 2017
# Authors: Dmitry Monakhov <dmonakhov@openvz.org>
"""
Avocado Plugin to propagate Job results to remote host
"""
from avocado.core.plugin_interfaces import CLI, Result
from avocado.core.settings import settings
from avocado.utils import process
from avocado.utils import path as utils_path
class ResultUpload(Result):
"""
ResultsUpload output class
"""
name = 'result_upload'
description = 'ResultUpload result support'
def render(self, result, job):
"""
Upload result, which corresponds to one test from
the Avocado Job
if job.status == "RUNNING":
return # Don't create results on unfinished jobs
"""
self.upload_url = None
if getattr(job.args, 'result_upload_url', None) is not None:
self.upload_url = job.args.result_upload_url
self.upload_cmd = None
if getattr(job.args, 'result_upload_cmd', None) is not None:
self.upload_cmd = job.args.result_upload_cmd
if self.upload_url is None:
return
if self.upload_cmd is None:
return
ret = process.run("%s %s %s" % (self.upload_cmd, job.logdir,
self.upload_url))
if ret.exit_status:
job.log.error("ResultUploader failed msg=%s" % result.stderr)
class ResultUploadCLI(CLI):
"""
ResultsUpload output class
"""
name = 'result_upload'
description = "ResultUpload options for 'run' subcommand"
def configure(self, parser):
run_subcommand_parser = parser.subcommands.choices.get('run', None)
if run_subcommand_parser is None:
return
msg = 'result-upload options'
parser = run_subcommand_parser.add_argument_group(msg)
parser.add_argument('--result-upload-url',
dest='result_upload_url', default=None,
help='Specify the result upload url')
try:
rsync_bin = utils_path.find_command('rsync')
def_ssh = ('ssh -oLogLevel=error -o stricthostkeychecking=no'
' -o userknownhostsfile=/dev/null'
' -o batchmode=yes -o passwordauthentication=no')
def_upload_cmd = 'rsync -arz -e \'%s \'' % def_ssh
except utils_path.CmdNotFoundError:
def_upload_cmd = None
parser.add_argument('--result-upload-cmd',
dest='result_upload_cmd', default=def_upload_cmd,
help='Specify the command to upload results')
def run(self, args):
url = getattr(args, 'result_upload_url', None)
if url is None:
url = settings.get_value('plugins.result_upload',
'url',
default=None)
if url is not None:
args.result_upload_url = url
cmd = getattr(args, 'result_upload_cmd', None)
if cmd is None:
cmd = settings.get_value('plugins.result_upload',
'command',
default=None)
if cmd is not None:
args.result_upload_cmd = cmd
#!/bin/env python
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 LICENSE for more details.
#
# Copyright: Virtuozzo Inc. 2017
# Authors: Dmitry Monakhov <dmonakhov@openvz.org>
from setuptools import setup, find_packages
setup(name='avocado-framework-plugin-result-upload',
description='Avocado Plugin to propagate Job results to remote host',
version=open("VERSION", "r").read().strip(),
author='Avocado Developers',
author_email='avocado-devel@redhat.com',
url='http://avocado-framework.github.io/',
packages=find_packages(),
include_package_data=True,
install_requires=['avocado-framework'],
entry_points={
'avocado.plugins.cli': [
'results_upload = avocado_result_upload:ResultUploadCLI',
],
'avocado.plugins.result': [
'results_upload = avocado_result_upload:ResultUpload',
]})
......@@ -10,10 +10,10 @@
%global gittar %{srcname}-%{version}.tar.gz
%else
%if ! 0%{?commit:1}
%global commit 4aabc6a21ddfe741ba914b24902f24a23a9cda65
%global commit cf93b03d1b5693f9853bcf123c218074e90ae3f9
%endif
%if ! 0%{?commit_date:1}
%global commit_date 20171020
%global commit_date 20171215
%endif
%global shortcommit %(c=%{commit};echo ${c:0:8})
%global gitrel .%{commit_date}git%{shortcommit}
......@@ -29,7 +29,7 @@
Summary: Framework with tools and libraries for Automated Testing
Name: python-%{srcname}
Version: 56.0
Release: 0%{?gitrel}%{?dist}
Release: 1%{?gitrel}%{?dist}
License: GPLv2
Group: Development/Tools
URL: http://avocado-framework.github.io/
......@@ -144,6 +144,9 @@ popd
pushd optional_plugins/varianter_pict
%{__python} setup.py build
popd
pushd optional_plugins/result_upload
%{__python} setup.py build
popd
%{__make} man
%install
......@@ -175,6 +178,9 @@ popd
pushd optional_plugins/varianter_pict
%{__python} setup.py install --root %{buildroot} --skip-build
popd
pushd optional_plugins/result_upload
%{__python} setup.py install --root %{buildroot} --skip-build
popd
%{__mkdir} -p %{buildroot}%{_mandir}/man1
%{__install} -m 0644 man/avocado.1 %{buildroot}%{_mandir}/man1/avocado.1
%{__install} -m 0644 man/avocado-rest-client.1 %{buildroot}%{_mandir}/man1/avocado-rest-client.1
......@@ -210,6 +216,9 @@ popd
pushd optional_plugins/varianter_pict
%{__python} setup.py develop --user
popd
pushd optional_plugins/result_upload
%{__python} setup.py develop --user
popd
# Package build environments have the least amount of resources
# we have observed so far. Let's avoid tests that require too
# much resources or are time sensitive
......@@ -249,6 +258,7 @@ AVOCADO_CHECK_LEVEL=0 selftests/run
%exclude %{python_sitelib}/avocado_golang*
%exclude %{python_sitelib}/avocado_varianter_yaml_to_mux*
%exclude %{python_sitelib}/avocado_varianter_pict*
%exclude %{python_sitelib}/avocado_result_upload*
%exclude %{python_sitelib}/avocado_framework_plugin_result_html*
%exclude %{python_sitelib}/avocado_framework_plugin_runner_remote*
%exclude %{python_sitelib}/avocado_framework_plugin_runner_vm*
......@@ -258,6 +268,7 @@ AVOCADO_CHECK_LEVEL=0 selftests/run
%exclude %{python_sitelib}/avocado_framework_plugin_varianter_pict*
%exclude %{python_sitelib}/avocado_framework_plugin_loader_yaml*
%exclude %{python_sitelib}/avocado_framework_plugin_golang*
%exclude %{python_sitelib}/avocado_framework_plugin_result_upload*
%{_libexecdir}/avocado/avocado-bash-utils
%{_libexecdir}/avocado/avocado_debug
%{_libexecdir}/avocado/avocado_error
......@@ -398,6 +409,18 @@ Pair-Wise algorithms, also known as Combinatorial Independent Testing.
%{python_sitelib}/avocado_varianter_pict*
%{python_sitelib}/avocado_framework_plugin_varianter_pict*
%package plugins-result-upload
Summary: Avocado Plugin to propagate Job results to a remote host
Requires: %{name} == %{version}
%description plugins-result-upload
This optional plugin is intended to upload the Avocado Job results to
a dedicated sever.
%files plugins-result-upload
%{python_sitelib}/avocado_result_upload*
%{python_sitelib}/avocado_framework_plugin_result_upload*
%package examples
Summary: Avocado Test Framework Example Tests
Requires: %{name} == %{version}
......@@ -417,6 +440,9 @@ examples of how to write tests on your own.
%{_datadir}/avocado/varianter_pict
%changelog
* Fri Dec 15 2017 Cleber Rosa <cleber@redhat.com> - 56.0-1
- Added result_upload plugin
* Tue Nov 21 2017 Cleber Rosa <cleber@redhat.com> - 56.0-0
- New upstream release
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册